文章目录
- 配置
- 代码
- 窗口绑定
配置
选择添加库
选择外部库
LIBS += -L'C:/Program Files/MVTec/HALCON-17.12-Progress/lib/x64-win64/'
LIBS += -lhalconcpp\
-lhdevenginecpp\
-lhalcon
INCLUDEPATH += 'C:/Program Files/MVTec/HALCON-17.12-Progress/include'
DEPENDPATH += 'C:/Program Files/MVTec/HALCON-17.12-Progress/include'
代码
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
HalconCpp::HObject m_oImg;
HalconCpp::ReadImage(&m_oImg,("code3906.png"));
HalconCpp::OpenWindow(0,0,480,640,0,"visible","black",&hWnd);
HalconCpp::DispImage(m_oImg,hWnd);
}
窗口绑定
Widget::Widget(QWidget *parent)
: QWidget(parent)
, ui(new Ui::Widget)
{
ui->setupUi(this);
//获取窗口ID
Hlong WidgetId=ui->widget->winId();
HalconCpp::HObject m_oImg;
HalconCpp::ReadImage(&m_oImg,("code3906.png"));
HalconCpp::OpenWindow(0,0,ui->widget->width(),ui->widget->height(),WidgetId,"visible","black",&hWnd);
//显示灰度图
//HalconCpp::DispImage(m_oImg,hWnd);
//显示图像
HalconCpp::DispObj(m_oImg,hWnd);
}