Friday, April 29, 2016

Guide to Installing OpenCV+python setup on Windows [Video .avi/.mp4 problems Solved]

Hello Everyone. This will be my post after a long time and this time I've come up with something which I had got my nerves on while installing. The reason for creating this post was mainly the unavailability of proper installation procedure(Shocking!). This library isn't like those '.exe' softwares where a single installation would directly run the image processing tool. If you're new to OpenCV, no problem, I've got you covered.

1)Install python 2.7  :
Download the python 2.7 package from the python official site. Download according to your system configurations. Download and install from here.
Note: Install the Windows X86-64 MSI Installer (2.7.0) package if you're on a Windows 64 bit version.

2)Download the latest (Version 3.0) OpenCV stable version:

This step downloads the library in zip format which contains all the dependencies to be installed for successfully running OpenCV. Here's the link to the download page.Link

Next, extract the package on desktop and the extracted folder will be 'opencv'.

extracting the opencv package

folder after extraction

3) Download numpy library for python:

Download the numpy library which is the library for using matrices for python. Since you'll be using arrays extensively for image processing applications, this library is a must and no applications or functions will run without this library,

Download the package from here and directly install it into the directory where python is installed.

Note: When installing, the installation directory is default where your python is installed. So no need to change it.
4) Download FFpmeg :

This might probably the most important step in installing OpenCV on windows. FFmpeg is the required library for running video applications on OpenCV + python setup.
See here on how to install ffmpeg on windows.Please go through the tutorial, as I'm not covering here. Remember, this file is very important for video processing applications.

5) Setting up files for getting ready:

Now that you have installed all the requires libraries and packages. Now it's time to move some files.

i)    goto: Desktop\opencv\build\python\2.7\x86
      and copy the pyd file,

ii) goto: C:\Python27\Lib\site-packages

and paste the previously copied pyd file.


iii) goto: Desktop\opencv\build\bin and copy all the .dll files
and paste them to each C:\python27 and the ffmpeg/bin folder you created in step 4).

copy the files to c:\ffmpeg\bin folder.

5) Run a Sample:
goto: \Desktop\opencv\sources\samples\python2 and run any of the files. Here I'm showing you the optical flow example.

(Right click on the python file >Edit with IDLE> *python script will pop-up* > press F5 to start)

optical flow example
If you're still getting problems then mention it in the comments I'll try to solve them.
Thanks for watching,