qt-opensource-windows-x86-mingw491_opengl-5.4.0.exewindows
cmake-3.12.0-rc1-win64-x64.msi函數
opencv-2.4.10.zip工具
運行「qt-opensource-windows-x86-mingw491_opengl-5.4.0.exe」,安裝目錄爲C:\Qt,並將"C:\Qt\Qt5.4.0\5.4\mingw491_32\bin"添加到環境變量中去ui
運行"cmake-3.12.0-rc1-win64-x64.msi",記得選擇「將cmake添加到系統環境變量中」。spa
解壓opencv-2.4.10.zip,這裏我在opencv-2.4.10裏面建立了一個文件夾source,並將opencv-2.4.10內的文件複製到source文件夾,並在opencv-2.4.10文件夾內建立了一個build文件夾。3d
打開qcreeator,點擊"工具->選項->構建和運行->CMake",確保正確找到cmake路徑,以下:code
用qtcreator打開opencv的CMakeLists.txt文件,以下:blog
接下來,跟着提示走就好了,記得下面的配置:ip
點擊"構建"按鈕便可。qt
將"F:\opencv-2.4.10\build\install\x64\mingw\bin"寫入到系統環境變量中去。
在pro文件內添加如下內容:
INCLUDEPATH += F:/opencv-2.4.10/build/install/include \ F:/opencv-2.4.10/build/install/include/opencv \ F:/opencv-2.4.10/build/install/include/opencv2 LIBS += F:/opencv-2.4.10/build/install/x64/mingw/lib/libopencv_*
main函數以下:
#include <QCoreApplication> #include "opencv/highgui.h" #include "opencv/cv.h" void pepper_salt(cv::Mat &img, int n); cv::Mat contrast(cv::Mat &img); cv::Mat rotate(const cv::Mat &srcImg,double degree); int main(int argc, char *argv[]) { cv::Mat img1 = cv::imread("a.jpg"); cv::namedWindow("Salt&&Pepper Window"); cv::imshow("Salt&&Pepper Window", img1); cv::waitKey(0); cv::destroyAllWindows(); return 0; }