Halcon C++混合编程学习之Qt 实现检测焊接点

 1 # include "HalconCpp.h"
# include "HDevThread.h"
# include <X11/Xlib.h>
# include <stdio.h> using namespace HalconCpp; // Main procedure
void action()
{ // Local iconic variables
HObject ho_Die, ho_Brightregion, ho_ROI, ho_DieROI;
HObject ho_RawSegmentation, ho_Wires, ho_BallRegion, ho_Balls;
HObject ho_FinalBalls; // Local control variables
HTuple hv_WindowID,hv_WindowID2;
HTuple hv_Width,hv_Height; ReadImage(&ho_Die, "/home/debug/Halcon_Test/Halcon_Qt_Test/DeteBondPoint/die_03.png");
GetImageSize(ho_Die,&hv_Width,&hv_Height);
SetWindowAttr("background_color","black");
OpenWindow(,,hv_Width,hv_Height,,"","",&hv_WindowID);
HDevWindowStack::Push(hv_WindowID);
DispImage(ho_Die,hv_WindowID); Threshold(ho_Die, &ho_Brightregion, , );
ShapeTrans(ho_Brightregion, &ho_ROI, "rectangle2");
ReduceDomain(ho_Die, ho_ROI, &ho_DieROI);
Threshold(ho_DieROI, &ho_RawSegmentation, , );
FillUpShape(ho_RawSegmentation, &ho_Wires, "area", , );
OpeningCircle(ho_Wires, &ho_BallRegion, 15.5);
Connection(ho_BallRegion, &ho_Balls);
SelectShape(ho_Balls, &ho_FinalBalls, "circularity", "and", 0.85, 1.0); if (HDevWindowStack::IsOpen())
SetWindowAttr("background_color","black");
OpenWindow(,,hv_Width,hv_Height,,"","",&hv_WindowID2);
HDevWindowStack::Push(hv_WindowID2);
DispObj(ho_FinalBalls, HDevWindowStack::GetActive()); WaitSeconds();
ClearWindow(hv_WindowID);
ClearWindow(hv_WindowID2); } int main(int argc, char *argv[])
{
// Default settings used in HDevelop (can be omitted)
int ret=;
// SetSystem("width", 700);
// SetSystem("height", 600);
XInitThreads();
action();
return ret;
} 结果如下:

Halcon C++混合编程学习之Qt 实现检测焊接点


上一篇:springboot 常用配置文件


下一篇:P2920 [USACO08NOV]时间管理Time Management