zw版【转发· 台@@湾 nvp系列Delphi例程】HALCON AffineTransRegion
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; rg : HRegionX; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var HomMat2D : HHomMat2DX; begin HomMat2D := CoHHomMat2DX.Create; HomMat2D.HomMat2dIdentity; HomMat2D := HomMat2D.HomMat2dRotate(Pi / 4, 250, 250); rg := rg.AffineTransRegion(HomMat2D, 'nearest_neighbor'); HWindowXCtrl1.HalconWindow.ClearWindow; img.DispObj(HWindowXCtrl1.HalconWindow); rg.DispObj(HWindowXCtrl1.HalconWindow); end; procedure TForm1.FormShow(Sender: TObject); var w, h : OleVariant; begin img := CoHImageX.Create; rg := CoHRegionX.Create; img.ReadImage('ic0'); w := img.GetImageSize(h); HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1); HWindowXCtrl1.HalconWindow.SetDraw('margin'); HWindowXCtrl1.HalconWindow.SetLineWidth(2); HWindowXCtrl1.HalconWindow.SetColor('red'); rg.GenRectangle1(150, 150, 349, 349); img.DispObj(HWindowXCtrl1.HalconWindow); rg.DispObj(HWindowXCtrl1.HalconWindow); end; end.
|
请发表评论