In the classmate's help, finally successfully configured the VS+OPENCV, the detailed process recorded in this, convenient for later review
Reference 1
Installing vs2012
Download vs2012, official
- Double-click the installation file to set the installation path
2. Select the desired installation package
3. Installation in progress
4. Finally the installation is complete
5. Click Start
Prompt to enter product secret key
Ykcw6-bpfpf-bt8c9-7dcth-qxgwc
Activation successful
6. Other configuration pages appear
Choose c + + as the default development environment here
7. Start
8. Note that compatibility issues may sometimes occur and need to download the update package
Click Install to
Installing OPENCV
1. Download OpenCV Source code
OPENCV official website address: http://opencv.org/, the internet is a little slow
Click Download, select the OpenCV version you want to download in the new page that pops up, select 2.4.9
Then, start the download
About 349MB
2. Extracting source code
Unzip the path any
Extract password
3. Configure environment Variables for OPENCV
(1) Computer right button "Properties"
(2) Advanced system settings
(3) Click Environment variables
(4) Add the OpenCV Bin folder path to the environment variable named path, specifically:
① 32-bit system, added: D:\File program\opencv\build\x86\vc11\bin
② 64-bit system, add:
D:\File Program\opencv\build\x86\vc11\bin (corresponds to 32-bit system)
D:\File Program\opencv\build\x64\vc11\bin (corresponds to 64-bit system)
The purpose is to switch back and forth in the compiler Win32 and X64
Note 1:d:\file PROGRAM\OPENCV is the decompression path for OPENCV
Note 2:VC11 indicates that the compilation environment is Microsoft Visual Studio 2012;
Configuring OpenCV in vs2012
1. Open vs2012
2. Create a new Win32 Console application
3. New item in Solution Explorer: Add as source file
4. Configuring at the property manager
(Once configured in the property manager, it is equivalent to a common configuration process, and the new project will not have to be reconfigured again)
(1) View, property Manager
(2) Pop up the property manager
(3) Configure debug Win32
Note: It is discussed here that the configuration of debug,release is quite similar
In Debug | Microsoft.Cpp.Win32.user Right-click "Properties" at Win32
Popup Microsoft.Cpp.Win32.user Property Page
(4) Start Configuration Microsoft.Cpp.Win32.user Property page
① add the Include directory, so that C + + programs caninclude opencv
Specifically: In the pop-up property page, find the "VC + + directory" in the corresponding right containing directory, enter the OpenCV build->include directory
As you can see, there are two folders under the Opencv->build->include directory, which should be added to the Include directory for both the large directory and the two folder directories.
The following three directories will be added to the Include directory
D:\File Program\opencv\build\include
D:\File PROGRAM\OPENCV\BUILD\INCLUDE\OPENCV
D:\File Program\opencv\build\include\opencv2
② Adding a library directory
Still on the right side of the VC + + directory, add the Opencv->build->x86->vc11->lib path to the library directory
namely: D:\File Program\opencv\build\x86\vc11\lib
Note: Here are the x64 or x86 depending on the compiler (not the operating system!). )
As shown, the compiler is WIN32, then you should select the library under the x86 directory
Other than that:
VC10 = Visual Studio 2010
VC11 = Visual Studio 2012
VC12 = Visual Studio 2013
③ Adding a link library (that is, a DLL)
Find additional dependencies on the right side of the linker, input, on the Microsoft.Cpp.Win32.user property page
Add the following DLL name (dynamic-link library in 2.4.9 version-debug corresponding OPENCV)
Opencv_ml249d.lib
Opencv_calib3d249d.lib
Opencv_contrib249d.lib
Opencv_core249d.lib
Opencv_features2d249d.lib
Opencv_flann249d.lib
Opencv_gpu249d.lib
Opencv_highgui249d.lib
Opencv_imgproc249d.lib
Opencv_legacy249d.lib
Opencv_objdetect249d.lib
Opencv_ts249d.lib
Opencv_video249d.lib
Opencv_nonfree249d.lib
Opencv_ocl249d.lib
Opencv_photo249d.lib
Opencv_stitching249d.lib
Opencv_superres249d.lib
Opencv_videostab249d.lib
Note: If the release is configured | Win32, then, you need to add the following 19 release versions without D
Opencv_objdetect249.lib
Opencv_ts249.lib
Opencv_video249.lib
Opencv_nonfree249.lib
Opencv_ocl249.lib
Opencv_photo249.lib
Opencv_stitching249.lib
Opencv_superres249.lib
Opencv_videostab249.lib
Opencv_calib3d249.lib
Opencv_contrib249.lib
Opencv_core249.lib
Opencv_features2d249.lib
Opencv_flann249.lib
Opencv_gpu249.lib
Opencv_highgui249.lib
Opencv_imgproc249.lib
Opencv_legacy249.lib
Opencv_ml249.lib
In addition, for opencv2.4.8
Debug version
Opencv_ml248d.lib
Opencv_calib3d248d.lib
Opencv_contrib248d.lib
Opencv_core248d.lib
Opencv_features2d248d.lib
Opencv_flann248d.lib
Opencv_gpu248d.lib
Opencv_highgui248d.lib
Opencv_imgproc248d.lib
Opencv_legacy248d.lib
Opencv_objdetect248d.lib
Opencv_ts248d.lib
Opencv_video248d.lib
Opencv_nonfree248d.lib
Opencv_ocl248d.lib
Opencv_photo248d.lib
Opencv_stitching248d.lib
Opencv_superres248d.lib
Opencv_videostab248d.lib
Release version
Opencv_objdetect248.lib
Opencv_ts248.lib
Opencv_video248.lib
Opencv_nonfree248.lib
Opencv_ocl248.lib
Opencv_photo248.lib
Opencv_stitching248.lib
Opencv_superres248.lib
Opencv_videostab248.lib
Opencv_calib3d248.lib
Opencv_contrib248.lib
Opencv_core248.lib
Opencv_features2d248.lib
Opencv_flann248.lib
Opencv_gpu248.lib
Opencv_highgui248.lib
Opencv_imgproc248.lib
Opencv_legacy248.lib
Opencv_ml248.lib
Test whether the OPENCV is configured successfully
New Blank Win32 Console Application
Add a CPP to the project and enter the following code in the CPP
Note: Be sure to secure the project path under the PIC image!
or the absolute path of the image is given directly (this avoids path errors)
#include<iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
Using namespace cv;
Int main()
{
// read in a picture (game original)
Mat img=imread("pic.jpg");
// Create a window called "Game Original"
cvNamedWindow("game original painting");
// Display the original game in the window
Imshow("game original painting", img);
// Wait for 6000 ms and the window closes automatically
waitKey(6000);
}
(1) Compiling
Success, no compilation errors
(2) Run the program, display the image successfully
Note 1: If there are no images to manipulate under the path, the following error will occur
Install Visual Studio 2012, and configure OpenCV