今天遇到的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
上方答案出自——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/
let's make it a bit clearer:
3.0 version:
2.4 version: