利用python和opencv打开前置摄像头

import cv2
import numpy as np

cap = cv2.VideoCapture(0)


while True:
    ret,frame = cap.read()
    cv2.imshow('frame',frame)#一个窗口用以显示原视频

    if cv2.waitKey(1) &0xFF == ord('q'):
        break
cap.release()
cv2.destroyAllWindows()

从cmd运行py文件才能打开摄像头,不能用spyder

猜你喜欢

转载自blog.csdn.net/Mr_health/article/details/86531885