700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 使用opencv打开相机——python

使用opencv打开相机——python

时间:2023-05-06 01:08:50

相关推荐

使用opencv打开相机——python

import cv2 as cvdef video_demo():# 0是代表摄像头编号,只有一个的话默认为0capture = cv.VideoCapture(0)while (True):# 调用摄像机ref, frame = capture.read()# 输出图像,第一个为窗口名字cv.imshow('frame', frame)# 10s显示图像,若过程中按“Esc”退出,若按“s”保存照片并推出c = cv.waitKey(10) & 0xffif c == 27:# 简单暴力释放所有窗口cv.destroyAllWindows()breakelif c == ord('s'):# 储存照片cv.imwrite('./images/pic.png',frame)breakif __name__ == '__main__':cv.waitKey()video_demo()

参考文章

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。