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 ~
Download OpenCV4.1.0 of: https://opencv.org/releases/ , you can choose Windows, and then extract the installation.
opencv configuration steps(Designated focus !!!)
Article Directory
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.
2. New Configuration Item
Open the VS2019, a new empty project, select Console Application, can be determined
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
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
}