VS 2019 configuration opencv under Win

VS 2019 configuration opencv under Win

(Configure once, add property sheet later)

1. Environment:
Visual Studio 2019 Opencv
3.4.12
My Opencv installation address: D:\opencv\opencv

  • View the opencv version
    Open the installation directory of opencv---->Enter the build directory---->Open OpenCVConfig-version.cmake with Notepad
                   
  • Download the opencv
    official website download address https://opencv.org/ , after entering (if you remember correctly) open the online documentation, the latest version on the left

2. System configuration

  • Environment Variables
    Open the Control Panel---->System and System Security---->System---->Advanced System Settings

    ---->Advanced---->Environment Variables---->System Variables---->Path Insert picture description here
    ---->Add to path: D:\opencv\opencv\build\x64\vc15\bin
    Insert picture description here
  • Copy files Copy
    the opencv_world3412.dll, opencv_world3412d.dll, opencv_ffmpeg3412_64.dll files in the D:\opencv\opencv\build\x64\vc15\bin directory to C:\Windows\System32 (three dll files, the names may be different)
                   

Three.VS 2019 configuration

  • Create a new project---->c++ console application---->set the name and storage location
  • Solution---->opencv---->right click properties
  • ---->vc++ directory---->Include directory
    Insert picture description here
    add D:\opencv\opencv\build\include and D:\opencv\opencv\build\include\opencv2 (see your address, that is, address+\build\ include and address +\build\include\opencv2)
  • ---->vc++ directory---->library directory
    Insert picture description here
    add D:\opencv\opencv\build\x64\vc15\lib (address+\build\x64\vc15\lib)
  • ---->linker---->input---->additional dependencies
    Insert picture description here
    add opencv_world3412d.lib (add this in debug mode)
    or opencv_world3412.lib (add this in release mode)
    (see your own previous What are the names of the two files, in the copy file)
    Insert picture description here
  • determine
  • Exit Properties---->Open Property Manager---->Debug Win32
    If you are not sure which file it is, you can right-click the properties and see which one is just changed.
  • Right-click ----> add new project property sheet
    Insert picture description here
  • Change the name of the attribute table to opencvDebug and create a new folder to store the attribute table
    Insert picture description here
  • When running, pay attention to change to Debug x64
    Insert picture description here
  • Next time, when you need to create an opencv file, directly in the property manager---->Debug Win32---->right click to add an existing property sheet---->add the last saved property sheet

四.CONGRATULATIONS!

Five. Test code

#include <opencv2/opencv.hpp>
using namespace cv;
int main()
{
    
    
    Mat srcImage = imread("C:\\Users\\441\\Desktop\\ZL\\夏目\\1.jpg");
    imshow("原图",srcImage);
    waitKey(0);
    return 0;
}

Add your own picture address in imread()

Guess you like

Origin blog.csdn.net/X_To_Y/article/details/112911778