1.安装QT ,注意选择“msvc2015_64”,"VC++"选项。
2.安装vs2015。
3.安装opencv,可以选择cmake编译,编译opencv。
4.配置环境变量,配置到电脑PATH。
QT:
\5.10.0\msvc2015_64\bin
opencv:
\install\x64\vc14\bin
5.新建qt项目,在“.pro”文件加入以下配置:
INCLUDEPATH += D:/run/cepencv/install/include INCLUDEPATH += D:/run/cepencv/install/include/opencv\ INCLUDEPATH += D:/run/cepencv/install/include/opencv2\ CONFIG(debug, debug|release): { LIBS += -LD:/run/cepencv/install/x64/vc14/lib \ -lopencv_calib3d330d \ -lopencv_core330d \ -lopencv_dnn330d \ -lopencv_features2d330d \ -lopencv_flann330d \ -lopencv_highgui330d \ -lopencv_imgcodecs330d \ -lopencv_imgproc330d \ -lopencv_ml330d \ -lopencv_objdetect330d \ -lopencv_photo330d \ -lopencv_shape330d \ -lopencv_stitching330d \ -lopencv_superres330d \ -lopencv_video330d \ -lopencv_videoio330d \ -lopencv_videostab330d } else:CONFIG(release, debug|release): { LIBS += -LD:/run/cepencv/install/x64/vc14/lib \ -lopencv_calib3d330d \ -lopencv_core330d \ -lopencv_dnn330d \ -lopencv_features2d330d \ -lopencv_flann330d \ -lopencv_highgui330d \ -lopencv_imgcodecs330d \ -lopencv_imgproc330d \ -lopencv_ml330d \ -lopencv_objdetect330d \ -lopencv_photo330d \ -lopencv_shape330d \ -lopencv_stitching330d \ -lopencv_superres330d \ -lopencv_video330d \ -lopencv_videoio330d \ -lopencv_videostab330d }注意选择对应的路径,最后“构建”->“执行qmake”
“构建”->“执行qmake”
“构建”->“执行qmake”
6.写软件测试
#include "mainwindow.h" #include <QApplication> #include "opencv2/highgui/highgui.hpp" #include "opencv2/imgproc/imgproc.hpp" using namespace cv; using namespace std; int main(int argc, char *argv[]) { Mat image = imread("D:\\learn\\qt\\practise\\opence\\opencv\\2.jpg"); cvNamedWindow("sindow", CV_WINDOW_AUTOSIZE); imshow("window", image); waitKey(0); return 0; }