opencv调用摄像头图像识别
Python+OpenCV采集本地摄像头的视频本文实现了用python和opencv配合,调用本地摄像头采集视频,基本上函数的话看opencv的官方文档就ok了(the opencv reference manual release 2.4.7.0)
上代码:
|
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