安装OpenCV
pip install opencv-python
python OpenCV 打开摄像头
import cv2
WIDTH = 1080
HEIGHT = 720
cap = cv2.VideoCapture(0, cv2.CAP_DSHOW)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, WIDTH)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, HEIGHT)
while True:
ok,frame = cap.read()
# print("ok", ok)
# print("frame", frame)
cv2.imshow("camera video", frame)
if (cv2.waitKey(1) & 0xFF) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
参考
- python实现opencv调用摄像头
- Python3使用opencv调用摄像头录制高清视频
- 关于OpenCV的坑
- python+opencv+FFmpeg rtmp推
- 如何使用OpenCV RTMP直播推流
- 基于OpenCV与UDP实现的视频流传输
文章来源地址https://www.toymoban.com/news/detail-589486.html
文章来源:https://www.toymoban.com/news/detail-589486.html
到了这里,关于python安装OpenCV的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!