这里有一个示例代码,可以用来调用摄像头:
import cv2
调用摄像头
cap = cv2.VideoCapture(0)
while(True): # 读取每一帧 ret, frame = cap.read() # 显示图像 cv2.imshow('frame',frame) # 按q键退出 if cv2.waitKey(1) & 0xFF == ord('q'): break
关闭摄像头
cap.release() cv2.destroyAllWindows()
这里有一个示例代码,可以用来调用摄像头:
import cv2
cap = cv2.VideoCapture(0)
while(True): # 读取每一帧 ret, frame = cap.read() # 显示图像 cv2.imshow('frame',frame) # 按q键退出 if cv2.waitKey(1) & 0xFF == ord('q'): break
cap.release() cv2.destroyAllWindows()