zw版【转发·*nvp系列Delphi例程】HALCON RegionToBin2

时间:2023-12-21 18:12:32

zw版【转发·*nvp系列Delphi例程】HALCON RegionToBin2

zw版【转发·*nvp系列Delphi例程】HALCON RegionToBin2

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;
HWindowXCtrl2: THWindowXCtrl;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
img : HUntypedObjectX;
rg : HUntypedObjectX;
op : HOperatorSetX;
w, h : OleVariant;
begin
op := CoHOperatorSetX.Create;
op.ReadImage(img, 'circle_plate');
op.GetImageSize(img, w, h);
HWindowXCtrl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
op.DispObj(img, HWindowXCtrl1.HalconWindow.HalconID);
op.Threshold(img, rg,0, 60);
op.RegionToBin(rg, img, 128, 0, w, h);
HWindowXCtrl2.HalconWindow.SetPart(0, 0, h - 1, w - 1);
op.DispObj(img, HWindowXCtrl2.HalconWindow.HalconID);
end;
end.