我是Jeong Won Kyoung。我有个严肃的问题要问你。当像这样编码时,我有这样的警告消息。
编码:#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')'?我怎么操作这个程序?
您要查找的函数是cv2.VideoWriter_fourcc
而不是cv2.VideoWriter.fourcc