The official website of the OpenCV Library is http://opencv.org/. In the site can download the latest OpenCV for Windows, such as the current I download is Opencv-2.4.9.exe, double-click the file extracted to a directory, the extracted root directory for the OPENCV,OPENCV directory has 2 subdirectories, The build and Sources,build directories are stored in a compiled library, and the sources directory contains the source code. Below we will compile the source code in the sources directory.
You can see a CMakeLists.txt file in the sources directory, which is used to generate vs works with CMake.
Click Configure and generate respectively, the VS2008 is installed on my machine, so select VS2008.
Configuration files such as the VS solution can then be seen in the Cmake-bin directory.
Double-click OpenCV.sln to open VS, the project is shown as follows:
Press F7 to compile , then you can go to the toilet, drink tea or something, (^_^) ∠※
Came back and found that there was a project compile error:
1>------Started Build: project: Opencv_python, config: Debug Win32------1> is linking ... 1>link:fatal error LNK1104: Can't open File "Python27_d.lib"
Online Search for the relevant answers are: http://blog.csdn.net/loonger_leon/article/details/5862150
I can't use Python for the time being, so I don't care about it for the moment.
Finally, you can install the OpenCV library into the Cmake-bin/install directory by right- creating the Install project. After you write the OPENCV application, you can reference the library file and the header file in the Cmake-bin/install directory.
To facilitate the application's reference, we also need to set environment variables here. Execute at the command line:
Setx-m Opencv_dir F:\OPENCV_CODE\sources\cmake-bin\install
The environment variable for the OPENCV library path is set, which can be queried using the SET command
Opencv_dir=f:\opencv_code\sources\cmake-bin\install
To facilitate dynamic loading, we need to place the loaded dynamic link library in the PATH environment variable.
Otherwise it will need to be placed in the same directory as the executable, an application is OK, if more than one time each will have to copy the dynamic library to the same directory as the executable file.