VS2019 configuration OpenCV4.1.0

Download the VS2019: https://visualstudio.microsoft.com/zh-hans/downloads/ , download here the general community version, and then select the desktop in general and the development of a common platform to develop, document, then it is best not installed on the C drive ah ~
Here Insert Picture Description
Download OpenCV4.1.0 of: https://opencv.org/releases/ , you can choose Windows, and then extract the installation.

opencv configuration steps(Designated focus !!!)

1. Add the environment variable

I am here for the installation directory: F: \ opencv4. Add the PATH inside F: \ opencv4 \ opencv \ build \ x64 \ vc15 \ bin. Remember to determine the save, need to restart after some students say you want to change the environment variables, and here I still can not restart. Meanwhile, F: \ opencv4 \ opencv \ build \ x64 \ vc15 \ bin directory, copy the following opencv_world401.dll and opencv_world401d.dll files to C: \ Windows \ SysWOW64 folder.

Here Insert Picture Description

2. New Configuration Item

Open the VS2019, a new empty project, select Console Application, can be determined
Here Insert Picture Description

3. Configure VS

As shown open Property Manager, compilation method generally choose Release | X64, click Properties, and add the directory that contains the library catalog.
Directory containing: F: \ opencv4 \ opencv \ build \ include \ opencv2, F: \ opencv4 \ opencv \ build \ include
library directory: F: \ opencv4 \ opencv \ build \ x64 \ vc15 \ lib
configuration link, add additional libraries catalog and additional dependencies.
Additional library directory: F: \ opencv4 \ opencv \ build \ x64 \ vc15 \ lib
Additional Dependencies: opencv_world410.lib, opencv_world410d.lib

Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description
Here Insert Picture Description

4. Test Code

#include <iostream>
#include <opencv2/highgui.hpp>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>

using namespace cv;
using namespace std;

int main()
{
	Mat image;
	image = imread("C:\\Users\\Lenovo\\Desktop\\opencv-logo.png"); // Read the file

	if (image.empty()) // Check for invalid input
	{
		cout << "Could not open or find the image" << std::endl;
		return -1;
	}


	namedWindow("Display window", WINDOW_AUTOSIZE); // Create a window for display.
	imshow("Display window", image); // Show our image inside it.

	waitKey(0); // Wait for a keystroke in the window

}

Here Insert Picture Description

Published 15 original articles · won praise 9 · views 6923

Guess you like

Origin blog.csdn.net/Magician0619/article/details/97378780