第1步附加包含目录:H:\software\programming\opencv\opencv\build\include
第2步附加库目录:H:\software\programming\opencv\opencv\build\x64\vc15\lib
第3步附加依赖项:opencv_world410.lib release模式 。其中opencv_world410d.lib是debug模式
报错找不到opencv_world410.dll 添加环境变量H:\software\programming\opencv\opencv\build\x64\vc15\bin
还报错重启visual studio。成功显示ly.jpg
代码如下:
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
String filename = "ly.jpg";
Mat image;
image = imread(filename, IMREAD_COLOR); // 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
return 0;
}
4这个位置是项目的目录,图片要放在这里