opencv4.0 + cmake + vs2017 environment configuration

1. Download the appropriate package from the official website opencv

        Good has been downloaded and uploaded to the network disk, link: https: //pan.baidu.com/s/1YktAwRPk2DlUGranPHPgKg. Extraction code: mjey 

2. Download the corresponding version of cmake_gui

     Note cmake and visual studio version to version and version opencv adapt, use here vs2017 version, version 4.0 opencv

3.cmake compile the source code

    The benefits of open-source framework that can come into contact with the source code, so get the required dll lib and compile from source, if something goes wrong or need to optimize the efficiency of the algorithm, you can debug the corresponding source code for the project.

   1. Set soure corresponding file path, the file path and bin

   2. The first click configure, will pop up the corresponding compiler platform, IDE is vs2017 64-bit, so the choice of compiler-bit visual studio 2017 _64

   3. The second confiure, check the files needed to generate attention, after opencv3.0 provides opencvworld.dll to the series for all dll references, remember to check here build_opencv_world 

   4, after all the configure has been completed, the interface is not red, indicating ok \

   5. Click generate will produce corresponding vs engineering

   6. If the follow-up found some module really, you can check the corresponding option, re-engineering cmake

 

4. opencv source compiler

  1. Click ALL_BUILD compiled cmaketarget folder of all projects, take some time to compile, compile all the success is not being given instructions have been OK.

  2. Click install, vs cmake will be set according to the document, the corresponding compiler-generated include, lib, bin folder to generate corresponding install folder below.

  3.ok, I can now use their own algorithms to compile the file to test it! !

 

5.opencv project environment configuration test

  1. The corresponding new empty project

   2.添加cpp文件如下

  3.打开该项目的属性视图,增加一个属性配置在x64中,命名为opencv4.0deug.prop

 4.在对应的c++目录中增加inclue 路径

D:\Code\opencv_cxx\opencv-4.0.0-bin\install\include

D:\Code\opencv_cxx\opencv-4.0.0-bin\install\include\opencv2

5 在c++目录的库目录中增加

D:\Code\opencv_cxx\opencv-4.0.0-bin\install\x64\vc15\lib

6.在链接器 -》输入 中增加opencv_world4.0d.dll(这里只有debug dll ,如果需要编译对应的release版本,返回到对应的源码编译工程,以release的方式重新编译即可)

7.在系统环境变量path中增加路径

D:\Code\opencv_cxx\opencv-4.0.0-bin\install\x64\vc15\bin

8.运行以下代码ok,可以看到显示的企鹅的图像了。

9 ,这个属性页opencv4.0.prop可以直接方便为其他项目引入配置。

 

 1 #include <opencv2/opencv.hpp>
 2 #include <iostream>
 3 
 4 using namespace cv;
 5 using namespace std;
 6 
 7 int main(int artc, char** argv) {
 8 
 9     Mat src = imread("D:\\Code\\opencv_cxx\\opencv_application\\images\\95728.jpg", IMREAD_GRAYSCALE);
10     if (src.empty()) {
11         printf("could not load image...\n");
12         return -1;
13     }
14     namedWindow("input", WINDOW_AUTOSIZE);
15     imshow("input", src);
16 
17     waitKey(10000);
18     return 0;
19 }

 

 

 

 

 

 

 

 

 

 

Guess you like

Origin www.cnblogs.com/codeAndlearn/p/11424087.html
Recommended