Vs2015+opencv3.1+contrib Library installation configuration under Windows environment

Source: Internet
Author: User

In recent days in the installation of OpenCV, also looked at some online posts, combined with some of the problems they encountered wrote a little content.

Get ready:

1. OpenCV The latest version is 3.10, you can download http://opencv.org/on the website. The website will be downloaded and extracted with two folders: build and sources. What we need to use is sources, recompile the contents of the sources with CMake, and add the contrib library. Build content is the official website has been compiled, and there are other blogs about the use of build installation, and here we do not use. OpenCV can also download HTTPS://GITHUB.COM/OPENCV/OPENCV from GitHub, which is the source code, equivalent to the Sources folder described above.

2. CMake is used to compile the source code, the official website download https://cmake.org/. I used to be. Use CMake in addition to OPENCV compiled source, there is another reason is: opencv3.1 version can only debug x64, can not debug x86. In other words, in order to debug in 32-bit environment, we need to recompile the source code with CMake.

3. Contrib Library. The opencv3.1 on the official website contains a stable core library, and some of the unstable ones are placed in the contrib. GitHub download Https://github.com/opencv/opencv_contrib. After extracting, we use the Modules folder.

4. when you see the unpacking package in the file, do not open it easily.

Begin:

1. folder path, this with your own settings on the line. I will prepare the contents of the content in the D:\BUILD (the following are replaced with #\), create a new MYOPENCV folder, to install the CMake compiled content, you will get the form:

2. in CMake compiling OPENCV source code, need to download several files, but generally difficult to download and lead to compilation failure, so directly copied to the folder. Link: http://pan.baidu.com/s/1c18V9Ck Password: bt7z. Copy the files from the three folders in the downloads to the #\opencv\sources\3rdparty\ffmpeg and get the form as follows:

Copy the Ippicv_win folder to #\opencv\sources\3rdparty\ippicv, modify the Downloader.cmake, open it as Notepad, and delete the "_icv_downloader ()" at the end.

3. Open the Cmake-gui.exe under #\cmake\bin. In the where is the source code input #\opencv\sources, in the where to build the binaries input #\myopencv. Will get the form as follows:

Then click Configure, and the compiler selection dialog box will appear

Select Visual Studio 14 2015, after which the opencv3.1 can be debugged in the x86 (Win32) environment. Visual Studio Win64 corresponds to x64. Then there is the wait for the configuring done, such as.

Then search finds Opencv_extra_modules_path and enters #\opencv_contrib_master\modules. Click Configure again, and then after the configuring done, click Generate, and then the generating do appear. So far, the work of compiling is complete.

4. under #\myopencv, locate the OpenCV.sln file and open it. After initialization, right-click the solution ' OpenCV 'and select Rebuild solution. This is generated in the debug, Win32 environment. This process takes a long time. Then locate the install file under the Cmaketargets folder, such as:

Right-click only for projects, generate install only. Then there will be an install folder under the #\myopencv.

5. Configure the environment variables.

environment variable settings. Variable name: OPENCV; value: #\myopencv\install.

User variable settings. Path under Add: #\myopencv\install\x86\vc14\bin.

6. Open the vs2015 and create a new project. Locate the MICROSOFT.CPP.WIN32.UESR in the property manager, such as:

The right-click property will pop up the dialog box. Locate the Common Properties->vc++ directory, such as:

Add in the Include directory:

#\myopencv\install\include

#\myopencv\install\include\opencv

#\myopencv\install\include\opencv2

In the library directory, add:

#\myopencv\install\x86\vc14\lib

Find additional dependencies, input, linker, such as:

Add content to additional dependencies (that is, the Lib file in the #\myopencv\install\x86\vc14\lib folder, as opposed to adding the line):

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_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_ts310d.lib
Opencv_video310d.lib
Opencv_videoio310d.lib
Opencv_videostab310d.lib
Opencv_xfeatures2d310d.lib
Opencv_ximgproc310d.lib
Opencv_xobjdetect310d.lib
Opencv_xphoto310d.lib

So far, all the work has been done.

Test:

Restart your computer to verify that it is OK. Here are two of the code:

1. The first one is to display an image. Put the image in the project you built

#include <iostream>#include<opencv2/core/core.hpp>#include<opencv2/highgui/highgui.hpp>using namespaceCV;intMain () {//read a picture (original picture of the game)Mat img = Imread ("light. jpg"); //Create a window named "Game Original picture"Namedwindow ("Game original Painting"); //display the game's original picture in the windowImshow ("Game original Painting", IMG); //wait for 6000 ms after the window automatically shuts downWaitkey (6000);}

The results shown are:

2. Sift algorithm

#include <iostream>#include<opencv2/opencv.hpp>#include<opencv2/xfeatures2d.hpp>using namespaceCV; using namespacestd;intMain () {//Create SIFT class pointerPtr<feature2d> f2d =xfeatures2d::sift::create (); //read in pictureMat img_1 = Imread ("4.jpg"); Mat img_2= Imread ("5.jpg"); //Detect the keypointsVector<keypoint>Keypoints_1, keypoints_2; F2d-Detect (Img_1, keypoints_1); F2d-Detect (Img_2, keypoints_2); //Calculate descriptors (feature vectors)Mat descriptors_1, descriptors_2; F2d-Compute (img_1, keypoints_1, descriptors_1); F2d-Compute (img_2, keypoints_2, descriptors_2); //Matching descriptor vector using BfmatcherBfmatcher Matcher; Vector<DMatch>matches;    Matcher.match (Descriptors_1, descriptors_2, matches); //draw the key points that match outMat img_matches;    Drawmatches (img_1, Keypoints_1, Img_2, keypoints_2, matches, img_matches); Imshow (""Match Chart"", img_matches); //wait for any button to pressWaitkey (600000);}

The results shown are:

Vs2015+opencv3.1+contrib Library installation configuration under Windows environment

Related Article

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.