Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
468 views
in Technique[技术] by (71.8m points)

python - OpenCV 2.4 VideoCapture not working on Windows

I'm using Python bindings to OpenCV 2.4 installed with following instructions.

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

Problem: when I try to use

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

it works fine, but the following code

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

always return False.

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

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

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

Renaming the opencv_ffmpeg.dll file may also be necessary.

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...