Preparing the development environment (OpenCV 4.3.0 + VS2019)

  • Download the OpencV library: opencv.org/releases/
  • Opencv-4.3.0-vc14_vc15.exe executable file (opencv-4.3.0-vc14_vc15.exe)
  • After executing the exe file, generate the OpencV directory in the same directory, including the build and sources folders

  • VS2019 use in community edition: visualstudio.microsoft.com/zh-hans/dow…

VS project creation and configuration

  • Create the CMake project
  • In the cmakelist.txt file, set up the header and library files supported by OpencV
Cmake_minimum_required (VERSION 3.8) # directories("... /opencv/build/include") # directories... Opencv/build/x64 vc15 / lib ") # add source code to the executable file to the project. Add_executable (OpevCV_demo_430 "opevcv_DEMO_430. CPP" "opevcv_DEMO_430. h") # link opencV libraries to this project target_link_libraries(ObjectName opencv_world430d.lib)Copy the code
  • Copy the dynamic library file (opencv_world430D.dll) to the directory (.ext) where the project generated the executable file

Code verification: get OpenCV version number

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace std;

int main()
{
    cout << "opencv version:"<< CV_VERSION << endl;
    system("pause");
    return 0;
}
Copy the code

Print result: