zw版【转发·台湾nvp系列Delphi例程】HALCON DirectShow (Delphi Prism)

zw版【转发·台湾nvp系列Delphi例程】HALCON DirectShow (Delphi Prism)

 

 

namespace DirectShow_Prism;
interface
uses
System.Drawing,
System.Collections,
System.Collections.Generic,
System.Windows.Forms,
System.ComponentModel,
HalconDotNet;
type
/// <summary>
/// Summary description for MainForm.
/// </summary>
MainForm = partial class(System.Windows.Forms.Form)
private
method MainForm_Load(sender: System.Object; e: System.EventArgs);
method MainForm_FormClosing(sender: System.Object; e: System.Windows.Forms.FormClosingEventArgs);
method timer1_Tick(sender: System.Object; e: System.EventArgs);
method button1_Click(sender: System.Object; e: System.EventArgs);
private
var fg: HFramegrabber := new HFramegrabber();
var img: HImage;
var mtype: String := '';
var w: System.Int32;
h: System.Int32;
protected
method Dispose(disposing: Boolean); override;
public
constructor;
end;
implementation
{$REGION Construction and Disposition}
constructor MainForm;
begin
//
// Required for Windows Form Designer support
//
InitializeComponent();
//
// TODO: Add any constructor code after InitializeComponent call
//
end;
method MainForm.Dispose(disposing: Boolean);
begin
if disposing then begin
if assigned(components) then
components.Dispose();
//
// TODO: Add custom disposition code here
//
end;
inherited Dispose(disposing);
end;
{$ENDREGION}
method MainForm.MainForm_Load(sender: System.Object; e: System.EventArgs);
begin
fg.OpenFramegrabber(new HTuple('DirectShow'), new HTuple(1), new HTuple(1), new HTuple(0), new HTuple(0), new HTuple(0), new HTuple(0), new HTuple('default'), new HTuple(8), new HTuple('rgb'), new HTuple(-1), new HTuple('false'), new HTuple('default'), new HTuple('[1] ASUS USB2.0 Webcam'), new HTuple(0), new HTuple(-1))
end;
method MainForm.button1_Click(sender: System.Object; e: System.EventArgs);
begin
if button1.Text = 'Grab Start' then begin
button1.Text := 'Grab Stop';
timer1.Enabled := true
end
else begin
timer1.Enabled := false;
button1.Text := 'Grab Start'
end
end;
method MainForm.timer1_Tick(sender: System.Object; e: System.EventArgs);
begin
img := fg.GrabImage();
img.GetImagePointer1(out mtype, out w, out h);
hWindowControl1.HalconWindow.SetPart(0, 0, h - 1, w - 1);
hWindowControl1.HalconWindow.DispObj(img);
HOperatorSet.ClearObj(img);
//img.Dispose();
end;
method MainForm.MainForm_FormClosing(sender: System.Object; e: System.Windows.Forms.FormClosingEventArgs);
begin
timer1.Enabled := false;
fg.Dispose()
end;
end.

QQ群 247994767(delphi与halcon) 【zw版《delphi与halcon系列原创教程》,网址,cnblogs.com/ziwang/ 】 QQ:2592439395(zw) , delphi+halcon,图像分析神级配置, 分分钟秒杀 c+opencv,python+opencv,c+matlab, 以及其他各种组合

posted on 2021-01-13 01:22  癫狂编程  阅读(174)  评论(0编辑  收藏  举报

导航

好的代码像粥一样,都是用时间熬出来的