Download the latest version of the runtime from the official website https://opencv.org/releases/
Unzip to the specified folder
Add environment variables to the system
Open the Control Panel, enter System Information, and click Advanced System Settings
Click on environment variables
Add D:\OpenCV project\opencv 4.6 runtime\build\x64\vc15 (OpenCV runtime path) to the Path environment variable
Visual Studio project configuration
Create a C++ console application
Enter the property manager
Configure Debug|x64
VC++ directory
include directory added:
D:\OpenCV project\opencv 4.6 runtime\build\include
D:\OpenCV project\opencv 4.6 runtime\build\include\opencv2
Add D:\OpenCV project\opencv 4.6 runtime\build\x64\vc15\lib to the library directory
Linker
Enter additional dependency projects to fill in opencv_world460d.lib
That is, the full file name of the file under this path
Copy the library files compiled at runtime to the compilation path of the project
Test opening the picture
#include <iostream>
#include <opencv2/core.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/imgcodecs.hpp>
using namespace std;
using namespace cv;
int main()
{
Mat image;
image = imread("C:\\Users\\Aron\\Desktop\\01\\1.jpg");
imshow("Test", image);
waitKey(0);
}