QT+opencv

环境:win10,qtcreator,opencv,msvc2017,cdb.exe

之前我按照教程配置opencv执行qmake和构建都没有问题,但是一到执行exe的时候就特么crashed。。。我#####*************。搞了好久我终于明白了为什么。

配置步骤参考该博文,讲的非常详细:

https://www.cnblogs.com/scobbing/p/6349275.html

然后我发现我的opencv没有配置系统环境变量,在System的Path下,如果你也没有,记得加上:

然后我创建了普通的Widget工程,就酱紫:

# You can also make your code fail to compile if you use deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
INCLUDEPATH += D:/opencv/build/include

CONFIG(debug, debug|release): {
LIBS += -LD:/opencv/build/x64/vc12/lib \
-lopencv_core2411d \
-lopencv_imgproc2411d \
-lopencv_highgui2411d \
-lopencv_ml2411d \
-lopencv_video2411d \
-lopencv_features2d2411d \
-lopencv_calib3d2411d \
-lopencv_objdetect2411d \
-lopencv_contrib2411d \
-lopencv_legacy2411d \
-lopencv_flann2411d
} else:CONFIG(release, debug|release): {
LIBS += -LD:/opencv/build/x64/vc12/lib \
-lopencv_core2411 \
-lopencv_imgproc2411 \
-lopencv_highgui2411 \
-lopencv_ml2411 \
-lopencv_video2411 \
-lopencv_features2d2411 \
-lopencv_calib3d2411 \
-lopencv_objdetect2411 \
-lopencv_contrib2411 \
-lopencv_legacy2411 \
-lopencv_flann2411
}
#include "mainwindow.h"
#include 
#include 
#include 

using namespace std;
using namespace cv;

//int main(int argc, char *argv[])
//{
////    QApplication a(argc, argv);
////    MainWindow w;
////    w.show();

////    return a.exec();
//}
int main(){
    Mat image = imread("F:\\...\\edit.jpg");
    cvNamedWindow("window", CV_WINDOW_NORMAL);
    imshow("window",image);
    waitKey(0);
}

就出来东西了。

你可能感兴趣的:(QT)