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

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

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

procedure TForm1.Button1Click(Sender: TObject);
var
ho_Egypt1 : HImageX;
ho_Egypt2 : HImageX;
ho_Region : IHRegionX;
w, h : OleVariant;
Rows, Columns: OleVariant;
ht : HTupleX;
begin
ho_Egypt1 := CoHImageX.Create;
ho_Egypt1.ReadImage('screw_thread');
w := ho_Egypt1.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
ho_Egypt1.DispObj(HWindowXCtrl1.HalconWindow);
ho_Region := ho_Egypt1.BinThreshold;
ho_Egypt1 := ho_Egypt1.ChangeDomain(ho_Region);
w := ho_Egypt1.GetImageSize(h);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
HWindowXCtrl2.HalconWindow.SetColor('red');
HWindowXCtrl2.HalconWindow.SetDraw('margin');
HWindowXCtrl2.HalconWindow.ClearWindow;
ho_Egypt1.DispObj(HWindowXCtrl2.HalconWindow);
ho_Region.DispObj(HWindowXCtrl2.HalconWindow);

Rows := ho_Region.GetRegionPoints(Columns);
ht := CoHTupleX.Create;
ho_Egypt2 := ho_Egypt1.CropPart(ht.TupleMin(Rows), ht.TupleMin(Columns), ht.TupleMax(Columns) - ht.TupleMin(Columns) + 1, ht.TupleMax(Rows) - ht.TupleMin(Rows) + 1);
w := ho_Egypt2.GetImageSize(h);
HWindowXCtrl3.HalconWindow.SetPart(0, 0, h - 1, w - 1);
HWindowXCtrl3.HalconWindow.SetColor('red');
HWindowXCtrl3.HalconWindow.SetDraw('margin');
HWindowXCtrl3.HalconWindow.ClearWindow;
ho_Egypt2.DispObj(HWindowXCtrl3.HalconWindow);

ho_Egypt1 := ho_Egypt1.FullDomain;
ho_Egypt2 := ho_Egypt1.CropPart(ht.TupleMin(Rows), ht.TupleMin(Columns), ht.TupleMax(Columns) - ht.TupleMin(Columns) + 1, ht.TupleMax(Rows) - ht.TupleMin(Rows) + 1);
w := ho_Egypt2.GetImageSize(h);
HWindowXCtrl4.HalconWindow.SetPart(0, 0, h - 1, w - 1);
HWindowXCtrl4.HalconWindow.SetColor('red');
HWindowXCtrl4.HalconWindow.SetDraw('margin');
HWindowXCtrl4.HalconWindow.ClearWindow;
ho_Egypt2.DispObj(HWindowXCtrl4.HalconWindow);
end;

上一篇:WIndows下使用Grafana+InfluxDB打造监控系统


下一篇:sybase SA密码重置