zw版【转发·台湾nvp系列Delphi例程】HALCON HomMat2dRotate1
procedure TForm1.Button1Click(Sender: TObject);
var
img : HImageX;
rg : HRegionX;
w, h : OleVariant;
hv_HomMat2DIdentity, hv_HomMat2DRotate : HHomMat2DX;
begin
HWindowXCtrl1.HalconWindow.SetDraw(‘margin‘);
HWindowXCtrl1.HalconWindow.SetColor(‘red‘);
HWindowXCtrl2.HalconWindow.SetDraw(‘margin‘);
HWindowXCtrl2.HalconWindow.SetColor(‘red‘);
img := CoHImageX.Create;
img.ReadImage(‘ic1‘);
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
rg := CoHRegionX.Create;
rg.GenRectangle1(h / 2 - 100, w / 2 - 100, h / 2 + 100, w / 2 + 100);
img.DispObj(HWindowXCtrl1.HalconWindow);
rg.DispObj(HWindowXCtrl1.HalconWindow);
hv_HomMat2DIdentity := CoHHomMat2DX.Create;
hv_HomMat2DIdentity.HomMat2dIdentity;
hv_HomMat2DRotate := hv_HomMat2DIdentity.HomMat2dRotate(Pi / 180 * 45, h / 2, w / 2);
rg := hv_HomMat2DRotate.AffineTransRegion(rg, ‘false‘);
img.DispObj(HWindowXCtrl2.HalconWindow);
rg.DispObj(HWindowXCtrl2.HalconWindow);
end;