Monday, 6 July 2015

How to install OpenCV 3.0.0 in Windows and create a sample program in Visual Studio 2012



Hello!

OpenCV libraries are a great way to get started in Computer Vision and Image processing applications. Plus its FREE!

 It has C++, C , Python and Java interfaces and supports Windows, Mac OS, Linux , iOS and Android. You can check it out here : http://opencv.org/

Installing it can be a little confusing to some people. This is a complete guide which includes a step by step process on how to install it and run a simple code in Visual Studio 2012. 


You can watch the Video on YouTube and Follow the steps below:








Step 1: Downloading and installing


· Download OpenCV 3.0 at: http://opencv.org/downloads.html

· Download Visual studio 2012 at: http://www.microsoft.com/en-in/download/details.aspx?id=34673

· Install Visual studio 2012 and Log in with your Microsoft account if you already have one or you can sign up and register. The software is available for FREE

· Click on Opencv 3.0 and Extract the files to a location






Step 2: Create a system variable:


· Variable name: OPENCV_BUILD

· Value: C:\opencv3\build

· Path: C:\opencv3\build\x86\vc12\bin






Step 3: Configuration


1. Open Visual Studio and create a Console Application

2. Right click on the file and click properties

3. Choose Configuration Manager and add x64 platform if your system is x64 (only if your system is x64)

4. At configuration field, choose all configurations

5. At Configuration Properties - C/C++ - Additional Include Directories, add opencv include folders


Additional Include Directories:


· C:\opencv3\build\include


· C:\opencv3\build\include\opencv


· C:\opencv3\build\include\opencv2


Note: opencv3 is the folder in which I extracted the files (Check your folder name and folder location)









6. At Configuration Properties - Linker- Additional Library Directories, add opencv library folder


Additional Library Directories:

C:\opencv3\build\x86\vc12\lib



7. At configuration field, choose Debug mode


8. At Configuration Properties - Linker- Additional dependencies- add dependence libraries


Additional libraries


opencv_ts300.lib


opencv_ts300d.lib


opencv_world300.lib


opencv_world300d.lib


Note: These libraries are in the folder- C:\opencv3\build\x86\vc12\lib



9. At configuration field, choose Release mode


10. At Configuration Properties -Linker - Additional dependencies - add dependence libraries


Additional libraries


opencv_ts300.lib


opencv_ts300d.lib


opencv_world300.lib


opencv_world300d.lib


Note: These libraries are in the folder- C:\opencv3\build\x86\vc12\lib




Step 4: Build and Debug


· I have given a sample code.


· Copy -paste it and build it. And debug.




Note: In case there is an error like the '.Dll' file is missing,  Go to Environmental variables and check the path again and restart your computer.

It should work. 


If you want to use extra features available in the contrib_module , then you'll need to build the extra modules from source using cmake. I'll be writing another post showing how to do that.  
If  this was helpful please subscribe and If you have any questions feel free to comment or you can mail me