1. Install opencv and.
I installed opencv2.4.10 and vs2012 on my computer.
2. Configure Environment Variables
The following uses the Win8 64-bit system as an example:
Computer-properties-advanced system settings-Environment Variables
Then in System Variables
Edit path: Add D: \ Program Files \ opencv \ build \ x86 \ vc11 \ bin (pay attention to your installation path and install it on D: \ Program Files \ opencv, according to the actual situation)
Note that vs2012 is vc11, and vs2010 is VC10.
3. Configure the vs Environment
First open a Win32 Project
Then add the include directory
Add a new project Attribute Table in debug on the right.
Then open the properties of the newly created Project Attribute Table.
Then add the include directory of opencv to the include directory.
For example, D: \ Program Files \ opencv \ build \ include
Add your own lib directory to the library directory
Example: D: \ Program Files \ opencv \ build \ x64 \ vc11 \ Lib
Then add the following to the additional dependency:
Opencv_core246d.lib
Opencv_imgproc246d.lib
Opencv_highgui246d.lib
Opencv_ml246d.lib
Opencv_video246d.lib
Opencv_features2d246d.lib
Opencv_calib3d246d.lib
Opencv_objdetect246d.lib
Opencv_contrib246d.lib
Opencv_legacy246d.lib
Opencv_flann246d.lib
Note: Version 246 represents opencv 2.4.6, which can be adjusted based on your own version.
And the success is achieved.
Iv. debugging
Enter code
1 #include <opencv2/opencv.hpp> 2 #include <iostream> 3 using namespace cv; 4 void main() { 5 IplImage *src; 6 src = cvLoadImage("desert.jpg"); 7 cvNamedWindow("bvin",CV_WINDOW_AUTOSIZE); 8 cvShowImage("bvin",src); 9 cvWaitKey(0); 10 cvDestroyWindow("bvin");11 cvReleaseImage(&src);12 13 }
After the input, the name in the directory is displayed
desert.jpg
Image
If the DLL is missing, follow these steps:
In vs2012
1. Click debug 2, then select and set 3. Enable source server support on the right side. 4. Click symbol 5 on the left side, check the Microsoft symbol server, and wait for a while!! 7. Problem Solving the end
Opencv + vs2012 environment setup tutorial