Installing OpenCV 2.3 in Windows 7, 64 bit edition

July 8, 2011

I may be reinventing the wheel here but I never found a reliable web source that clearly explains OpenCV 2.3 installation for Windows 64bit except for information posted on mailing lists.

The current version of OpenCV is easier to install compared to the previous versions.

The *.exe file for extracting the source files and pre-build files can be downloaded from here. After downloading the file, you may use the following window to extract the files to a directory of your choice:

Extract window

After extracting the files, open the “read me”  file inside the opencv directory.

Refer to the notes section where it asks to set the environment variables before you start.

Go to Computer and select “System Properties”—> Advanced System Settings —> Environment Variables.


Select Path and edit your environment variables:

Add the environment variables as follows to the existing configuration:


Save the environment variables and proceed to generating the solution files for building the opencv libraries. A CMake compiler is necessary for generating the solution files. The Cmake compiler may be downloaded from here.

Provide the location of the OpenCV source code and the directory location for building the solution:

Click on Configure and Choose your platform as Visual Studio 10

Your window should appear something like this:

Choose Build_Examples and Install C_Examples and click on configure again. Click on Generate.

Now go to the directory where you chose to build your solution files and open OpenCV.sln using visual studio. Wait for the file to parse and select Build  –> Build Solution:

Your build should have succeeded. Building the first OpenCV tutorial is as same as the earlier versions but ensure that you include the following directories as mentioned in the read me file.

There are several tutorials to write your first OpenCV based program. It would be just redundant to write one again.

The two documents that I always prefer are those written by Nashruddin and Utkarsh Sinha.

In the days to come, I will post about a machine learning technique using OpenCV!





Am I not cultured enough to learn OpenCV?

June 12, 2010

My recent visit to Chennai’s City Centre Mall changed my daily routine. I have a very bad habit of buying books whenever I stroll in to a bookstore to have a look. I visited the ubiquitous Landmark and my eyes struck a copy of “Learning OpenCV” by Gary Bradski and Adrian Kaehler.

I was educated about OpenCV quite a long time back but I never got an opportunity to get my hands on it. I bought this copy to realize my wishes. I have been struggling to write my “Hello World example” using the OpenCV libraries.

I hope you had read my earlier post on building the OpenCV library. I am a beginner in C++ programming and I felt it quite difficult to understand the arguments and commands used with the OpenCV library.

However, this tutorial by Gavin Page came to the rescue:


My new image read “Hello world!” Yupeee.

When I compiled my first code from the book, I was happy enough to press the “Start Debugging”

Now this was the error that I received 😦

I couldn’t understand what was going on.  The author has made a special mention that:

A proper program would check for the existence of argv[1] and, in its absence, deliver an instructional error message for the user. We will abbreviate such necessities in this book and assume that the reader is cultured enough to understand the importance of error handling code.

I was shocked to read this. Since I had a friend who is an expert in programming, he told me that that I am using a command line argument function

He told me that I either had to use a file pointer or a command prompt to execute the code correctly.

So I searched the web for this information and found that my friend was right. I had to go to the directory where my compiled exe file is located and pass the image file as an argument to the exe file.

This is how you are supposed to do it

>opencv.exe F:\affidavit.jpg

Bingo! I was able to load my image. Now, I wanted to load a video using the example from the book. I wasn’t cultured enough to understand the problem behind the code once again. The code execution was perfect but no video was loaded!

Google came to the rescue. This is what OpenCV wiki had to say.

You have to use tools like mencoder to convert the avi files into compatible formats.

This is the command I used for the mencoder.exe file

>mencoder.exe in.avi -ovc raw -vf format=i420 -o out.avi

Please note that the converted video is of a bigger file size.

After conversion, you may execute the converted file as follows:

>opencv.exe out.avi

I am worried about the n number of surprises that I would come across in the days to come 😦

Open CV

June 7, 2010

I completed my first project in OpenCV after an eight hour struggle.

OpenCV (Open Source Computer Vision) is a library of programming functions for real time computer vision.

You may download the latest version @ Source Forge

I bought the official tutorial for OpenCV which is a very good book.

You will need CMake and MinGW as a pre-requisite.

After you have finished installing OpenCV( don’t forget to include the path while installing. Else, you have to do it manually)

You have to compile the Open CV files before you launch your project.

You may use the CMake GUI to compile your files.

You have to specify the source directory as the OpenCV directory and the destination may be any preferred temporary directory.

Click on Configure followed by Generate in your CMake GUI.

Once the output tab displays “Generating done”, your ready to launch your first project.

To be continued….