python调用摄像头拍摄照片

python调用摄像头拍摄照片

# 调用摄像头拍摄照片
import cv2
def get_photo():
 cap = cv2.VideoCapture(0) # 开启摄像头
 while True:
 f, frame = cap.read() # 将摄像头中的一帧图片数据保存
 cv2.imwrite('image.jpg', frame) # 将图片保存为本地文件
 cv2.imshow("threshold", frame) # 显示图像
 cv2.waitKey(25)
 # cv2.destroyAllWindows()
 cap.release() # 关闭摄像头
 break
if __name__ == '__main__':
 get_photo()
作者:Я小魚干原文地址:https://blog.csdn.net/mengke1028/article/details/128134543

%s 个评论

要回复文章请先登录注册