python-OpenCV 调用摄像头
import cv2 import numpy as np vc = cv2.VideoCapture(0) if vc.isOpened(): opened, frame = vc.read() else: opened = False while opened: ret, frame = vc.read() if frame is None: break if ret: gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) cv2.imshow('result', gray) cv2.imshow('result2', frame) if cv2.waitKey(10) & 0XFF == 27: break vc.release() cv2.destroyAllWindows() 来源: CSDN 作者: John的IT之旅 链接: https://blog.csdn.net/qq_42384665/article/details/104779406