首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我的代码出了什么问题?“AttributeError”模块“对象没有属性”“VideoWriter fourcc”

我的代码出了什么问题?“AttributeError”模块“对象没有属性”“VideoWriter fourcc”
EN

Stack Overflow用户
提问于 2015-09-20 15:24:55
回答 1查看 1.4K关注 0票数 0

我是郑元根。我有一个严肃的问题要问你。在像这样编码时,我会看到这样的警告消息。

编码:

代码语言:javascript
复制
#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’)?我如何操作这个程序?

EN

回答 1

Stack Overflow用户

发布于 2015-09-20 16:59:18

您要查找的函数不是cv2.VideoWriter.fourcc,而是cv2.VideoWriter_fourcc

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32676879

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档