用usb摄相头如何及时显示所摄图象? 用usb摄相头如何及时显示所摄图象,目的是用此摄相头作照象用 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ImgScan控件是C:\WINNT\system32\imgscan.ocx(win2000),(98中也有)导入得参考 if imgscan.scanneravailable then try ImgScan.FileType := 3;//BMP格式 imgscan.image := 'C:\1.BMP'; ImgScan.PageOption := 0; imgscan.startscan; ImgScan.ScanTo := 2; except MessageDlg('您的外部设备没有打开,无法进行本次操作!' + chr(13) + '请退出本管理系统,待扫描仪打开后再进入,即可使用!', mtInformation, [mbOk], 0); Abort; end; 我用如此方法得到一帧一帧的相片,请高指点如何将图像动态地显示在我控制的窗体内,实现方法如下unit mainfrm;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, OleCtrls, ScanLibCtl_TLB;type TForm1 = class(TForm) Panel1: TPanel; OpenVideo: TButton; CloseVideo: TButton; GrabFrame: TButton; SaveBMP: TButton; StartAVI: TButton; StopAVI: TButton; SaveDialog1: TSaveDialog; Button1: TButton; ImgScan: TImgScan; procedure FormCreate(Sender: TObject); procedure OpenVideoClick(Sender: TObject); procedure CloseVideoClick(Sender: TObject); procedure GrabFrameClick(Sender: TObject); procedure SaveBMPClick(Sender: TObject); procedure StartAVIClick(Sender: TObject); procedure StopAVIClick(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } hWndC : THandle; CapturingAVI : bool; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}const 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';procedure TForm1.FormCreate(Sender: TObject);begin CapturingAVI := false; hWndC := 0; SaveDialog1.Options :=[ofHideReadOnly, ofNoChangeDir, ofPathMustExist]end;procedure TForm1.OpenVideoClick(Sender: TObject);beginhWndC := capCreateCaptureWindowA('My Own Capture Window',WS_CHILD or WS_VISIBLE ,Panel1.Left,Panel1.Top,Panel1.Width,Panel1.Height,Form1.Handle,0);if hWndC <> 0 thenSendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);end;procedure TForm1.CloseVideoClick(Sender: TObject);beginif hWndC <> 0 then beginSendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);hWndC := 0;end;end;procedure TForm1.GrabFrameClick(Sender: TObject);beginif hWndC <> 0 thenSendMessage(hWndC, WM_CAP_GRAB_FRAME, 0, 0); end;procedure TForm1.SaveBMPClick(Sender: TObject);beginif hWndC <> 0 then beginSaveDialog1.DefaultExt := 'bmp'; SaveDialog1.Filter := 'Bitmap files (*.bmp)|*.bmp'; if SaveDialog1.Execute then SendMessage(hWndC,WM_CAP_SAVEDIB,0,longint(pchar(SaveDialog1.FileName)));end;end;procedure TForm1.StartAVIClick(Sender: TObject);beginif hWndC <> 0 then begin SaveDialog1.DefaultExt := 'avi'; SaveDialog1.Filter := 'AVI files (*.avi)|*.avi'; if SaveDialog1.Execute then beginCapturingAVI := true; SendMessage(hWndC, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, Longint(pchar(SaveDialog1.FileName))); SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0); end; end;end;procedure TForm1.StopAVIClick(Sender: TObject);beginif hWndC <> 0 then begin SendMessage(hWndC, WM_CAP_STOP, 0, 0); CapturingAVI := false; end;end; 留下Email发给你一个Demo程序---------^^! http://expert.csdn.net/Expert/topic/2340/2340132.xml?temp=.3537104 cdsoftwarewj: 您好! ),我在此多谢你啦。 http://218.56.11.178:8020/web/index.aspx-》软件基地 -》源码-》delphi/kylix->视频技术相关源码 delphi中 Combox下拉列表問題 怎样才能让FastReport_v2.53和TeeChart7一起使用? 关于随机数的一个算法求教!thx 我的代码错在哪里呢? 动态生成按钮的点击事件 关于ShowModal窗口的一点疑问??在线等待! 怎样替换tstings中的一个字符串? 请教用Dephi6.0把文本数据导入SQL Server2000中? 求救:打印报表问题---主要是表头表尾的设定.200分,绝对结帖 使用mediaplayer播放mp3时,如何控制左右声道的问题?高手请关注!!! 基本语法问题! 如何解决在Timage中连续绘制图形的闪烁问题(救急)
if imgscan.scanneravailable then
try
ImgScan.FileType := 3;//BMP格式
imgscan.image := 'C:\1.BMP';
ImgScan.PageOption := 0;
imgscan.startscan;
ImgScan.ScanTo := 2;
except
MessageDlg('您的外部设备没有打开,无法进行本次操作!' + chr(13) +
'请退出本管理系统,待扫描仪打开后再进入,即可使用!', mtInformation,
[mbOk],
0);
Abort;
end;
unit mainfrm;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, OleCtrls, ScanLibCtl_TLB;type
TForm1 = class(TForm)
Panel1: TPanel;
OpenVideo: TButton;
CloseVideo: TButton;
GrabFrame: TButton;
SaveBMP: TButton;
StartAVI: TButton;
StopAVI: TButton;
SaveDialog1: TSaveDialog;
Button1: TButton;
ImgScan: TImgScan;
procedure FormCreate(Sender: TObject);
procedure OpenVideoClick(Sender: TObject);
procedure CloseVideoClick(Sender: TObject);
procedure GrabFrameClick(Sender: TObject);
procedure SaveBMPClick(Sender: TObject);
procedure StartAVIClick(Sender: TObject);
procedure StopAVIClick(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
hWndC : THandle;
CapturingAVI : bool;
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}const 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';procedure TForm1.FormCreate(Sender: TObject);
begin
CapturingAVI := false;
hWndC := 0;
SaveDialog1.Options :=[ofHideReadOnly, ofNoChangeDir, ofPathMustExist]
end;procedure TForm1.OpenVideoClick(Sender: TObject);
begin
hWndC := capCreateCaptureWindowA('My Own Capture Window',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;procedure TForm1.SaveBMPClick(Sender: TObject);
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;procedure TForm1.StartAVIClick(Sender: TObject);
begin
if hWndC <> 0 then begin
SaveDialog1.DefaultExt := 'avi';
SaveDialog1.Filter := 'AVI files (*.avi)|*.avi';
if SaveDialog1.Execute then begin
CapturingAVI := true;
SendMessage(hWndC,
WM_CAP_FILE_SET_CAPTURE_FILEA,
0,
Longint(pchar(SaveDialog1.FileName)));
SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
end;
end;
end;procedure TForm1.StopAVIClick(Sender: TObject);
begin
if hWndC <> 0 then begin
SendMessage(hWndC, WM_CAP_STOP, 0, 0);
CapturingAVI := false;
end;
end;
^^!
),我在此多谢你啦。