1:准备好OpenCV 源码包
下载地址:https://opencv.org/releases.html
编译教程:https://blog.csdn.net/computerme/article/details/53433315
2:准备好cmake安装包;
下载地址:https://cmake.org/download/
安装教程https://blog.csdn.net/baimafujinji/article/details/78588488
3:编译
Demo:(main.cpp)
1 #include <opencv2/opencv.hpp> 2 3 using namespace cv; 4 5 int main(int argc, char* argv[]) 6 { 7 Mat img; 8 img = imread("img.jpg",1); 9 namedWindow("Display Image",WINDOW_AUTOSIZE); 10 imshow("Display Image",img); 11 waitKey(0); 12 return 0; 13 }
g++ main.cpp -std=c++1z -I/usr/local/include/ -L/usr/local/lib/ -lopencv_highgui.3.2.0 -lopencv_core.3.2.0 -lopencv_imgcodecs