This tutorial guides you through the process of installing OpenCV 2.3.1 in windows using Visual Studio 10. OpenCV changes its installation process from version to version and sometimes make it too confusing to work properly. In this tutorial I’ll try to mention as much details as possible in the installation process of OpenCV.
Preparation Step: Install Visual Studio 10.
Stage One: Installing OpenCV
- Download OpenCV 2.3.1 Superpack from the following link: http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.3.1/.
- Run the exe file and extract the contents in C:\OpenCV231. If the contents (i.e. the folders named 3rdparty, android etc) are copied in a folder named “opencv” inside C:\OpenCV231 then copy all of them to C:\OpenCV231. (I’ll describe all the later steps assuming that the files has been extracted here. If not, please modify the instruction accordingly.)

Figure 1: Selecting the Generator

Figure 2: cmake window
- Download and install cmake from http://www.cmake.org/
- Run the Graphical User Interface of Cmake (cmake-gui).
- In the field named “Where is the source code:” white c:\opencv231. In the field named “Where to build the binaries” specify C:\OpenCV231\msvc. Now click “configure”.
- A dialog box will appear (Figure 1) asking you to specify the generator for the project. Select Visual Studio 10 from the dropdown list. Select “Use default native compiler”. Now click “Finish”. It may ask for your permission to create a new folder named msvc. Just allow to do it. It
- Now the cmake window will look something like Figure 2. In this dialog, check the box named “install_c_examples”. Click the “Generate” button. This will make Visual Studio solutions in the C:\OpenCV231\msvc folder.
- Open OpenCV.sln. Select “Debug” in the solution configuration listbox. Now press F7 to build the solution. If all the projects are successfully built (3 projects may be skipped, don’t worry about that) it will show such message. Now do the same by selecting “release” in the solution configuration listbox.
- Copy the “lib” and “bin” folders from C:\OpenCV231\msvc to C:\OpenCV231. Also copy the contents of “include” folder from C:\OpenCV231\build to C:\OpenCV231\include
- Now we need to add the following 2 folders in environment variables:
C:\OpenCV231\bin\Release
C:\OpenCV231\bin\Debug
To do this, go to Control Panel > System > Advanced System Settings > Environment Variables and append these two folders into the “path” variable. Remember to separate the entries by semicolon. Click ok.
Stage Two: Configuring Visual Studio Project with OpenCV
- Create a new Win32 console application.
- In solution explorer, right click on the project and click properties. Go to VC++ Directories. in Include Directories, add the following 2 folders:
C:\OpenCV231\include
C:\OpenCV231\include\opencv - Add the following folder in Library Directories while you are in Debug configuration:
C:\OpenCV231\lib\Debug
Add the following while in Release configuration:
C:\OpenCV231\lib\Release - Go to Linker > Input. Add the following in the “Additional Dependencies” field while in debug configuration:
opencv_calib3d231d.lib
opencv_contrib231d.lib
opencv_core231d.lib
opencv_features2d231d.lib
opencv_flann231d.lib
opencv_gpu231d.lib
opencv_haartraining_engined.lib
opencv_highgui231d.lib
opencv_imgproc231d.lib
opencv_legacy231d.lib
opencv_ml231d.lib
opencv_objdetect231d.lib
opencv_ts231d.lib
opencv_video231d.lib
Add the following while in release configuration:
opencv_calib3d231.lib
opencv_contrib231.lib
opencv_core231.lib
opencv_features2d231.lib
opencv_flann231.lib
opencv_gpu231.lib
opencv_haartraining_engine.lib
opencv_highgui231.lib
opencv_imgproc231.lib
opencv_legacy231.lib
opencv_ml231.lib
opencv_objdetect231.lib
opencv_ts231.lib
opencv_video231.lib - In earlier versions, OpenCV used to be included by the following line:
#include <cv.h>
From OpenCV 2.2, it is included by either the following:
#include <opencv2/opencv.hpp>
Or, by individually including each module located in different folders inside C:\OpenCV231\lib\Debug
Compatibility Issue:
I have found the following backward compatibility issue while moving from opencv 2.1 to 2.3.1
If M be a cv::Mat then if you have a command M.inv(CV_SVD_SYM) then you have to change it to M..inv(cv::DECOMP_SVD)

আপনার সাইটা সুন্দর। মহিউদ্দিন স্যারের সুপারভিশনে OpenCV te ইমেজ প্রসেসিং এ কিছু কাজ করেছি… আমি ইমেজ প্রসেসিং এ ইন্ডেপেন্ডেন্ট রিচার্চার হিসাবে একটা পেপার লিখতে চাই। টপিকস সাজেস্ট করে সাহায্য করতে পারবেন?
azam007(at)gmail.com
একদম পেপার লেখার উপযোগী টপিক পাওয়া আসলে কঠিন। আর যদি তেমন কোনও আইডিয়া কেউ পায়ও, তাহলে ওটা নিয়ে নিজে কাজ না করে অন্যকে দেবার মত মহানুভব হওয়াটা মনে হয় আরও অনেক কঠিন। তবে আমি কিছু লিঙ্ক হয়তবা দিতে পারি যেগুলোতে ঘোরাফেরা করলে অনেক সময় মাথায় আইডিয়া খেলে যেতে পারে।
http://www.siggraph.org/
http://www-video.eecs.berkeley.edu/
http://www.cs.cmu.edu/~cil/vision.html
http://media.mit.edu/
http://johnnylee.net/projects/
Thank you very much for visiting my websight
হাহাহা… ঠিক পিনপয়েন্ট আইডিয়াটা তো চাইনি, আপনার অভিজ্ঞতা থেকে কি নিয়ে কাজ করা যায় সেটা জানতে চেয়েছিলাম। তবে দারুন কিছু সাইট দিয়েছেন। এর মধ্যে Brain-Computer Interaction টপিকস টা পছন্দ হয়ে গেল। থেক্স ভাইয়া। আর আপনার সাইট টা এমনিতে কাজের, ভিজিট করার জন্য ধন্যবাদ জানানোর দরকার আছে বলে মনে হয় না। আপনি আপনার কাজ গুলো বাংলাতে লিখেন না কেন? আমি কিছু ট্রাই করেছি ব্লগে। দেখতে পারেন
http://www.somewhereinblog.net/blog/mnazamblog/category/13526
http://www.somewhereinblog.net/blog/mnazamblog
আর আমি রশীদ হলে ২১১ তে শাহাদাত ভাইয়ের রুম মেইট ছিলাম। আপনি মাঝে মাঝে আমাদের রুমে আসতেন। পি.এলে মটর ভাইয়েরা ধুমসে তাস পিটাইতো হাবিব ভাইয়ের বেডে
অ্যানিওয়ে, আশা করি ওয়েবটা ভবিষ্যতে আরো কন্টেন্ট সমৃদ্ধ হবে। ভালো থাকবেন।
Pingback: Introduction to OpenCV | Md. Iftekhar Tanveer
Pingback: Read Display and Write video/images/camera frames | Md. Iftekhar Tanveer