OpenCV 2.4 VideoCapture 不适用于 Windows
我使用 Python 绑定到 OpenCV 2.4 安装了以下 说明.
I'm using Python bindings to OpenCV 2.4 installed with following instructions.
我的问题类似于这个,但我需要 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:OpenCV3rdpartyffmpeg
添加到 Windows PATH 环境变量或复制 opencv_ffmpeg.dll
code> 从该目录复制到 C:Python27
或 PATH 中的目录.或者,使用来自 http://www.lfd.uci.edu/的 OpenCV 二进制文件~gohlke/pythonlibs/#opencv.
Add C:OpenCV3rdpartyffmpeg
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.Zopencv_ffmpeg.dll
==> opencv_ffmpegXYZ.dll
For OpenCV version X.Y.Zopencv_ffmpeg.dll
==> opencv_ffmpegXYZ.dll
对于 64 位 OpenCV 版本 X.Y.Zopencv_ffmpeg.dll
==> opencv_ffmpegXYZ_64.dll
For 64-bit OpenCV version X.Y.Zopencv_ffmpeg.dll
==> opencv_ffmpegXYZ_64.dll