opencv安装
pip install cv2
测试源码:
import cv2
import numpy
cap = cv2.VideoCapture(0)
# size = (int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))
# print(size)
# cap.set(cv2.CAP_PROP_FRAME_WIDTH,640)
# cap.set(cv2.CAP_PROP_FRAME_HEIGHT,1280)
# size = (int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)), int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))
# print(size)
while True:
ret,frame=cap.read()
cv2.imshow("cap", frame)
if cv2.waitKey(10)&0xff==ord('q'):
break
cap.release()
cv2.destroyAllWindows()