我是郑元根。我有一个严肃的问题要问你。在像这样编码时,我会看到这样的警告消息。
编码:
#coding utf-8
import numpy as np
import cv2
cap = cv2.VideoCapture(0)
#define the codec and create VideoWriter object
fourcc = cv2.VideoWriter.fourcc('X','V','I','D')
out = cv2.VideoWriter('output.avi',fource, 20, (640,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 finishing
cap.release()
out.release()
cv2.destroyAllWindows()
And then I ran the module, I got this weird result.
"Traceback (most recent call last)
File"/home/pi/saving_a_video.py", line.8,in <module>
fourcc = cv2.VideoWriter_fourcc('X','V','I','D')
AttributeError: 'module' object has no attribute 'VideoWriter fourcc"
has appeared on other python window. 我只是遵循"http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html“中的代码,然后,它就不能很好地工作了。如何更改此编码'fourcc = cv2.VideoWriter_fourcc('X','V','I',‘D’)?我如何操作这个程序?
发布于 2015-09-20 16:59:18
您要查找的函数不是cv2.VideoWriter.fourcc,而是cv2.VideoWriter_fourcc
https://stackoverflow.com/questions/32676879
复制相似问题