當前位置:編程學習大全網 - 編程語言 - 利用Delphi編輯控制攝像頭(二)

利用Delphi編輯控制攝像頭(二)

完整的程序代碼如下

unit Unit ;interfaceusesWindows Messages SysUtils Variants Classes Graphics Controls Forms Dialogs StdCtrls ExtCtrls;typeTForm = class(TForm)Panel : TPanel;Button : TButton;Button : TButton;Button : TButton;Button : TButton;Button : TButton;procedure Button Click(Sender: TObject);procedure Button Click(Sender: TObject);procedure Button Click(Sender: TObject);procedure Button Click(Sender: TObject);procedure Button Click(Sender: TObject);procedure FormClose(Sender: TObject; var Action: TCloseAction);privatehWndC : THandle;public{ Public declarations }end;varForm : TForm ;const WM_CAP_START = WM_USER;const WM_CAP_STOP = WM_CAP_START + ;const WM_CAP_DRIVER_CONNECT = WM_CAP_START + ;const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + ;const WM_CAP_SAVEDIB = WM_CAP_START + ;const WM_CAP_GRAB_FRAME = WM_CAP_START + ;const WM_CAP_SEQUENCE = WM_CAP_START + ;const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + ;const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ const WM_CAP_SET_OVERLAY =WM_CAP_START+ const WM_CAP_SET_PREVIEW =WM_CAP_START+ const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START + ;const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START + ;const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START + ;const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START + ;const WM_CAP_SET_SCALE=WM_CAP_START+ const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ function capCreateCaptureWindowA(lpszWindowName : PCHAR;dwStyle : longint;x : integer;y : integer;nWidth : integer;nHeight : integer;ParentWin : HWND;nId : integer): HWND;STDCALL EXTERNAL AVICAP DLL ;implementation{$R * dfm}procedure TForm Button Click(Sender: TObject);beginhWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle );hWndC := capCreateCaptureWindowA( My Own Capture Window WS_CHILD or WS_VISIBLE Panel Left Panel Top Panel Width Panel Height Form Handle );if hWndC <> thenbeginSendMessage(hWndC WM_CAP_SET_CALLBACK_VIDEOSTREAM );SendMessage(hWndC WM_CAP_SET_CALLBACK_ERROR );SendMessage(hWndC WM_CAP_SET_CALLBACK_STATUSA );SendMessage(hWndC WM_CAP_DRIVER_CONNECT );SendMessage(hWndC WM_CAP_SET_SCALE );SendMessage(hWndC WM_CAP_SET_PREVIEWRATE );SendMessage(hWndC WM_CAP_SET_OVERLAY );SendMessage(hWndC WM_CAP_SET_PREVIEW );end;end;procedure TForm Button Click(Sender: TObject);beginif hWndC <> then beginSendMessage(hWndC WM_CAP_DRIVER_DISCONNECT );hWndC := ;end;end;procedure TForm Button Click(Sender: TObject);beginif hWndC <> then beginSendMessage(hWndC WM_CAP_SAVEDIB longint(pchar( c:\test bmp )));end;end;procedure TForm Button Click(Sender: TObject);beginif hWndC <> thenbeginSendMessage(hWndC WM_CAP_FILE_SET_CAPTURE_FILEA Longint(pchar( c:\test avi )));SendMessage(hWndC WM_CAP_SEQUENCE );end;end;procedure TForm Button Click(Sender: TObject);beginif hWndC <> then beginSendMessage(hWndC WM_CAP_STOP );end;end;procedure TForm FormClose(Sender: TObject; var Action: TCloseAction);beginif hWndC <> then beginSendMessage(hWndC WM_CAP_DRIVER_DISCONNECT );end;end;end

如果電腦沒有攝像頭 但又想看看程序的效果 可以麽?

當然可以 找個虛擬攝像頭不就搞定 大家可以試試SoftCam這個軟件 它是壹個名副其實的軟件攝像機 能模擬成為 真實的 攝像機 提醒壹下各位 大家可不要用這個東東用在QQ MSN等聊天軟件上欺騙MM或GG啊

關於攝像頭編程 大家也可以看看這組VCL組件 DSPack DSPack是壹套使用微軟Direct Show和DirectX技術的類和組件 設計工作於DirectX 支持系統Win X ME 和Windows XP

lishixinzhi/Article/program/Delphi/201311/24709

  • 上一篇:風雷打板是誰
  • 下一篇:輸出的近義詞輸出的近義詞是什麽
  • copyright 2024編程學習大全網