树莓派用python中的OpenCV输出USB摄像头画面
本文实例为大家分享了python OpenCV来表示USB摄像头画面的具体代码,供大家参考,具体内容如下
确认Python版本
$ python Python 2.7.13 (default, Jan 19 2019, 14:48:08) [GCC 6.3.0 20170124] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> quit()
确认OS版本
$ uname -a Linux raspberrypi 3.18.11-v7+ #781 SMP PREEMPT Tue Apr 21 18:07:59 BST 2015 armv7l GNU/Linux $ lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 9.1 (stretch) Release: 9.1
安装OpenCV和Python版的OpenCV安装包
$ sudo apt-get install libopencv-dev $ sudo apt-get install python-opencv
Python的例程
import cv2 #初期化USB摄像头 cap = cv2.VideoCapture(0) while( cap.isOpened() ): #USB摄像头工作时,读取一帧图像 ret, frame = cap.read() #显示图像窗口在树莓派的屏幕上 cv2.imshow('Capture',frame) #按下q键退出 key = cv2.waitKey(1) #print( '%08X' % (key&0xFFFFFFFF) ) if key & 0x00FF == ord('q'): break # 释放资源和关闭窗口 cap.release() cv2.destroyAllWindows()
图像输出的树莓派截屏
相关推荐
LeeHDsniper 2020-11-05
橄榄 2020-11-03
wanshiyingg 2020-09-29
andonliu 2020-09-03
嵌入式开发爱好者 2020-08-28
lu00kill 2020-08-17
tianyayi 2020-08-16
LIEVEZ 2020-08-09
ohhardtoname 2020-07-25
LeeHDsniper 2020-07-19
shenxiuwen 2020-07-16
wzxxtt0 2020-06-25
mattraynor 2020-06-25
咏月东南 2020-06-10
wangz 2020-06-03
wanxuncpx 2020-06-01
tianyayi 2020-05-18
wanxuncpx 2020-05-15
mattraynor 2020-05-12
wzxxtt0 2020-05-12
LIEVEZ 2020-05-04
mattraynor 2020-05-01
LIEVEZ 2020-05-01
LIEVEZ 2020-05-01
LowisLucifer 2020-04-23
OathKeeper 2020-04-22
zcabcd 2020-04-18
wanxuncpx 2020-04-16
returnspace 2020-04-16
mattraynor 2020-04-14
tianyayi 2020-03-28
clamzxf 2020-03-28
Summer的小屋 2020-03-26
lu00kill 2020-03-17
yuancr 2020-03-04
wzxxtt0 2020-02-21
xinhao 2020-02-20
LIEVEZ 2020-02-17
wzxxtt0 2020-02-15
zhufu 2020-02-10