当前位置: 首页 > 工具软件 > raw2tiff > 使用案例 >

2、ubuntu20.04安装QT并测试opencv

蒋岳
2023-12-01

1、安装QT的教程参考如下,写的非常详细

Ubuntu 20.04 下载、安装、配置、使用 QT 5.9.0 - 灰信网(软件开发博客聚合)

2、QT启动后,创建cosole项目,项目配置如下:

TEMPLATE = app

SOURCES += main.cpp

# The following define makes your compiler emit warnings if you use
# any feature of Qt which as been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# 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 +=/usr/local/include\
/usr/local/include/opencv4

LIBS +=/usr/local/lib/libopencv_*.so

3、简单的测试程序如下

#include <QCoreApplication>
#include <opencv2/opencv.hpp>
using namespace cv;

int main(int argc, char *argv[])
{
//

    Mat src;
    src = imread("/home/chen/imgtest.png");
    imshow("img_text",src);
    waitKey(0);
    QCoreApplication a(argc, argv);
    return 0;

//    return a.exec();
}

 类似资料: