Installing & Configuring with Visual Studio

In this tutorial, I am using OpenCV 2.4.5 and Visual Studio 2012. But it is almost same for other versions of OpenCV and Visual Studio.

If you want, you can refer to the older post Installing & Configuring OpenCV2.1 with Visual Studio  2010.

There are 2 ways to install OpenCV into your computer. But for a beginner, the most suitable way is the installation by using the pre-built libraries. So, I am going to discuss how to install OpenCV by using pre-built libraries.

First of all you should have a suitable IDE. I installed Visual Studio Express 2012 which is a free edition. (You will need to register by giving your email address to obtain the free product key).

Then you have to download OpenCV from here. You can choose whatever version, you want. I choose OpenCV 2.4.5.

Then double click the downloaded 'OpenCV-2.4.5.exe' file and it will be extracted to whatever location, you give. I gave C:\ as the extracting location.

Then you will need to set up environment variables correctly to be able to use OpenCV.

Steps to Set up Environmental Variable

  • Right click on 'My Computer' and click 'Properties' in the drop down menu. You will see a window like this.
Find Bitness of a Computer
Find Bitness of a Computer

Here the System type is 32 bit operating system. So the system architecture is x86.
If the system type is 64 bit operating system, the system architecture is x64.

Both Visual Studio 2012 and OpenCV2.4.5  supports vc11. So, in this tutorial, I am going to use vc11 as the compiler type. You can find supporting compiler types of OpenCV, if you go to C:\opencv\build\x86 or C:\opencv\build\x64 according to your system architecture.

Remember your system architecture and expected compiler type because you will need this in the middle part of this post.

  • Now you are ready to set the environment variables. This can be done in the command line or by using GUI. I am going to explain the GUI method.
    • Right click on 'My Computer' and click 'Properties' in the drop down menu. You will see a window like this. 

Advance System Settings

    • Click 'Advance System Settings' in the above window

    • Then click 'Environment Variables'
Environment Variables

    • Then click 'New' button at the bottom of the window
New Environment Variable

    • Type OPENCV_DIR against Variable name:. And type the location C:\opencv\build\ against the Variable value:. 
Creating New Environment Variables

    • Then press OK
Now you have added a new environment variable to the system.

Now you are going to edit a system variable.
    • click 'Path' or 'PATH' inside the list of System variables and then click 'Edit' button at the bottom of the window 
Edit Environment Variable

    • Then add a ; to the end of the line and add the following %OPENCV_DIR%\x86\vc11\bin  after the semicolon. x86 is your system architecture and vc11 is the compiler type. How to find your system architecture and compiler type is explained at the beginning of the post. (Don't delete anything. Just append it at the end of the line.)
Edit Environment Variables

Hooray!! You have completed the installation of OpenCV. Next thing you have to do is configuring Visual Studio.

Configure Visual Studio Express
  • Start Microsoft Visual Studio
  • Go to File>New Project...
  • Do everything as shown in the below image and click OK and then click Finish.
Creating new Visual Studio Project

  • Press 'Ctrl' key and then 'W' while holding the 'Ctrl' key in your keyboard. Release both keys. Then press 'S' in your keyboard. Then you will see the 'Solution Explorer' pane in your right or left side of the Visual Studio window. In my case, it is in the right side.

Solution Explorer

  • Then right click on the project name (you have entered this name in a previous step) and then click 'Properties'
Solution Properties

  • Choose 'All Configurations' as indicated in the 1st box. Click the 3 places as pointed by next 3 boxes in the given order. Then copy and paste $(OPENCV_DIR)\include against the 'Additional Include Directories'
Adding Include Directories

  • Click the first 2 places as pointed by first 2 boxes in the given order.Then copy and paste $(OPENCV_DIR)\x86\vc11\lib against the 'Additional Library Directories' 
Additional Library Directories

  • Click as illustrated below
Additional Dependencies

  • After you click the <Edit...> (4th arrow in the above image), dialog box will appear and you have to copy and paste following library file names. If you are using a different version of OpenCV other than 2.4.5, please check the 'C:\opencv\build\x86\vc11\lib' location for respective file names.

These are some of the file names, you can find in the 'C:\opencv\build\x86\vc11' location.

Adding Additional Dependencies

Now click OK

Congratulations!! You have done with all of the configurations of your IDE. Now you are ready to write your first OpenCV application.

Next Tutorial : Basics of OpenCV API

Previous Tutorial : What is OpenCV?


  1. Thank you for sharing such an informative news with us. Keep on sharing Contents like this. You can also share this content on various sites like the Automation Associates LLC site.

  2. Beautiful post I've come across today. Informative. Thanks for sharing this most excellent information. You can share this information on other platforms such as, Wordpress the most useful Blogspot site followed by the famous Tumblr and also in Medium lastly in the Livejournal site

  3. Excellent and amazing post. This blog is very helpful. You can also share these post in different social medias to get a higher ground like Facebook, the famous media Twitter and in the LinkedIn profiles joined by Google Plus and the Infographic sharing Site Pinterest.

  4. Great post, and I am glad that you shared this useful info with us. Worth the time. You can also share this Information on many other sites for example like Free Samples 411, a clean business site like Os Business Opportunities swiftly followed by Jfissures and Asaimjapan and also the Johny Adams site.

  5. The satta matka Original Website Provide Fast Matka Result site.

  6. I tried copy paste the file names but it nothing is shown in the inherit section. Any idea why?

  7. I have analyzed your post. Excellent details you did here. I enjoyed reading your blog, and it is both instructional and enjoyable. You can Share this most interesting post in other sites like Free Samples 411

  8. I have analyzed your post. The post is both instructional and enjoyable. You can Share this most interesting post in other sites like, the innovative Asaim Japan site and also to the Jfissures site followed by Automation Associaltes LLC to the sites like OS Business Opportunities sites and lastly to the sites like Johny Adams sites.

  9. Thanks for sharing this data. Return again for all the more fascinating stuff like this post. You can share this enlightening post in Social Media sites like the overall celebrated Facebook, the unsurpassed most loved Twitter and a fascinating Google Plus website, business web page LinkedIn and furthermore to the Infographic website Google Plus to produce more traffic to your blog entry.

  10. The post is exceptionally useful. It is a joy understanding it. I have also bookmarked you for checking out new posts. You can likewise share this significant substance on different platforms, for example, Blogspot, the popular Wordpress website, the inventive Tumblr web page and furthermore the sites like Medium and the well known Live Journal website.

  11. Thanks a lot for this post ,
    is there anyway I can configure visual studio for all my projects ?

  12. You can also share this content on various sites like the Automation Associates LLC site.

    แตกใน xxx

  13. HostOne is providing both cheap and reliable domain registration and web hosting services to our many satisfied customers in Karachi, Lahore, Islamabad and other cities of Pakistan.  Web hosting in Pakistan.

  14. Your blog has given me that thing which I never expect to get from all over the websites. Nice post guys!

    Social Media Services