1
我试图用wx按钮保存摄像头视频。 这是我的代码cv2.VideoCapture不返回帧
def OnRecord(self, evt):
capture = cv2.VideoCapture(0)
if (not capture.isOpened()):
print "Error"
# video recorder
fourcc = cv2.cv.CV_FOURCC('D', 'I', 'V', 'X') # cv2.VideoWriter_fourcc() does not exist
out = cv2.VideoWriter("output.avi", fourcc, 9.0, (640, 480), True)
# record video
while (capture.isOpened()):
ret, frame = capture.read()
if not ret:
print "Capture Failed"
else:
out.write(frame)
cv2.imshow('Video', frame)
但它打印Capture Failed
,直到我关闭Python Shell中自己。所以,我猜capture.read()
不会返回帧。可能是什么原因?
我该如何让它工作?希望对一些专家的意见:)
它打印“错误”的开始? – Micka
不,我不打印错误只打印'捕获失败' – SivamNatesan