build opencv with qt to make debugging easier

最近发现使用自己编译的opencv,可以增强opencv的imshow函数功能。从哪里得到的线索已经忘记了。可能是无意中发现的某一张截图吧。

要实现cv::imshow函数功能增强,需要在cmake中配置使用qt。

编译及使用,见视频:

 

# testProj.pro
QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

INCLUDEPATH += D:/data/playGround/install_opencv_from_source/opencv-4.5.0-build/install/include
LIBS += D:/data/playGround/install_opencv_from_source/opencv-4.5.0-build/install/x64/vc15/lib/opencv_world450d.lib
// main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "opencv2/opencv.hpp"

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

    cv::Mat image = cv::imread("D:/dog.jfif");
    cv::namedWindow("img", cv::WINDOW_NORMAL);
    cv::imshow("img", image);
    cv::waitKey();
    cv::destroyAllWindows();
    return 0;
}

 

building detail









posted on 2022-11-06 23:20  yusisc  阅读(20)  评论(0编辑  收藏  举报

导航