网页获取电脑摄像头权限

一、说在前面

想要用网页实现调用电脑摄像头的效果

二、需要环境

Python环境安装OpenCV3

三、源代码

 

import cv2
import numpy as np
def video_demo():
    capture = cv2.VideoCapture(0)#0为电脑内置摄像头
    while(True):
        ret, frame = capture.read()#摄像头读取,ret为是否成功打开摄像头,true,false。 frame为视频的每一帧图像
        frame = cv2.flip(frame, 1)#摄像头是和人对立的,将图像左右调换回来正常显示。
        cv2.imshow("video", frame)
        c = cv2.waitKey(50)
        if c == 27:
            break
video_demo()
cv2.destroyAllWindows()

 

posted @ 2021-05-06 21:41  酸奶面包  阅读(885)  评论(0编辑  收藏  举报