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

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

 

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;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
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 : HRegionX;
w , h : OleVariant;
rest : Integer;
begin
img := CoHImageX.Create;
img.ReadImage('bga_14x14_defects');
w := img.GetImageSize(h);
HWindowXCtrl1.HalconWindow.SetDraw('margin');
HWindowXCtrl1.HalconWindow.SetColor('red');
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
img.DispObj(HWindowXCtrl1.HalconWindow);
rg := img.FastThreshold(0, 120, 20);
rg.DispObj(HWindowXCtrl1.HalconWindow);
rest := rg.TestRegionPoint(76, 360);
Label2.Caption := '(76, 360) - ' + IntToStr(rest);
rest := rg.TestRegionPoint(77, 360);
Label3.Caption := '(77, 360) - ' + IntToStr(rest);
end;
end.

posted @ 2015-10-01 16:07  统领  阅读(461)  评论(0编辑  收藏  举报