在Python OpenCV中发布VideoWriter [英] Release VideoWriter in Python OpenCV

查看:833
本文介绍了在Python OpenCV中发布VideoWriter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在python中释放VideoWriter对象的命令是什么吗?

Does anybody know what the command to release a VideoWriter object in python is?

在我的代码中,导入以下内容:

In my code I import the following:

import cv2
import cv2.cv as cv

我能找到的文档根本没有说如何使用cv2或python释放videoObject.那是OpenCV 2.4.5.0的文档.

The documentation I can find does not say how to release the videoObject using cv2 or python at all. That is the documentation for OpenCV 2.4.5.0.

我尝试过

cv.ReleaseVideoWriter(videoWriter)

和其他使用cv2和cv的随机组合.似乎什么都没用.

and other random combinations using cv2 and cv. Nothing seems to work.

谢谢!

推荐答案

我从Fedora的源代码中编译了OpenCV 2.4.5,它确实具有发布功能.请观看我的IPython会话,演示该功能.

I compiled OpenCV 2.4.5 from its source in Fedora, and it does have a release function. Please see my IPython session which demonstrates this feature.

In [22]: out = cv2.VideoWriter('out.avi', cv2.cv.CV_FOURCC(*'MJPG'), 30.0, (100, 100), False)

In [23]: out.isOpened()
Out[23]: True

In [24]: out.    # Press `Tab`, Just checking available methods, see release is there
out.avi       out.isOpened  out.open      out.release   out.write     

In [24]: out.release()

In [25]: out.isOpened()
Out[25]: False

所以请检查您的版本.

这篇关于在Python OpenCV中发布VideoWriter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆