⑴ 谁有用delphi编写的用于控制摄像头录像并且保存的程序代码,发给我一个,不胜感激!越快越好……
unit ControlMonitor;
interface
uses Messages, Windows, SysUtils, Forms;
function OpenMonitor(Left, Top, Width, Height: Integer; Handle: HWND): Boolean;
function CloseMonitor(): Boolean;
function Capture(FileName: String): Boolean;
function BeginRecord(FileName: String): Boolean;
function EndRecord(): Boolean;
implementation
var
hWndC : THandle;
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;
function capCreateCaptureWindowA(lpszWindowName : PCHAR; dwStyle : longint;x : integer;y : integer;nWidth : integer; nHeight : integer;ParentWin : HWND;nId : integer): HWND; STDCALL EXTERNAL
'AVICAP32.DLL';
//打开
function OpenMonitor(Left, Top, Width, Height: Integer; Handle: HWND): Boolean;
begin
Result := False;
try
hWndC := capCreateCaptureWindowA('My Own Capture Window',
WS_CHILD or WS_VISIBLE ,
Left,
Top,
Width,
Height,
Handle,
0);
hWndC := capCreateCaptureWindowA('My Own Capture Window',
WS_CHILD or WS_VISIBLE ,
Left,
Top,
Width,
Height,
Handle,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);
Result := True;
end;
except
on E: Exception do
begin
MessageBox(Application.Handle, PChar(E.Message), '错误', MB_OK OR MB_ICONERROR);
Result := False;
end;
end;
end;
//关闭
function CloseMonitor(): Boolean;
begin
Result := False;
try
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_DRIVER_DISCONNECT, 0, 0);
hWndC := 0;
Result := True;
end;
except
on E: Exception do
begin
MessageBox(Application.Handle, PChar(E.Message), '错误', MB_OK OR MB_ICONERROR);
Result := False;
end;
end;
end;
//截图
function Capture(FileName: String): Boolean;
begin
Result := False;
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_SAVEDIB, 0, longint(pchar(FileName)));
Result := True;
end;
end;
//开始录制
function BeginRecord(FileName: String): Boolean;
begin
Result := False;
try
if hWndC <> 0 then
begin
SendMessage(hWndC,WM_CAP_FILE_SET_CAPTURE_FILEA,0, Longint(pchar(FileName)));
SendMessage(hWndC, WM_CAP_SEQUENCE, 0, 0);
Result := True;
end;
except
on E: Exception do
begin
MessageBox(Application.Handle, PChar(E.Message), '错误', MB_OK OR MB_ICONERROR);
Result := False;
end;
end;
end;
//结束录制
function EndRecord(): Boolean;
begin
Result := False;
if hWndC <> 0 then
begin
SendMessage(hWndC, WM_CAP_STOP, 0, 0);
Result := True;
end;
end;
end.
⑵ 电脑上有多个摄像头时。怎样编写一个java程序调用我指定的那个摄像头
先下载jfm安装好,里面可以里面可以看到你有哪些摄像头驱动的,还可以对每个回摄像头进行设答置
你要用java进行摄像头开发必须先下载安装jmf.
比如:
captureDeviceInfo = CaptureDeviceManager.getDevice("vfw:Microsoft WDM Image Capture (Win32):0"); // 加载驱动
这个加载的驱动名称就是和jfm中的驱动对应的,如果你有其他摄像头在jmf中可以看到驱动的,直接加载那个驱动就可以了
⑶ delphi 利用简易摄像头编写监控的程序
可能是监视界面图像需要刷新吧,每个时刻都在变化,需要调用RePaint方法。