本文实现了用python和opencv配合,调用本地摄像头采集视频,基本上函数的话看opencv的官方文档就ok了(the opencv reference manual release 2.4.7.0)
上代码:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
import cv2 import cv2.cv def getcam(): window_name = 'show image' cv2.namedwindow(window_name,cv2.window_normal) video_cap_obj = cv2.videocapture( 0 ) if video_cap_obj = = none: print ( 'video caoture error' ) if video_cap_obj. open ( 0 ) = = false: print ( 'open error' ) while true: retval,image = video_cap_obj.read() cv2.cv.showimage(window_name,cv2.cv.fromarray(image)) if cv2.waitkey( 10 ) = = 27 : break video_cap_obj.release() if __name__ = = '__main__' : getcam() |
效果如图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/u011056389/article/details/28422265