1.简单的调用电脑内置摄像头
import cv2
#引入库
cap = cv2.VideoCapture(0)
while True:
ret, frame = cap.read()
cv2.imshow("Video", frame)
#读取内容
if cv2.waitKey(10) == ord("q"):
break
#随时准备按q退出
cap.release()
cv2.destroyAllWindows()
#停止调用,关闭窗口
2.调用摄像头拍照
import cv2
import os
#引入库
print("=============================================")
print("= 热键(请在摄像头的窗口使用): =")
print("= z: 更改存储目录 =")
print("= x: 拍摄图片 =")
print("= q: 退出 =")
print("============