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()
效果如图:
以上是 Python+OpenCV采集本地摄像头的视频 的全部内容, 来源链接: utcz.com/z/328566.html