zw版【转发·台湾nvp系列Delphi例程】HALCON SetGray

zw版【转发·台湾nvp系列Delphi例程】HALCON SetGray-LMLPHP

SetGray_Delphi.PNG

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);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
img : HImageX;
rg, Circles : HRegionX;
tp : HTupleX;
w, h : OleVariant;
Row, Column, Radius : OleVariant;
begin
img := CoHImageX.Create;
Circles := CoHRegionX.Create;
tp := CoHTupleX.Create;
img.ReadImage('pads');
rg := img.Regiongrowing(3, 3, 6, 100);
rg := rg.SelectShape('area', 'and', 100, 2000);
Row := rg.SmallestCircle(Column, Radius);
Circles.GenCircle(Row, Column, Radius);
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
HWindowXCtrl1.HalconWindow.SetDraw('margin');
HWindowXCtrl1.HalconWindow.SetLineWidth(2);
HWindowXCtrl1.HalconWindow.SetGray(tp.TupleConcat(tp.TupleConcat(0, 120), 255));
img.DispObj(HWindowXCtrl1.HalconWindow);
Circles.DispObj(HWindowXCtrl1.HalconWindow);
end;
end.

05-11 21:59