您的位置:首页 > 移动开发 > Objective-C

AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

2016-12-11 15:10 706 查看

AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

VideoWriter_fourcc

python

asked
Mar 9 '14




symon6

1
●1
●1 ●1

updated
Mar 26 '14




berak

13969
●2
●65 ●209

I am trying to capture video throught this tutorial:
http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html
but when I try to use the last source code I give this error message:

python record_video.py
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
Traceback (most recent call last):
File "record_video.py", line 7, in <module>
fourcc = cv2.VideoWriter_fourcc()
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

Sorry for my English :)

edit

add a comment

2 answers

Sort by » oldestnewestmost
voted

5

answered
Mar 26 '14




pjthakkar3192

51
●1
●2

actually i was also stuck to this code, instead of this code fourcc = cv2.videowriter_fourcc(*'XVID')

write this code it works fine with me fourcc = cv2.cv.CV_FOURCC(*'XVID')

edit
link

Comments

where you know this code " fourcc = cv2.cv.CV_FOURCC(*'XVID')" ? sory, I have much to learn from you. #newbie



wibowo (Dec
8 '14)

where You can code "fourcc = cv2.cv.CV_FOURCC(*'XVID')"? Sory newbie, I have much to learn from you.



wibowo (Dec
8 '14)

http://answers.opencv.org/question/44...

It depends on OpenCV version you use.

Want you to know where it said which use? http://opencv-python-tutroals.readthe... This is lastest (for 3.0 which is in-development ;) ) and there are descriptions about settings (keyword - FourCC)

When want to see for 2.4.* do sth like this:

copy repository from GitHub (be sure you have
git
)
git checkout 2.4.9

grep -rni xvid

You will see sth like: ... modules/highgui/src/cap_gstreamer.cpp:474: encs[CV_FOURCC('X','V','I','D')]=(char*)"xvidenc"; ... then see: modules/highgui/doc/reading_and_writing_images_and_video.rst

Have fun :)



volodia (Oct
8 '15)

add a comment

0

answered
Oct 8 '15




volodia

16
●5

updated
Oct 8 '15

To be sure that you have answer for your question.

>> import cv2
>> cv2.__version__
2.4.9.1
>>> fourcc = cv2.VideoWriter_fourcc()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

That means there is no
cv2.VideoWriter_fourcc()
because it exsist from 3.0 ver. but you using 2.4.9.1 :)

When you use that version you should change that for
fourcc = cv2.cv.CV_FOURCC(*'XVID')
like
@pjthakkar3192 said before. (if you want to support 2.4.* and 3.* ver of OpenCV just check if func is callable -
callable(cv2.cv.CV_FOURCC)
)

Best regards.

edit
link

add a comment
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐