First, the preparatory work:
1. Download OPENCV installation package: HTTPS://GITHUB.COM/OPENCV/OPENCV
The installation process is actually the decompression process, after the installation is completed (this changes the file name):
2. Download Opencv_contrib Source: Https://github.com/opencv/opencv_contrib
After downloading the direct decompression, get the source directory:
3. Download Cmake-gui tool: http://www.cmake.org/cmake/resources/software.html
Choose not to install the version, according to their own model select X86 or X64, after the download is complete, directly decompression can be used, do not have to install.
Due to the reasons for the slow download, can not step by step, the following will use the following links to the first one. Add your own point of view on the basis of related links, and the problems encountered, as well as the handling
Second, use CMake to generate OpenCV.sln:
1. Open the Cmake-gui.exe tool in the Cmake-gui\bin directory:
2. Fill in the corresponding parameters, including: OpenCV source directory and OpenCV.sln project export directory, first Configure Export OpenCV.sln project:
For the first time, you need to set up the version of VS that will be used to compile this OpenCV.sln project (in particular, it is important to note that there is a corresponding VS version on your machine, if it is not installed, it will be wrong to compile, it may not be possible to find the corresponding tool, and to choose X86 and X64), here is the VS Win64.
Some dependent packages are downloaded during the process, and if they fail, the manual download is placed in the corresponding location
Click "Generate" to start building the project after the setup is complete:
3. After the first compilation is complete, we need to add additional opencv_contrib to the project for a second compilation, find "Opencv_extra_modules_path" in the configuration table, set its parameter value to Open_ Contrib source package in the Modles directory, my directory is "E:\OpenCV\tools\opencv_contrib-master\modules":
After the setup is finished, click Configure to configure it, and then compile the second time without error Generate:
The second compilation is usually done in a very short time:
After compiling, we look at the file output directory set above in the Explorer, and found a lot of files in the directory, in fact, OpenCV.sln project file:
Third, open the OpenCV.sln project with VS, compile and generate debug and release libraries:
1. Open the OpenCV.sln project with VS 2013 to view the project catalog in the solution:
2. Compile and build the debug version of the library, remember to choose to compile the platform information before, this is the compilation to build debug version and release version of the difference, you can also choose release, because your project may need to use the corresponding dynamic link library:
In the solution Select Project, right-click to rebuild the solution:
3. Locate the install in the cmaketargets and then right-select "Project only" and "Generate Install only":
Then, in the install directory under the project directory, you can see that a bunch of files have been generated, and this heap of files is similar to the top:
Finally: Configure the system environment variable path
D:\opencv3\opencv_contrib\Install\x64\vc12\bin
Iv. Configure the new library file to the project:
VC + + Directory--contains directories, add:
D:\opencv3\opencv_contrib\Install\included:\opencv3\opencv_contrib\install\ Include\opencvd:\opencv3\opencv_contrib\Install\include\opencv2
VC + + Directory---Library directory, add:
D:\opencv3\opencv_contrib\Install\x64\vc12\lib
Linker-to-and-attach dependencies, add: (the release version added below, note that the added library is consistent with the compilation options, you need to be aware that debug is more than the file name of release D)
Debug |
Release |
Opencv_aruco310d.lib Opencv_bgsegm310d.lib Opencv_bioinspired310d.lib Opencv_calib3d310d.lib Opencv_ccalib310d.lib Opencv_core310d.lib Opencv_datasets310d.lib Opencv_dnn310d.lib Opencv_dpm310d.lib Opencv_face310d.lib Opencv_features2d310d.lib Opencv_flann310d.lib Opencv_fuzzy310d.lib Opencv_hdf310d.lib Opencv_highgui310d.lib Opencv_imgcodecs310d.lib Opencv_imgproc310d.lib Opencv_line_descriptor310d.lib Opencv_ml310d.lib Opencv_objdetect310d.lib Opencv_optflow310d.lib Opencv_phase_unwrapping310d.lib Opencv_photo310d.lib Opencv_plot310d.lib Opencv_reg310d.lib Opencv_rgbd310d.lib Opencv_saliency310d.lib Opencv_shape310d.lib Opencv_stereo310d.lib Opencv_stitching310d.lib Opencv_structured_light310d.lib Opencv_superres310d.lib Opencv_surface_matching310d.lib Opencv_text310d.lib Opencv_tracking310d.lib Opencv_video310d.lib Opencv_videoio310d.lib Opencv_videostab310d.lib Opencv_xfeatures2d310d.lib Opencv_ximgproc310d.lib Opencv_xobjdetect310d.lib Opencv_xphoto310d.lib |
Opencv_aruco310.lib Opencv_bgsegm310.lib Opencv_bioinspired310.lib Opencv_calib3d310.lib Opencv_ccalib310.lib Opencv_core310.lib Opencv_datasets310.lib Opencv_dnn310.lib Opencv_dpm310.lib Opencv_face310.lib Opencv_features2d310.lib Opencv_flann310.lib Opencv_fuzzy310.lib Opencv_hdf310.lib Opencv_highgui310.lib Opencv_imgcodecs310.lib Opencv_imgproc310.lib Opencv_line_descriptor310.lib Opencv_ml310.lib Opencv_objdetect310.lib Opencv_optflow310.lib Opencv_phase_unwrapping310.lib Opencv_photo310.lib Opencv_plot310.lib Opencv_reg310.lib Opencv_rgbd310.lib Opencv_saliency310.lib Opencv_shape310.lib Opencv_stereo310.lib Opencv_stitching310.lib Opencv_structured_light310.lib Opencv_superres310.lib Opencv_surface_matching310.lib Opencv_text310.lib Opencv_tracking310.lib Opencv_video310.lib Opencv_videoio310.lib Opencv_videostab310.lib Opencv_xfeatures2d310.lib Opencv_ximgproc310.lib Opencv_xobjdetect310.lib Opencv_xphoto310.lib |
4, about the problem of Imread. If the picture name is present in the TXT document, and you extract it to the list by using the Readimagelists method, pay special attention to the newline character of the TXT document that must be "UNIX final bundle character-lf". Otherwise, the read file name will be more than "\ r" characters, resulting in the reading of image files failed.
RELATED Links: http://blog.csdn.net/linshuhe1/article/details/51221015
RELATED Links: http://www.cnblogs.com/asmer-stone/p/5530868.html
RELATED Links: http://www.yidongtime.com/Html/dev/web/20160305/55517.html
V. Some issues
1. In all test codes, the default search path is
D:\opencv3\opencv_contrib\Install\testdata
2. The program appears debug compile pass, but the operation stops
The run-to-multithreaded debug DLL (/MDD), C + +, code generation,
3. Debug runtime Cannot find "XXX.exe" debug information, or the information does not match
Debug-Build Debug information set to Yes (debug)
4. The VS Watch variable window displays "undefined identifier"
Optimize-to-C + +-optimization set to Disabled (/od)
(i) compiling extensions OpenCV 3.1.0 + opencv_contrib and some issues under Windows