Monday 26 May 2014

Installing and linking OpenCV 2.4.3 with Visual Studio 2012

After a long period I'm back into my experiments. So I was planning from where I have to resume all, so selected OpenCV. After 2 years again going to work with OpenCV. This post I'm describing the OpenCV older version with the VS 2012 in a very simple step by step procedure. Those who are using OpenCV latest version like 2.4.9 no need for these tutorial, it already have with the build for VS 12. you can simply add the build directories as you have done earlier. Most of the peoples attracts to OpenCV very quickly but the lengthy procedures for setting it up will make them lazy and quit studying it. I'm describing it in a very easy way so that anyone can build application by linking OpenCV.

At first I will tell a small introduction what is OpenCV. OpenCV(Open Computer Vision) is an open source image processing cross platform which has lots of in-built function for image processing so that anyone can easily step into image processing and travel to the very highs of image processing in a very simple way. I'm not saying that OpenCV is simple, if you have the logic, OpenCV helps you to implement it is a very efficient and optimized way. A person like me who is very interested in robotics studying OpenCV is worth. Since it is developed in C the code is more reliable and portable. I'm not explaining detailed now, you can expect a detailed tutorial about OpenCV soon. Now in this post i will describe about the installation and the linking and building your first application with OpenCV 2.4.3 and VS 2012. The latest version you can directly link with VS 12. But if you want to use OpenCV 2.4.3 with the VS12 you need to build the binaries from the source of 2.4.3 to binaries for VS 12, If you are using VS 10, no need for these steps you can directly add the directory to the project properties, this is only of VS12 to run OpenCV 2.4.3 or lower versions.
You can download OpenCV free from its official site.
Just download it and open, then extract it to C:\
Now you will have a folder OpenCV in your C:\ drive with all the content you have extracted from the OpenCv you downloaded.

 So what to do next? Now we need to make the binaries for VS 12  with a simple cross platform called CMake. Just download the CMake from its website , Install it by just forwarding with the next buttons.
After installation Open it. in the browse source select the C:\OpenCV folder in which you have extracted the files of OpenCv. Create a folder eg: 'Target' in the C:\ drive and select that folder in the browse build section.

select 'Tools->Configure' and select Visual Studio 11/12 Win 64 if you want 64-bit or if you want 32 select Visual Studio 11 /12. click Finish . Select VS 11 or VS 12 as per the version of your VS

Now it will build the source to the target as you required. wait for sometime. After the process complete successfully. Go to the folder you created and put the new build in the C:\ drive. It will look like this:-

Now you can see a file OpenCV.sln this file will be used to make the needed target file. Open this file in VS 2012

Select the mode as Debug and then right Click on the install file in the solution browser and click build, Now VS will build the things to produce the required targets. Wait for sometime until the build completes successfully. After that select Release mode and again build the Install file just as the same procedure before. Wait until it is successful.
Wow Congrats You done it !!!!!

Now you have the files in your C:\Target\install directories. Copy the Install Folder to C:\OpenCV Now include the system variables.
My Computer->select System properties->Advanced System Settings->Environment Variables-> select Path-> Edit-> in the Variable Value add " ;OpenCV\install\bin ". Now you only need to add the required files for your projects just by linking the files in C:\OpenCV\install as you required in your project. 

No comments:

Post a Comment