首页 > 解决方案 > 错误:使用未声明的标识符“scale_image_range”?

问题描述

我同时使用 Halcon 和 QT,我将 halcon 中的算法导出到 C++ 中,然后将导出的代码放入 QT 中。

我发现无法识别功能“scale_image_range”。如何解决这个问题呢?

我尝试使用命名空间 HalconCpp 添加#include "HalconCpp.h"、#include "HDevThread.h";到我的代码。但它不起作用

部分代码如下

    #include "mainwindow.h"
    #include "HalconCpp.h"
    #include "HDevThread.h"
    #include "ui_mainwindow.h"
    #include <QFileDialog>
    #include <QMessageBox>
    #include <QDir>
    #include <QRadioButton>
    using namespace std;
    using namespace HalconCpp;

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
    {
    ..............................
    }

    MainWindow::~MainWindow()
    {
    delete ui;
    }

    ////Slot function of button "Read"
    void MainWindow::on_pushButton_clicked()
    {

    ....................

    }

    //Slot function of button "Detect"
    void MainWindow::on_pushButton_2_clicked()
    {
    if(ui->radioButton->isChecked())
    {
    ................................


    }

    if(ui->radioButton_2->isChecked())
     {
    ...........

    **scale_image_range(ho_img2, &ho_img3, 20, 220);**

     .............................

}

}

我希望这个功能可以被 QT 识别

标签: c++qthalcon

解决方案


您必须将 HALCON 安装的包含目录添加到您的 .pro 文件中,以便 Qt 可以识别 HALCON 函数。HALCON 提供了一个标准示例,展示了如何将 HALCON 集成到 Qt 应用程序中。安装 HALCON 后,您可以在此处找到示例(Windows):%HALCONEXAMPLES%\cpp\qt\Matching

如上所述,对您来说最重要的部分是 .pro 文件,您需要在其中指定以下内容:

#includes
INCLUDEPATH   += "$$(HALCONROOT)/include"
INCLUDEPATH   += "$$(HALCONROOT)/include/halconcpp"

#libs
QMAKE_LIBDIR  += "$$(HALCONROOT)/lib/$$(HALCONARCH)"
unix:LIBS     += -lhalconcpp -lhalcon -lXext -lX11 -ldl -lpthread
win32:LIBS    += "$$(HALCONROOT)/lib/$$(HALCONARCH)/halconcpp.lib" \
               "$$(HALCONROOT)/lib/$$(HALCONARCH)/halcon.lib"


推荐阅读