Visual Studio 2015 compilation installs OPENCV 3.0 and Opencv_contrib

Source: Internet
Author: User

OpenCV 3.0 has been announced in June, the new version of the API has held a liquidation, through the introduction of T-API, IPP, Neon achieved great function promotion, and change to modular layout. However, since VS2015 was released later, the OpenCV 3.0 installation package provides support for VC11 and VC12 without VC14. If you use a file under VC12, you can compile it, but the runtime will error "application does not start properly 0xc000007b". As a VS2015, you can only compile OpenCV 3.0 to use it on your own. But this also has a benefit is convenient to view OpenCV source code.

Compile Step

The following steps are compiled:
1. Download and install separately: CMake3.5.1, OpenCV3.0, VS2015
A) cmake3.5.1:https://cmake.org/download/
b) Opencvcontrib:https://github.com/itseez/opencv_contrib
c) opencv:http://opencv.org/downloads.html
2. VS2015 solution for generating OpenCV with CMake
(1) Click Cmake-gui.exe, run CMake;
(2) Click the "Browse Source ..." button to select the source code path$(opencv_dir)/sources;
(3) Click the "Browse Build ..." button to select the build path;

(4) Click Configure in the Popup dialog box to select Build project version and compiler;

(5) Tick the red bar to select the items and attributes to be generated;
If you want to compileopencv_contrib, you setOPENCV_EXTRA_MODULE_PATHThe value is$(opencv_contrib_dir)/modules, where“$(opencv_contrib_dir)”Saidopencv_contribUnzip the path.


The top is corresponding to the compilation of the dynamic link library version, if you compile the static link library version, you need to cancelBUILD_SHARE_LIBS
In order to OpenCV the final generated library into a world, you need to chooseBUILD_opencv_world

(6) Click Configure to complete, click Generate to generate project projects;

3. Open the OPENCV project and compile the source code to generate the dynamic link library we need
(1) Double-click the build directory OpenCV.sln, open the solution;

(2) Select the All_build project in the Solution Explorer window and right-click the "Generate" button;

(3) switch from debug mode to release to generate the project again;

The generated link library files are$(build_dir)/bin/DebugAnd$(build_dir)/bin/ReleaseUnder
4. Configuring OPENCV Environment Variables
(1) Right click "My Computer" select "Properties" → "Advanced system settings" → "Environment variables" → "new" for editing, add variable name "OPENCV", Variable value is "$ (opencv_dir) \build";

(2) Add the generated link library path at the end of the environment variable path;

(3) Log off or restart the system to make the environment variable effective.
5. Create test Project
(1) Create an empty project in VS2015OpenCVDisplayImage
(2) EditOpenCVDisplayImage.cpp, and copy the picture to the project directory;

 #include < iostream>   #include <opencv2/core/core.hpp>   #include <opencv2/highgui/highgui.hpp>  using   Span class= "Hljs-keyword" >namespace  CV; int  Main () {//read in a picture (game original)  Mat Img=imread      ( "pic.jpg" );      //create a "game art" window  Namedwindow ( "game original" );      //in the window to display the original picture of the game  imshow ( "game original" , IMG);  //wait for 6000 ms after the window automatically closes  waitkey (6000 ); } 

(3) configuration includes directory, library directory and additional dependencies;
In the property manager, double-click debug| Win32, select the Include directory under VC + + directory, add

$(OPENCV)\include;$(OPENCV)\include\opencv;$(OPENCV)\include\opencv2;

Library directory, adding

$(OPENCV)\x86\vc14\lib\Debug;$(OPENCV)\x86\vc14\3rdparty\lib\Debug;


Add at additional dependencies, input, linker:

opencv_ts300d.lib;opencv_world300d.lib;


For release, double-click release "Win32, select Include directory, add

$(OPENCV)\include;$(OPENCV)\include\opencv;$(OPENCV)\include\opencv2;

Library directory, adding

$(OPENCV)\x86\vc14\lib\Release;$(OPENCV)\x86\vc14\3rdparty\lib\Release;

(4) Build the project and run it as shown in the results.

problems in the compilation process

The following steps are compiled:
1. CMake Error at 3rdparty/ippicv/downloader.cmake

CMake Error at 3rdparty/ippicv/downloader.cmake:75 (message):  icv:failed to download ICV Package:ippicv_windows_ 20141027.zip.  status=18; " Transferred a partial file "call Stack (most recent call first):  3rdparty/ippicv/downloader.cmake:108 (_icv_ Downloader)  cmake/opencvfindipp.cmake:235 (include)  cmake/opencvfindlibsperf.cmake:12 (include)  cmakelists.txt:526 (include)  configuring incomplete, Errors occurred!

Workaround:
A) manually download the Ippicv_windows_20141027.zip
b) Put the above zip file under the OpenCV directory, my path is the following:
E:\develop\opencv\include\opencv-3.0.0-windows\sources\3rdparty\ippicv\downloads\windows-b59f865d1ba16e8c84124e19d78eec57

c) Open the CMake and re-configure to generate the project file.

2, OpenCV 3.0 compilation failed

Visual Studio 2015 compilation installs OpenCV 3.0 and Opencv_contrib

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.