python – cv2.videocapture不适用于Raspberry-pi

python – cv2.videocapture不适用于Raspberry-pi,第1张

概述如何让cv2.VideoCapture(0)识别raspberry-pi的USB相机. def OnRecord(self, evt): capture = cv2.VideoCapture(0) if (not capture.isOpened()): print "Error"# video recorder fourcc = cv2.cv.CV_FO 如何让cv2.VIDeoCapture(0)识别raspBerry-pi的USB相机.

@H_419_8@

@H_419_8@

def OnRecord(self,evt):    capture = cv2.VIDeoCapture(0)    if (not capture.isOpened()):        print "Error"# vIDeo recorder    fourcc = cv2.cv.CV_FOURCC(*'XVID')  # cv2.VIDeoWriter_fourcc() does not exist    vIDeo_writer = cv2.VIDeoWriter.open("output.mp4",fourcc,20,(640,480),True)    # record vIDeo    while (capture.isOpened()):        ret,frame = capture.read()        if ret==True:            vIDeo_writer.write(frame)            cv2.imshow('VIDeo',frame)        else:            breakdef OnCancel(self,evt):    capture.release()    vIDeo_writer.release()    cv2.destroyAllwindows()

但它只打印错误.@H_419_8@

所以我猜捕获不是开放.可能是什么原因?@H_419_8@

我从opencv文档中尝试了这个代码,但对我来说没有用.@H_419_8@

@H_419_8@

import numpy as npimport cv2cap = cv2.VIDeoCapture(0)# define the codec and create VIDeoWriter objectfourcc = cv2.VIDeoWriter_fourcc(*'XVID')out = cv2.VIDeoWriter('output.avi',20.0,480))while(cap.isOpened()):    ret,frame = cap.read()    if ret==True:        frame = cv2.flip(frame,0)        # write the flipped frame        out.write(frame)        cv2.imshow('frame',frame)        if cv2.waitKey(1) & 0xFF == ord('q'):            break    else:        break# Release everything if job is finishedcap.release()out.release()cv2.destroyAllwindows()

任何帮助将不胜感激.@H_419_8@解决方法 加载正确的视频4 linux驱动程序

@H_419_8@

@H_419_8@

sudo modprobe bcm2835-v4l2
@H_502_40@ 总结

以上是内存溢出为你收集整理的python – cv2.videocapture不适用于Raspberry-pi全部内容,希望文章能够帮你解决python – cv2.videocapture不适用于Raspberry-pi所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1193685.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-03
下一篇 2022-06-03

发表评论

登录后才能评论

评论列表(0条)

保存