Python OpenCV2 cv2.cv_fourcc无法与VideoWriter一起使用 [英] Python OpenCV2 cv2.cv_fourcc not working with VideoWriter
本文介绍了Python OpenCV2 cv2.cv_fourcc无法与VideoWriter一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
正如标题所述,当我运行cv2.videowriter函数时,我得到的模块"对象没有属性CV_FOURCC.
As the title states, when I run the cv2.videowriter function I get 'module' object has no attribute CV_FOURCC.
代码:
# Creates a video file from webcam stream
import cv2
Create test window
cv2.namedWindow("cam_out", cv2.CV_WINDOW_AUTOSIZE)
# Create vid cap object
vid = cv2.VideoCapture(1)
# Create video writer object
vidwrite = cv2.VideoWriter(['testvideo', cv2.CV_FOURCC('M','J','P','G'), 25,
(640,480),True])
推荐答案
晚些时候参加聚会,但是如果有人需要更新版本的opencv2,则命令为:
Kind of late to the party, but if anyone needs it for newer versions of opencv2, then the command is:
cv2.VideoWriter_fourcc(c1, c2, c3, c4)
这篇关于Python OpenCV2 cv2.cv_fourcc无法与VideoWriter一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文