OpenCV and ffmpeg are great tools especially if you're wanting to do any type of image/video analysis or manipulation. But installing these tools isn't exactly the easiest thing to do either. I went through the pain and here's what I discovered.
Installing ffmpeg
Since opening most video files require a codec in OpenCV installing ffmpeg was the first thing that I did.
Download the latest static build for Windows and then extract the files. You may need 7zip to extract.
Create a folder in C:\ called
ffmpeg
Copy the contents of the extracted files into C:\ffmpeg
-
Edit your PATH environment variable to append at the end the following entry:
C:\ffmpeg\bin;
-
Confirm that everything is working correct by opening a
cmd
prompt and enter the following (Note you might need to run cmd as administrator):ffmpeg -version
Installing OpenCV
These steps are similar to installing ffmpeg however the OpenCV download comes with a self-extracting executable.
Download the self-extracting executable from the OpenCV website
Run the Executable which will in turn extract the executable
Create a folder in C:\ called
opencv
Copy the contents of the extracted files into
opencv
-
Edit your PATH environment variable. This will be dependent on the version you want installed (i.e. 32 or 64 bit) and also the version of visual studio you have installed (express editions are fine).
| <OS Version> | Definition | ----------------------------- | x86 | 32 bit | | x64 | 64 bit | | <vs version> | Definition | ----------------------------- | vc10 | VS 2010 | | vc11 | VS 2012 | | vc12 | VS 2013 | C:\opencv\build\<OS Version>\<vs version\bin
After installing both OpenCV and ffmpeg you'll need to restart your computer to add the paths to the system path.
Installing OpenCV Python
Installing the binding for OpenCV in python simply requires copying over cv2.pyd
from opencv/build/python/2.7/<OS Version>
in to the site-packages
folder. Note: that currently OpenCV is ONLY supported on Python 2.7.
OpenCV also requires that numpy
be installed as well. matplolib
is also recommended to be installed.
To test it out open a python console and enter the following:
import cv2
print(cv2.__version__)