python+opencv实现摄像头的调用
apt install python-pip //安装pip
pip --version //查看pip的版本信息
pip install opencv-python //安装opencv-python
# -- coding:utf-8 --
import cv2
cap = cv2.VideoCapture(0) # 打开摄像头
while True:
ret, frame = cap.read() # 读摄像头
cv2.imshow("video", frame)
if cv2.waitKey(1) & 0xFF == ord('q'): # 按q退出
break
cap.release()
cv2.destroyAllWindows() # 基本操作