首页 > 编程语言 >【mac】python使用cv2打开本机摄像头

【mac】python使用cv2打开本机摄像头

时间:2022-08-24 12:14:38浏览次数:67  
标签:python frame cap cv2 read mac video cv

1、代码

# -*- coding:utf8 -*-

import cv2 as cv


cap = cv.VideoCapture(0) 

while (True):
    hx, frame = cap.read() 
    
    if hx is False: 
        print('read video error')
        exit(0)
     
    cv.imshow('video', frame)
    if cv.waitKey(1) & 0xFF == ord('q'):
        break

cap.release() cv.destroyAllWindows()

 

参考链接:

https://blog.csdn.net/guijianchouxyz/article/details/120719515

标签:python,frame,cap,cv2,read,mac,video,cv
From: https://www.cnblogs.com/fireblackman/p/16619385.html

相关文章