VS 2019 configuration opencv under Win
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
---->Add to path: D:\opencv\opencv\build\x64\vc15\bin
- 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
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
add D:\opencv\opencv\build\x64\vc15\lib (address+\build\x64\vc15\lib) - ---->linker---->input---->additional dependencies
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)
- determine
- Exit Properties---->Open Property Manager---->Debug Win32
- Right-click ----> add new project property sheet
- Change the name of the attribute table to opencvDebug and create a new folder to store the attribute table
- When running, pay attention to change to Debug x64
- 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()