zw版【转发·台湾nvp系列Delphi例程】HALCON SetIcon2
procedure TForm1.Button1Click(Sender: TObject);
var img : HUntypedObjectX; w, h : OleVariant; rg, rg1 : HUntypedObjectX; op : HOperatorSetX;begin op := CoHOperatorSetX.Create; op.ReadImage(img, 'rings_and_nuts'); op.GetImageSize(img, w, h); HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1); img.DispObj(HWindowXCtrl1.HalconWindow); op.Threshold(img, rg, 0, 128); op.ClipRegion(rg, rg1, 10, 10, h - 10, w - 10); op.Connection(rg1, rg); HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1); HWindowXCtrl2.HalconWindow.SetDraw('margin'); HWindowXCtrl2.HalconWindow.SetColored(12); img.DispObj(HWindowXCtrl2.HalconWindow); rg.DispObj(HWindowXCtrl2.HalconWindow); HWindowXCtrl3.HalconWindow.SetPart(0, 0, h - 1, w - 1); HWindowXCtrl3.HalconWindow.SetDraw('margin'); HWindowXCtrl3.HalconWindow.SetColored(12); HWindowXCtrl3.HalconWindow.SetShape('icon'); op.GenCircle(rg1, 100, 100, 60); op.SetIcon(rg1, HWindowXCtrl3.HalconWindow.HalconID); img.DispObj(HWindowXCtrl3.HalconWindow); rg.DispObj(HWindowXCtrl3.HalconWindow); op.ClearObj(img); op.ClearObj(rg); op.ClearObj(rg1);end;