Install Opencv in VS2019

Install Opencv in VS2019

1. Download Opencv

Download from the opencv official website, address: https://sourceforge.net/projects/opencvlibrary/
Insert image description here
Click DownLoad, wait 5 seconds and the download will start automatically. If you want to download other versions, you can also find it here: https://opencv .org/releases/

2. Install Opencv

1. Double-click the downloaded .exe file, select the installation location, and click Extract.
Insert image description here
After decompression is completed, there is the following content in the opencv folder:
Insert image description here
2. Add environment variables
. Right-click this computer, select Properties, open advanced system settings, select environment variables, find the path variable in system variables, double-click it to open it, click New, and change " H:\opencv\build\x64\vc15\bin" path is added to the environment variable.
Insert image description here
Insert image description here
3. Find the following three files in the "H:\opencv\build\x64\vc15\bin" directory:
Insert image description here
4. Copy the three files "opencv_world452.dll", "opencv_world452d.dll" and "opencv_videoio_ffmpeg452_64.dll" Go to the directory "C:\Windows\System32".
Insert image description here

3. Configure Opencv in VS2019

1. Open VS2019, create a new empty project, select the storage path and click Create.
Insert image description here
Insert image description here
2. Right-click the created project, select Properties, open the property page and select "Debug|X64" mode.
Insert image description here
Insert image description here
3. Select "Include Directory" in the VC++ directory, click Edit, and add the following two paths:

H:\opencv\build\include
H:\opencv\build\include\opencv2

Insert image description here
Insert image description here
4. Select "Library Directory" in the VC++ directory, click Edit, and add the following path:

H:\opencv\build\x64\vc15\lib

Insert image description here
Insert image description here
5. Select "Input" in the linker, select "Additional Dependencies", click Edit, and add the following variables:

opencv_world452d.lib

Insert image description here
Insert image description here
The attribute configuration is completed, let’s conduct a simple test.

4. Test

Create a new item in the source file and add the .cpp source file.
Insert image description here
The test code is as follows:

#include<opencv2/imgcodecs.hpp>
#include<opencv2/highgui.hpp>
#include<opencv2/imgproc.hpp>
#include<iostream>
using namespace cv;
using namespace std;

int main()
{
    
    
	string path = "H:\\test.jpg"; //这里的路径是你测试图片的存放路径,用"\\"来分隔每个文件
	Mat img = imread(path);
	imshow("Image", img);
	waitKey(0);
	return 0;
}

The results are as follows:
Insert image description here
At this point, the installation of Opencv in VS2019 is successfully completed~

Guess you like

Origin blog.csdn.net/Wxy971122/article/details/117782229