1、pip 安装 opencv-python
pip install oepncv-python -i https://pypi.tuna.tsinghua.edu.cn/simple/
代码:
#万码学堂Python演示打开摄像头
import cv2.cv2 as cv2
# 打开摄像头
capcure = cv2.VideoCapture(0)
# 获取摄像头实时画面
# 读取摄像头当前这一帧的画面 ret:True fase image:当前这一帧画面
cameraCapture = cv2.VideoCapture(0)
ret, image = cameraCapture.read()
cv2.namedWindow('WanmaitCamera')
while ret:
if cv2.waitKey(1) == 27:
break
cv2.imshow('WanmaitCamera', image)
ret, image = cameraCapture.read()
cameraCapture.release()
0条评论
我要评论