python-OpenCV 调用摄像头

非 Y 不嫁゛ 提交于 2020-03-11 02:27:14
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()

 

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!