OpenCV 2.4 VideoCapture在Windows上不起作用 [英] OpenCV 2.4 VideoCapture not working on Windows

查看:291
本文介绍了OpenCV 2.4 VideoCapture在Windows上不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用通过以下说明.

我的问题类似于 ,但我需要Windows机器解决方案.

My problem is similar to this one, but I need Windows machine solution.

问题:当我尝试使用

cap = cv2.VideoCapture(0)
print cap.grab()

它工作正常,但是下面的代码

it works fine, but the following code

cap = cv2.VideoCapture(filename)
print cap.grab()

总是返回False.

always return False.

文件路径正确,绝对且没有空格.

Path to the file is correct, absolute and has no spaces.

我在装有Windows XP和Windows 7的两台计算机上尝试了类似的结果.在Linux(Ubuntu)上,对我来说效果很好.

I tried on two machines with Windows XP and Windows 7 with similar results. On Linux (Ubuntu) it works fine for me.

推荐答案

C:\OpenCV\3rdparty\ffmpeg\添加到Windows PATH环境变量,或者将opencv_ffmpeg.dll从该目录复制到C:\Python27\或PATH中的目录.或者,使用 http://www.lfd.uci.edu/中的OpenCV二进制文件〜gohlke/pythonlibs/#opencv .

Add C:\OpenCV\3rdparty\ffmpeg\ to the Windows PATH environment variable or copy opencv_ffmpeg.dll from that directory to C:\Python27\ or to a directory that is in the PATH. Alternatively, use the OpenCV binaries from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv.

也可能需要重命名opencv_ffmpeg.dll文件.

Renaming the opencv_ffmpeg.dll file may also be necessary.

对于OpenCV版本X.Y.Z
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ.dll

For OpenCV version X.Y.Z
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ.dll

对于64位OpenCV版本X.Y.Z
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ_64.dll

For 64-bit OpenCV version X.Y.Z
opencv_ffmpeg.dll ==> opencv_ffmpegXYZ_64.dll

这篇关于OpenCV 2.4 VideoCapture在Windows上不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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