系統:windows10
Qt版本:5.13.1
OpenCV版本:3.4.3(與4.1.1)
2. Qt安裝
點選「下一步」。
D:\Qt5.13.1\5.13.1\mingw73_32\bin
D:\Qt5.13.1\Tools\mingw730_32\bin
INCLUDEPATH += F:/OpenCV/OpenCV3.4.3/opencv_3.4.3_build_qt/include\
F:/OpenCV/OpenCV3.4.3/opencv_3.4.3_build_qt/include/opencv\
F:/OpenCV/OpenCV3.4.3/opencv_3.4.3_build_qt/include/opencv2
LIBS += F:/OpenCV/OpenCV3.4.3/opencv_3.4.3_build_qt/x86/mingw/lib/libopencv_*.dll.a
若使用OpenCV4.0及以上版本,由於OpenCV4.0取消了所有的C語言介面部分,故路徑設定不需要新增最後一級檔案目錄名為「opencv」的路徑,即需要新增的路徑如下:
INCLUDEPATH += F:/OpenCV/OpenCV4.1.1/opencv_4.1.1_build_qt/include\
F:/OpenCV/OpenCV4.1.1/opencv_4.1.1_build_qt/include/opencv2
LIBS += F:/OpenCV/OpenCV4.1.1/opencv_4.1.1_build_qt/x64/mingw/lib/libopencv_*.dll.a
#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("F:\\RM.png"); // 這邊修改成自己的圖片路徑,注意雙斜槓
if(img.empty())
{
cout << "can't read this image!" << endl;
return 0;
}
imshow("image", img);
waitKey(0);
return 0;
}
至此大功告成,耶!!!