Today i'll show you the how can you manually configure OpenCV 2.4.11 with Visual Studio 2013.
Open the visual studio File > New > New Project > Installed > Template > Visual C++ > CLR then click on CLR Console Application and named the project as TestOpenCV then hit OK.
Go to Link and download opencv 2.4.11, you can choose any latest version of opencv, process will be same as following.
Create a new folder in Drive C named as cv2411 and extract in it. Your directory should be like following image.
First of all you need to set System Environment Variable in windows. Open Control panel > System and Security > System > Advance system settings > Advanced click on Environment Variables button. Select Path from System variables then click Edit and paste bin path as following then click OK OK and OK :).
Go back to Visual Studio, right click on project and select properties. I'm building opencv for x86 platform in visual studio but you can also use x64. For this you just need to change path as x64. In properties panel go to Configuration Properties > VC++ Directories > Include Directories then click drop down edit button and add following path.
In Libraries Directories add following path
Go to C/C++ > Additional Include Directories and paste following directory
Go to Linker > Additional Library Directories and paste following directory
Then click on Apply button then OK. Your opencv has been configured. Now let's run some lines of code to test OpenCV, just copy following code and paste in TestOpenCV.cpp file.
Open the visual studio File > New > New Project > Installed > Template > Visual C++ > CLR then click on CLR Console Application and named the project as TestOpenCV then hit OK.
Go to Link and download opencv 2.4.11, you can choose any latest version of opencv, process will be same as following.
Create a new folder in Drive C named as cv2411 and extract in it. Your directory should be like following image.
First of all you need to set System Environment Variable in windows. Open Control panel > System and Security > System > Advance system settings > Advanced click on Environment Variables button. Select Path from System variables then click Edit and paste bin path as following then click OK OK and OK :).
- C:\cv2411\opencv\build\x86\vc12\bin
Go back to Visual Studio, right click on project and select properties. I'm building opencv for x86 platform in visual studio but you can also use x64. For this you just need to change path as x64. In properties panel go to Configuration Properties > VC++ Directories > Include Directories then click drop down edit button and add following path.
- C:\cv2411\opencv\build\include
In Libraries Directories add following path
- C:\cv2411\opencv\build\x86\vc12\lib
Go to C/C++ > Additional Include Directories and paste following directory
- C:\cv2411\opencv\build\include
Go to Linker > Additional Library Directories and paste following directory
- C:\cv2411\opencv\build\x86\vc12\lib
- opencv_calib3d2411d.lib
- opencv_contrib2411d.lib
- opencv_core2411d.lib
- opencv_features2d2411d.lib
- opencv_flann2411d.lib
- opencv_gpu2411d.lib
- opencv_highgui2411d.lib
- opencv_imgproc2411d.lib
- opencv_legacy2411d.lib
- opencv_ml2411d.lib
- opencv_nonfree2411d.lib
- opencv_objdetect2411d.lib
- opencv_photo2411d.lib
- opencv_stitching2411d.lib
- opencv_superres2411d.lib
- opencv_ts2411d.lib
- opencv_video2411d.lib
- opencv_videostab2411d.lib
Then click on Apply button then OK. Your opencv has been configured. Now let's run some lines of code to test OpenCV, just copy following code and paste in TestOpenCV.cpp file.
- #include "stdafx.h"
#include <iostream>
#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <opencv2/core/core.hpp>
#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image;
image = cv::imread("C:\\test.png");
namedWindow("Display window", 1);
imshow("Display window", image);
waitKey(0);
return 0;
}
Build the project and run.
If you are facing dll missing errors then simply go to following path and copy all dll files and paste them with project .exe file. You can find project exe file in Project directory. it will be in Debug or Release folder.
If you are facing dll missing errors then simply go to following path and copy all dll files and paste them with project .exe file. You can find project exe file in Project directory. it will be in Debug or Release folder.
- C:\cv2411\opencv\build\x86\vc12\bin