基础是已经添加了halcon 和qt的路径;如果没有请看前面的博客,添加路径;
qt显示图片之label
Hlong MainWndID;
HTuple hv_Width, hv_Height;
HTuple hv_WindowID;
HObject himage1, ho_ROI1;
QString str = QDir::currentPath() +"/Data/I2.bmp";
//读取图片
HalconCpp::ReadImage(&himage1,str.toStdString().c_str());
qt label的winid
MainWndID = (Hlong)this->ui.label->winId();
//打开窗口
OpenWindow(0, 0, ui.label->width() , ui.label->height(), MainWndID, "visible", "", &hv_WindowID);
qt 加载wind
//画一个圆
GenCircle(&ho_ROI1, 200, 200, 90);
//显示圆 和图片
if (HDevWindowStack::IsOpen())
DispObj(ho_Image, HDevWindowStack::GetActive());
if (HDevWindowStack::IsOpen())
DispObj(ho_ROI1, HDevWindowStack::GetActive());
//截取窗口图片
DumpWindowImage(&himage1, hv_WindowID);
//保存图片
WriteImage(himage1, "bmp", 0, "C:/Users/mxw/Desktop/124.bmp");