zw版【转发·台湾nvp系列Delphi例程】HALCON AffineTransImage
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;
type
TForm1 = class(TForm)
HWindowXCtrl1: THWindowXCtrl;
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
img : HImageX;
w, h : OleVariant;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
HomMat2D : HHomMat2DX;
img1 : HImageX;
begin
HomMat2D := CoHHomMat2DX.Create;
HomMat2D.HomMat2dIdentity;
HomMat2D := HomMat2D.HomMat2dRotate(Pi / 4, 256, 256);
img1 := img.AffineTransImage(HomMat2D, ‘constant‘, ‘false‘);
w := img1.GetImageSize(h);
HWindowXCtrl1.HalconWindow.ClearWindow;
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img1.DispObj(HWindowXCtrl1.HalconWindow);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
img := CoHImageX.Create;
img.ReadImage(‘forest_road‘);
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl1.HalconWindow);
end;
end.