在delphi中 如何实现 USB摄像头捕获视频显示?

椰子天涯 2010-11-26 08:54:28
delphi中USB摄像头捕获视频显示程序 思路 或是有源码可以参考最好 不胜感激~~
...全文
504 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
椰子天涯 2010-11-29
  • 打赏
  • 举报
回复
谢谢大家 我再看看
smile_ps 2010-11-27
  • 打赏
  • 举报
回复
做个标记先。回去慢慢研究。
xjq2003 2010-11-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 easyboot 的回复:]
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,Directshow9;

type
TForm1 = class(TForm)
Button1: ……
[/Quote]试一下
wlm_8888 2010-11-27
  • 打赏
  • 举报
回复
可以用directx库写,也可以用opencv库,还可以用做好的控件dspack,控件可以到www.2ccc.com下载,里面有demo,很容易就可以看懂
  • 打赏
  • 举报
回复
有个现成的工具,ImageEN
椰子天涯 2010-11-26
  • 打赏
  • 举报
回复
哇 谢谢哦 我试试看 能给我说一下思路吗?
easyboot 2010-11-26
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls,Directshow9;

type
TForm1 = class(TForm)
Button1: TButton;
Panel1: TPanel;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Button5: TButton;
Button6: TButton;
Button7: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure Panel1Click(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
private
{ Private declarations }
hWndC : THandle; //定义捕捉窗句柄
public
{ Public declarations }
end;

var
Form1: TForm1;
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;
const WM_CAP_SEQUENCE_NOFILE =WM_CAP_START+ 63;
const WM_CAP_SET_OVERLAY =WM_CAP_START+ 51;
const WM_CAP_SET_PREVIEW =WM_CAP_START+ 50;
const WM_CAP_SET_CALLBACK_VIDEOSTREAM = WM_CAP_START +6;
const WM_CAP_SET_CALLBACK_ERROR=WM_CAP_START +2;
const WM_CAP_SET_CALLBACK_STATUSA= WM_CAP_START +3;
const WM_CAP_SET_CALLBACK_FRAME= WM_CAP_START +5;
const WM_CAP_SET_SCALE=WM_CAP_START+ 53;
const WM_CAP_SET_PREVIEWRATE=WM_CAP_START+ 52;
const WM_CAP_DLG_VIDEOFORMAT =WM_CAP_START+ 41;
const WM_CAP_DLG_VIDEOSOURCE =WM_CAP_START+ 42; //1066 打开属性设置对话框,设置对比度、亮度等。
const WM_CAP_DLG_VIDEODISPLAY = WM_CAP_START + 43;
//const WM_CAP_SET_SCALE =WM_CAP_START+ 53; //设置刻度

function capCreateCaptureWindowA(lpszWindowName : PCHAR;
dwStyle : longint;x : integer;y : integer;nWidth : integer;
nHeight : integer;ParentWin : HWND;nId : integer): HWND;
STDCALL EXTERNAL 'AVICAP32.DLL';
implementation

{$R *.dfm}
//uses Directshow9;

function devwdm_SetVideoStandard(nID:longlong;VideoStandard:LONGLONG):LONGLONG;stdcall;external 'devwdm.dll';
function devwdm_InitCard(nID:longlong;handle:THandle;nWidth:integer;nHeight:integer):LONGLONG;stdcall;external 'devwdm.dll';
function devwdm_StartVideoPreview(nID:longlong):LONGLONG;stdcall;external 'devwdm.dll';

procedure TForm1.Button1Click(Sender: TObject);
begin
//使用Tpanel控件来创建捕捉窗口
hWndC:=CapCreateCaptureWindowA ('My Own Capture Window',WS_CHILD or WS_VISIBLE, //窗口样式
Panel1.Left,//X坐标
Panel1.Top,//Y坐标
panel1.Width, //窗口宽
panel1.Height, //窗口高
Form1.Handle, //窗口句柄
0); //一般为0
if hWndC <> 0 then
begin



SendMessage(hWndC, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, 0);
//捕捉一个视频流
SendMessage(hWndC, WM_CAP_SET_CALLBACK_ERROR, 0, 0); //得到一个设备错误
SendMessage(hWndC, WM_CAP_SET_CALLBACK_STATUSA, 0, 0); //得到一个设备状态
SendMessage(hWndC, WM_CAP_DRIVER_CONNECT, 0, 0);
//将一个捕捉窗口与一个设备驱动相关联
SendMessage(hWndC, WM_CAP_SET_SCALE, 1, 0);
SendMessage(hWndC, WM_CAP_SET_PREVIEWRATE, 66, 0);
SendMessage(hWndC, WM_CAP_SET_OVERLAY, 1, 0);
SendMessage(hWndC, WM_CAP_SET_PREVIEW, 1, 0);
end;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); //将捕捉窗同驱动器断开
hWndC := 0;
end;
//close;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0); //将捕捉窗同驱动器断开
end;
end;

procedure TForm1.Button3Click(Sender: TObject);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0,Longint(pchar('d:\test.avi')));// 录成AVI
SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
end;
end;

procedure TForm1.Button4Click(Sender: TObject);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_STOP, 0, 0);
end;
end;

procedure TForm1.Button5Click(Sender: TObject);
begin
if hWndC <> 0 then
begin
SendMessage(hWndC,WM_CAP_SAVEDIB,0,longint(pchar('D:\test.bmp')));//截图
end;
end;

procedure TForm1.Panel1Click(Sender: TObject);
begin
panel1.Height:=Panel1.Height+10;
Panel1.Width:=Panel1.Width+10;
end;

procedure TForm1.Button6Click(Sender: TObject);
//var CaptureParms :CAPTUREPARMS ;
begin
SendMessage(hWndC, WM_CAP_DLG_VIDEOSOURCE, 0, 0);
end;

procedure TForm1.Button7Click(Sender: TObject);
begin
SendMessage(hWndC, WM_CAP_DLG_VIDEOFORMAT, 0, 0);
end;

end.
椰子天涯 2010-11-26
  • 打赏
  • 举报
回复
谢谢大家 三楼的jianaixhb能麻烦你给把源码给我发邮箱里吗?我没有找到资源下载 我的邮箱是492548101@qq.com
sunli_py 2010-11-26
  • 打赏
  • 举报
回复
有专门的控件
xhj12077021 2010-11-26
  • 打赏
  • 举报
回复
做下标记
jianaixhb 2010-11-26
  • 打赏
  • 举报
回复
这个资源我上传过,你可以去下载啊

828

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 非技术区
社区管理员
  • 非技术区社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧