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()
Recommended Posts