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