下载OpenCV官方文件并解压
在debug x64环境下
c++项目属性包含如下路径:
C:\opencv\build\include
C:\opencv\build\include\opencv2
链接库添加如下路径:
C:\opencv\build\x64\vc15\lib
附加依赖项添加:opencv_world420d.lib
然后运行代码:
#include<iostream>
#include<opencv.hpp>
#include<highgui.hpp>
using namespace cv;
using namespace std;
#define show(exp); imshow( # exp , exp );
int main() {
string img_path;
getline(cin, img_path);
if (img_path[0] == '"') img_path = string(img_path,1,img_path.size()-2);
Mat img = imread(img_path.c_str());
show(img);
waitKey();
return 0;
}
成功