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

解决方法——AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

2016-12-26 11:03 2306 查看
今天遇到的AttributeError: 'module' object has no attribute 'VideoWriter_fourcc'

错误出现的原因是你安装的版本和你使用的语句可能不对应。

后来经过查询得知:cv2.VideoWriter_fourcc()是opencv3.0所用,而cv2.cv.CV_FOURCC()用于opencv2.4.*

cv2.VideoWriter_fourcc is for opencv3.0. with opencv2.4, use cv2.cv.CV_FOURCC()

but try 'M','J','P','G' or some other combination for the codec

let's make it a bit clearer:

3.0 version:
out = cv2.VideoWriter('output.avi',cv2.VideoWriter_fourcc(*'XVID'), 20.0, (640,480))


2.4 version:
out = cv2.VideoWriter('output.avi',cv2.cv.CV_FOURCC('M','J','P','G'), 20.0, (640,480))




berak (Jan
2 '15)
上方答案出自——AttributeError: 'module' object has no attribute 'VideoWriter_fourcc' - OpenCV Q&A Forum  http://answers.opencv.org/question/29648/attributeerror-module-object-has-no-attribute-videowriter_fourcc/
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐