Windows (WIN10) compilation OpenCV + Opencv_contrib

Source: Internet
Author: User

In the previous few articles, I mentioned compiling OpenCV + Opencv_contrib in Android, Linux, this article is mainly about compiling OpenCV + opencv_contrib in Windows.

The first environment to be prepared is:
    • Window 10 64 bit: This everyone knows, not much to say AH;
    • Cmake: Compile tool, you can download the installation https://cmake.org/download/, the current version is 3.10.1;
    • Visual Studio: Development tools are also needed when compiling, and I am installing Visual Studio 2015.
    • OpenCV Windows package,: https://opencv.org/releases.html;
    • Opencv_contrib package,: Https://github.com/opencv/opencv_contrib (note the version corresponds).

Extract the downloaded OpenCV Windows package, directory OpenCV, and then unzip the downloaded Opencv_contrib package into the OpenCV directory, create a new New_build folder (to put the results after compiling):

    

To generate OpenCV.sln using CMake:

Open the CMake after installation, select the openCV source directory in the where is the source code : F:\opencv\sources; in where to build the In binaries, select the directory that is compiled as a Visual Studio project: F:\opencv\new_build (Here I choose the New_build directory that I have just specifically created), as shown in:

    

Click the Configure button, pop up the dialog box, select the compiler, according to the local computer's CPU architecture, here is particularly important to note is whether the corresponding VS version on their machine, if not installed, or to compile the error, may not find the corresponding tool reason, and choose X86 and X64) , this is vs 2015.

    

Click "Generate" after the setup is complete to start the project. After the first compilation, 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 the Modles directory in the Open_contrib source package, my directory is "F:\opencv\opencv_contrib\modules":

    

Click "Generate" again to compile the second time:

    

At this point we can already see the OpenCV.sln compiled with the CMake tool:

    

To open the OpenCV.sln project with VS, compile to generate the debug and release libraries:

Open the OpenCV.sln project with VS 2015, and in the solution you can view the project catalog:

    

Compile build 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:

    

Compilation succeeded:

    

Locate the install in the cmaketargets and then right-select project only--Generate install only:

    

After the compilation is complete, the release mode is the same. At this point, the install directory is available. This directory contains the header files and library files that we need.

    

To Configure the new library file to the project:

VC + + Directory--contains directories, add:

E:\OpenCV320\opencv\new_build\install\include

VC + + Directory---Library directory, add:

E:\OpenCV320\opencv\new_build\install\x64\vc14\lib

Linker-to-and-attach dependencies, add: (Note that the added library is consistent with the compilation options, and you need to be aware that debug has a more D than the file name of the release)

Opencv_aruco320.lib

Opencv_aruco320d.lib

Opencv_bgsegm320.lib
Opencv_bgsegm320d.lib
Opencv_bioinspired320.lib
Opencv_bioinspired320d.lib
Opencv_calib3d320.lib
Opencv_calib3d320d.lib
Opencv_ccalib320.lib
Opencv_ccalib320d.lib
Opencv_core320.lib
Opencv_core320d.lib
Opencv_datasets320.lib
Opencv_datasets320d.lib
Opencv_dnn320.lib
Opencv_dnn320d.lib
Opencv_dpm320.lib
Opencv_dpm320d.lib
Opencv_face320.lib
Opencv_face320d.lib
Opencv_features2d320.lib
Opencv_features2d320d.lib
Opencv_flann320.lib
Opencv_flann320d.lib
Opencv_fuzzy320.lib
Opencv_fuzzy320d.lib
Opencv_highgui320.lib
Opencv_highgui320d.lib
Opencv_imgcodecs320.lib
Opencv_imgcodecs320d.lib
Opencv_line_descriptor320.lib
Opencv_line_descriptor320d.lib
Opencv_ml320.lib
Opencv_ml320d.lib
Opencv_objdetect320.lib
Opencv_objdetect320d.lib
Opencv_optflow320.lib
Opencv_optflow320d.lib
Opencv_phase_unwrapping320.lib
Opencv_phase_unwrapping320d.lib
Opencv_photo320.lib
Opencv_photo320d.lib
Opencv_plot320.lib
Opencv_plot320d.lib
Opencv_reg320.lib
Opencv_reg320d.lib
Opencv_rgbd320.lib
Opencv_rgbd320d.lib
Opencv_saliency320.lib
Opencv_saliency320d.lib
Opencv_shape320.lib
Opencv_shape320d.lib
Opencv_stereo320.lib
Opencv_stereo320d.lib
Opencv_stitching320.lib
Opencv_stitching320d.lib
Opencv_structured_light320.lib
Opencv_structured_light320d.lib
Opencv_superres320.lib
Opencv_superres320d.lib
Opencv_surface_matching320.lib
Opencv_surface_matching320d.lib
Opencv_text320.lib
Opencv_text320d.lib
Opencv_tracking320.lib
Opencv_tracking320d.lib
Opencv_video320.lib
Opencv_video320d.lib
Opencv_videoio320.lib
Opencv_videoio320d.lib
Opencv_videostab320.lib
Opencv_videostab320d.lib
Opencv_xfeatures2d320.lib
Opencv_xfeatures2d320d.lib
Opencv_ximgproc320.lib
Opencv_ximgproc320d.lib
Opencv_xobjdetect320.lib
Opencv_xobjdetect320d.lib
Opencv_xphoto320.lib
Opencv_xphoto320d.lib
Kernel32.lib
User32.lib
Gdi32.lib
Winspool.lib
Comdlg32.lib
Advapi32.lib
Shell32.lib
Ole32.lib
Oleaut32.lib
Uuid.lib
Odbc32.lib
Odbccp32.lib

In this way, we can use OPENCV in vs.

One point that needs to be mentioned, the need to use algorithms such as SIFT, requires the introduction of the Xfeatures2d namespace:

using namespace xfeatures2d;

Windows (WIN10) compilation OpenCV + Opencv_contrib

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.