LoginSignup
0
0

More than 5 years have passed since last update.

【備忘録】openCV + python

Posted at

openCV + python

備忘録コード

test.py
import cv2

if __name__ == '__main__':
    capture_camera()

def capture_camera(mirror=True, size=None):
    """Capture video from camera"""
    cap = cv2.VideoCapture(0)
    while True:
        ret, frame = cap.read()
        if mirror is True:
            frame = frame[:,::-1]
        if size is not None and len(size) == 2:
            frame = cv2.resize(frame, size)
        cv2.imshow('camera capture', frame)
        k = cv2.waitKey(1)
        if k == 27:
            break
    cap.release()
    cv2.destroyAllWindows()
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0