使用的代码如下:
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Panel1: TPanel;
OpenVideo: TButton;
CloseVideo: TButton;
GrabFrame: TButton;
procedure FormCreate(Sender: TObject);
procedure OpenVideoClick(Sender: TObject);
procedure CloseVideoClick(Sender: TObject);
procedure GrabFrameClick(Sender: TObject);
private
{ Private declarations }
hWndC : THandle;
CapturingAVI : bool;
public
{ Public declarations }
end;var
Form1: TForm1;implementationconst WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START + 68;
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;function capCreateCaptureWindowA(lpszWindowName : PCHAR;
dwStyle : longint;
x : integer;
y : integer;
nWidth : integer;
nHeight : integer;
ParentWin : HWND;
nId : integer): HWND;
STDCALL EXTERNAL 'AVICAP32.DLL';{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
hWndC := 0;
end;procedure TForm1.OpenVideoClick(Sender: TObject);
// 打开视频窗口
begin
hWndC := capCreateCaptureWindowA('自己的显示窗口',
WS_CHILD or WS_VISIBLE ,
Panel1.Left,
Panel1.Top,
Panel1.Width,
Panel1.Height,
Form1.Handle,
0);
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
end;
{上面代码以将摄像头上的图像传到屏幕上。}procedure TForm1.CloseVideoClick(Sender: TObject);
// 关闭视频窗口
begin
if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
end;procedure TForm1.GrabFrameClick(Sender: TObject);
// 拍照(一张)
begin
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0);
end;end.
现在如何反照片存入文件夹中????
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls;type
TForm1 = class(TForm)
Panel1: TPanel;
OpenVideo: TButton;
CloseVideo: TButton;
GrabFrame: TButton;
procedure FormCreate(Sender: TObject);
procedure OpenVideoClick(Sender: TObject);
procedure CloseVideoClick(Sender: TObject);
procedure GrabFrameClick(Sender: TObject);
private
{ Private declarations }
hWndC : THandle;
CapturingAVI : bool;
public
{ Public declarations }
end;var
Form1: TForm1;implementationconst WM_CAP_START = WM_USER;
const WM_CAP_STOP = WM_CAP_START + 68;
const WM_CAP_DRIVER_CONNECT = WM_CAP_START + 10;
const WM_CAP_DRIVER_DISCONNECT = WM_CAP_START + 11;
const WM_CAP_SAVEDIB = WM_CAP_START + 25;
const WM_CAP_GRAB_FRAME = WM_CAP_START + 60;
const WM_CAP_SEQUENCE = WM_CAP_START + 62;
const WM_CAP_FILE_SET_CAPTURE_FILEA = WM_CAP_START + 20;function capCreateCaptureWindowA(lpszWindowName : PCHAR;
dwStyle : longint;
x : integer;
y : integer;
nWidth : integer;
nHeight : integer;
ParentWin : HWND;
nId : integer): HWND;
STDCALL EXTERNAL 'AVICAP32.DLL';{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
hWndC := 0;
end;procedure TForm1.OpenVideoClick(Sender: TObject);
// 打开视频窗口
begin
hWndC := capCreateCaptureWindowA('自己的显示窗口',
WS_CHILD or WS_VISIBLE ,
Panel1.Left,
Panel1.Top,
Panel1.Width,
Panel1.Height,
Form1.Handle,
0);
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
end;
{上面代码以将摄像头上的图像传到屏幕上。}procedure TForm1.CloseVideoClick(Sender: TObject);
// 关闭视频窗口
begin
if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
end;
end;procedure TForm1.GrabFrameClick(Sender: TObject);
// 拍照(一张)
begin
if hWndC <> 0 then
SendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0);
end;end.
现在如何反照片存入文件夹中????
解决方案 »
- 怎么算得一个比某个时间多N分钟的TDateTime
- spcomm数据位8,停止位1,波特率是4800,或者是1200,的,校验位是无校验,接受数据是乱码,
- ado访问access数据库问题
- 51delphi怎么连不上啊?哪里有镜像没??
- 紧急!!!!求助!!!!
- 怎样存取类似(#28,#27,#30......)之类的字符数据?
- 如何取得创建的BUTTON 的消息?
- 在北京找工作,除了发e-mail就没有其他的办法吗?
- 如何把数据库中的blob字段的内容保存为html格式的文件?
- 能否提供一些关于用CREATE TABLE #表名创建临时表的资料?谢谢
- 有两三个LISTVIEW,拖动时,怎样判断是哪一个LISTVIEW拖过来的?
- 谁知道Excel文件的存储格式
begin
if hWndC <> 0 then begin
SaveDialog1.DefaultExt := 'bmp';
SaveDialog1.Filter := 'Bitmap files (*.bmp)|*.bmp';
if SaveDialog1.Execute then
SendMessage(hWndC,
WM_CAP_SAVEDIB,
0,
longint(pchar(SaveDialog1.FileName)));
end;
end;
就是SendMessage(hWndC,WM_CAP_EDIT_COPY,0,0)不懂得怎么用,(SendMessage里面的参数是什么意思呢?)
不知如何把它保存到文件夹中呢!