QT联合halcon实现实时形状模板匹配

 try.6pro

QT       += core gui
 
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
 
CONFIG += c++11
 
# The following define makes your compiler emit warnings if you use
# any Qt feature that has 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 it uses 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 += "C:\Users\jgy\AppData\Local\Programs\MVTec\HALCON-22.05-Progress\include//"
INCLUDEPATH += "C:\Users\jgy\AppData\Local\Programs\MVTec\HALCON-22.05-Progress\include\halconcpp//"
 
LIBS += "C:\Users\jgy\AppData\Local\Programs\MVTec\HALCON-22.05-Progress\lib\x64-win64/halcon.lib"
LIBS += "C:\Users\jgy\AppData\Local\Programs\MVTec\HALCON-22.05-Progress\lib\x64-win64/halconcpp.lib"
 
 
SOURCES += \
    main.cpp \
    widget.cpp
 
HEADERS += \
    widget.h
 
FORMS += \
    widget.ui
 
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target

widget.h

#ifndef WIDGET_H
#define WIDGET_H
 
#include "HalconCpp.h"
#include <QWidget>
#include <QDebug>
#include <QTimer> // 添加定时器头文件
#include <QGroupBox>
QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE
 
using namespace HalconCpp;
void clean_up_output (HTuple hv_OutputDir, HTuple hv_RemoveResults);
void set_display_font (HTuple hv_WindowHandle, HTuple hv_Size, HTuple hv_Font, HTuple hv_Bold,
    HTuple hv_Slant);
void remove_dir_recursively (HTuple hv_DirName);
void dev_display_shape_matching_results (HTuple hv_ModelID, HTuple hv_Color, HTuple hv_Row,
    HTuple hv_Column, HTuple hv_Angle, HTuple hv_ScaleR, HTuple hv_ScaleC, HTuple hv_Model);
void get_hom_mat2d_from_matching_result (HTuple hv_Row, HTuple hv_Column, HTuple hv_Angle,
    HTuple hv_ScaleR, HTuple hv_ScaleC, HTuple *hv_HomMat2D);
class Widget : public QWidget
{
 
    Q_OBJECT
 
 
public:
    Widget(QWidget *parent = nullptr);
    ~Widget();
    HObject ho_Image;
    HTuple hv_AcqHandle,hv_WindowHandle;
    HTuple qh_window_handle; 
    Hlong windID;
    void abb();
 
private slots:
    void camera();//放置需要定时器循环的代码
    void on_pushButton_3_clicked();
    void on_pushButton_clicked();
 
private:
    Ui::Widget *ui;
    QTimer *timer;
 
};
 
#endif // WIDGET_H
main.cpp
#include "widget.h"
 
#include <QApplication>
 
int main(int argc, char *argv[])
{
 
    QApplication a(argc, argv);
    Widget w;
    w.show();
    return a.exec();
}
widget.cpp

#include "widget.h"
#include "ui_widget.h"
 
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
 
    ui->setupUi(this);
    abb();
 
    // 初始化定时器
    timer=new QTimer(this);
    connect(timer,SIGNAL(timeout()),this,SLOT(camera()));
    connect(ui->pushButton,SIGNAL(clicked(bool)),qApp,SLOT(quit()));
//    timer->start(1000);
}
 
Widget::~Widget()
{
 
    delete ui;
}
 
void Widget::abb()
{
 
    HTuple qt_window_ID, width_qhw, height_qhw;
    HTuple Image_width, Image_height;
    Image_width = 1280;
    Image_height = 720;
    qt_window_ID = (Hlong)ui->groupBox->winId();
    width_qhw = ui->groupBox->width();
    height_qhw = ui->groupBox-&
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值