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

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

unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, OleCtrls, HALCONXLib_TLB, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
HWindowXCtrl1: THWindowXCtrl;
Button1: TButton;
Timer1: TTimer;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
fg : HFramegrabberX;
op : HOperatorSetX;
img : HImageX;
mtype, w, h : OleVariant;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure PatchINT3;
var
NOP : Byte;
NTDLL: THandle;
BytesWritten: DWORD;
Address: Pointer;
begin
if Win32Platform <> VER_PLATFORM_WIN32_NT then
Exit;
NTDLL := GetModuleHandle(‘NTDLL.DLL‘);
if NTDLL = 0 then
Exit;
Address := GetProcAddress(NTDLL, ‘DbgBreakPoint‘);
if Address = nil then
Exit;
try
if Char(Address^) <> #$CC then
Exit;
NOP := $90;
if WriteProcessMemory(GetCurrentProcess, Address, @NOP, 1, BytesWritten) and (BytesWritten = 1) then
FlushInstructionCache(GetCurrentProcess, Address, 1);
except
//Do not panic if you see an EAccessViolation here, it is perfectly harmless!
on EAccessViolation do ;
else raise;
end;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
PatchINT3;
op := CoHOperatorSetX.Create;
fg := CoHFramegrabberX.Create;
fg.OpenFramegrabber(‘DirectShow‘, 1, 1, 0, 0, 0, 0, ‘default‘, 8, ‘rgb‘, -1, ‘false‘, ‘default‘, ‘[0] Logitech QuickCam for Notebooks Pro‘, 0, -1);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
if Button1.Caption = ‘Grab Start‘ then
begin
Button1.Caption := ‘Grab Stop‘;
Timer1.Enabled := True;
end
else
begin
Timer1.Enabled := False;
Button1.Caption := ‘Grab Start‘;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
img := fg.GrabImage;
img.GetImagePointer1(mType,w,h);
HWindowXCtrl1.HalconWindow.SetPart(0,0,h-1,w-1);
img.DispObj(HWindowXCtrl1.HalconWindow);
img.GenEmptyObj;
img := nil;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Timer1.Enabled := False;
op.CloseFramegrabber(fg.Handle);
fg := nil;
end;
end.

时间: 2024-10-11 04:16:20

zw版【转发·台湾nvp系列Delphi例程】HALCON DirectShow的相关文章

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON DirectFile

zw版[转发·台湾nvp系列Delphi例程]HALCON DirectFile unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, HALCONXLib_TLB, StdCtrls, ExtCtrls;type TForm1 = class(TForm) HWindowXCtrl1: THWindowXCtrl

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON CheckDifference

zw版[转发·台湾nvp系列Delphi例程]HALCON CheckDifference unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;type TForm1 = class(TForm) HWindowXCtrl1: THWindowXCtrl; But

zw版【转发&#183;台湾nvp系列Delphi例程】.NET调用HALCON COM控件内存释放模式

zw版[转发·台湾nvp系列Delphi例程].NET调用HALCON COM控件内存释放模式 ------------------------------------方法一 :Imports System.Runtime.InteropServices Marshal.ReleaseComObject(COM物件)COM 物件 = Nothing 方法二 :COM 物件 = NothingGC.Collect()GC.WaitForPendingFinalizers() 方法三 :Import

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON HImage与Bitmap格式转换

zw版[转发·台湾nvp系列Delphi例程]HALCON HImage与Bitmap格式转换 (Delphi Prism)namespace HImage_Bitmap_Prism;interfaceuses System.Drawing, System.Collections, System.Collections.Generic, System.Windows.Forms, System.ComponentModel, System.Drawing, System.Drawing.Imag

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON AddNoiseWhite

zw版[转发·台湾nvp系列Delphi例程]HALCON AddNoiseWhite unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;type TForm1 = class(TForm) HWindowXCtrl1: THWindowXCtrl; Butto

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON HWindow Overlayer 1

zw版[转发·台湾nvp系列Delphi例程]HALCON HWindow Overlayer 1 ------------------------------------HALCON HWindow Overlayer 1 unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, HALCONXLib_TLB, St

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON Component Histogram

zw版[转发·台湾nvp系列Delphi例程]HALCON Component Histogram unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, OleCtrls, HALCONXLib_TLB;type TForm1 = class(TForm) HWindowXCtrl1: THWindowXCtrl;

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON Cast 使用方式

zw版[转发·台湾nvp系列Delphi例程]HALCON Cast 使用方式 procedure TForm1.Button1Click(Sender: TObject);var img, img1 : HImageX; img2, img3 : IHUntypedObjectX; w , h : OleVariant; mtype : OleVariant;begin img := CoHImageX.Create; img.ReadImage('fabrik'); img.GetImage

zw版【转发&#183;台湾nvp系列Delphi例程】Delphi 使用 HALCON库件COM控件数据格式转换

zw版[转发·台湾nvp系列Delphi例程]Delphi 使用 HALCON库件COM控件数据格式转换 Delphi 使用 HALCON库件COM控件数据格式转换,与IHObjectX接口有关 var rg0,rg1 : HRegionX;begin rg0 := CoHRegionX.Create; rg0.GenRectangle1(10,10,150,150); rg1 := CoHRegionX.Create; rg1.GenRectangle1(200,200,250,250); r

zw版【转发&#183;台湾nvp系列Delphi例程】HALCON BinThreshold

zw版[转发·台湾nvp系列Delphi例程]HALCON BinThreshold unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, OleCtrls, HALCONXLib_TLB, StdCtrls;type TForm1 = class(TForm) Button1: TButton; HWindowXCtrl1: THW