OpenCV官网
咱们是Windows环境因此选择 Windowsios
在包含目录中引入路径:visual-studio
在库目录中引入路径:测试
在 链接器-输入-附加依赖项 下加入:ui
#include<iostream> #include<opencv2/opencv.hpp> using namespace std; using namespace cv; int main() { Mat src = imread("d:/a.png"); if (src.empty()) { cout << "could not load image..." << endl; return -1; } namedWindow("Display Window", WINDOW_AUTOSIZE); imshow("Display Window", src); waitKey(0); return 0; }
OpenCV4.3 只给x64编译 因此在Visual Studio中若是用x86会:
此时换成x64:
记得环境变量:spa
也要从新配置一遍Visual Studio属性,x86和x64是分开的。code