zw版【转发·*nvp系列Delphi例程】HALCON SelectObj

zw版【转发·*nvp系列Delphi例程】HALCON SelectObj

zw版【转发·*nvp系列Delphi例程】HALCON SelectObj

procedure TForm1.Button1Click(Sender: TObject);
var
img : HImageX;
w, h : OleVariant;
rg, rg1 : HRegionX;
ht : HTupleX;
begin
ht := CoHTupleX.Create;
img := CoHImageX.Create;
img.ReadImage('rings_and_nuts');
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl1.HalconWindow );

rg := img.Threshold(0, 128);
rg := rg.ClipRegion(10, 10, h - 10, w - 10);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl2.HalconWindow);
HWindowXCtrl2.HalconWindow.SetDraw('margin');
HWindowXCtrl2.HalconWindow.SetColored(12);
rg.DispObj(HWindowXCtrl2.HalconWindow);
HWindowXCtrl2.HalconWindow.SetColor('red');
HWindowXCtrl2.HalconWindow.SetTposition(10, 10);
HWindowXCtrl2.HalconWindow.WriteString('Object Nums : ' + IntToStr(rg.CountObj));
rg1 := rg.Connection;
HWindowXCtrl3.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl3.HalconWindow);
HWindowXCtrl3.HalconWindow.SetDraw('margin');
HWindowXCtrl3.HalconWindow.SetColored(12);
rg1.DispObj(HWindowXCtrl3.HalconWindow);
HWindowXCtrl3.HalconWindow.SetColor('red');
HWindowXCtrl3.HalconWindow.SetTposition(10, 10);
HWindowXCtrl3.HalconWindow.WriteString('Object Nums : ' + IntToStr(rg1.CountObj));
rg1 := rg1.SelectObj(ht.TupleConcat(3, 4));
HWindowXCtrl4.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl4.HalconWindow);
HWindowXCtrl4.HalconWindow.SetDraw('margin');
HWindowXCtrl4.HalconWindow.SetColored(12);
rg1.DispObj(HWindowXCtrl4.HalconWindow);
HWindowXCtrl4.HalconWindow.SetColor('red');
HWindowXCtrl4.HalconWindow.SetTposition(10, 10);
HWindowXCtrl4.HalconWindow.WriteString('Object Nums : ' + IntToStr(rg1.CountObj));
end;

上一篇:彻底搞定c指针


下一篇:【前端学习】【CSS选择器】