R
rabaca
Unregistered / Unconfirmed
GUEST, unregistred user!
开始:
procedure CapSetVideoFileName( FileName : string );
begin
gCapVideoFileName := FileName;
end;
procedure CapStart;
var
achvideoFileName : array [0..255] of Char;
begin
if ghCapWnd = 0 then
exit;
StrPCopy(achvideoFileName, gCapVideoFileName);
capCaptureSequence( ghCapWnd );
end;
procedure CapSetCapSec( NofMaxVideoFrame : Integer );
begin
gdwCapNofMaxVideoFrame := DWord( NofMaxVideoFrame );
end;
(*---------------------------------------------------------------*)
(* -- 回凋函数 --- *)
(*---------------------------------------------------------------*)
function StatusCallbackProc(hWnd : HWND;
nID : Integer;
lpsz : LongInt): LongInt;
stdcall;
var
TmpStr : string;
dwVideoNum : dword;
begin
TmpStr := StrPas(PChar(lpsz));
gCapVideoInfoLabel.Caption := TmpStr;
gCapVideoInfoLabel.Refresh;
if nID = IDS_CAP_STAT_VIDEOCURRENT then
begin
dwVideoNum := StrToInt( Copy(TmpStr, 0, Pos(' ', TmpStr)-1));
if dwVideoNum >= gdwCapNofMaxVideoFrame then
begin
capCaptureAbort(ghCapWnd);
if @gCapStatusProcedure <> nil then
gCapStatusProcedure(nil);
end;
end;
Result := 1;
end;
function CapOpenDriver : Boolean;
var
Retc : LongInt;
DriverIndex : Integer;
DriverStarted : boolean;
achDeviceName : array [0..80] of Char;
achDeviceVersion : array [0..100] of Char;
achFileName : array [0..255] of Char;
begin
Result := FALSE;
if gCapVideoArea = nil then
exit;
Result := TRUE;
// 取得窗口
ghCapWnd := capCreateCaptureWindow( PChar('KruwoSoft'),
WS_CHILD or WS_VISIBLE, 0, 0,
gCapVideoArea.Width, gCapVideoArea.Height,
gCapVideoArea.Handle, 0);
if ghCapWnd <> 0 then
begin
// 装入状态回凋函数
retc := capSetCallbackOnStatus(ghCapWnd, LongInt(0));
if retc <> 0 then
begin
retc := capSetCallbackOnStatus(ghCapWnd, LongInt(@StatusCallbackProc));
if retc <> 0 then
begin
// 打开已经安装的摄像头
DriverIndex := 0;
repeat
DriverStarted := CapInitDriver( DriverIndex );
if NOT DriverStarted then
DriverIndex := DriverIndex + 1;
until (DriverStarted = TRUE) OR (DriverIndex >= MAXVIDDRIVERS);
// 维持现在的状态
if capGetDriverDescription( DriverIndex,
achDeviceName, 80,
achDeviceVersion, 100 ) then
begin
gCapVideoDriverName := string(achDeviceName);
end;
// 保存成文件 总是在打开的时候执行这个,并且retc总是为0
StrPCopy(achFileName, gCapVideoFileName);
retc := capFileSetCaptureFile(ghCapWnd, LongInt(@achFileName));
if retc = 0 then
begin
showmessage(gCapVideoDriverName+': Error in capFileSetCaptureFile');
end;
exit;
end;
end;
end;
Result := FALSE;
CapCloseDriver;
ghCapWnd := 0;
end;
procedure CapSetVideoFileName( FileName : string );
begin
gCapVideoFileName := FileName;
end;
procedure CapStart;
var
achvideoFileName : array [0..255] of Char;
begin
if ghCapWnd = 0 then
exit;
StrPCopy(achvideoFileName, gCapVideoFileName);
capCaptureSequence( ghCapWnd );
end;
procedure CapSetCapSec( NofMaxVideoFrame : Integer );
begin
gdwCapNofMaxVideoFrame := DWord( NofMaxVideoFrame );
end;
(*---------------------------------------------------------------*)
(* -- 回凋函数 --- *)
(*---------------------------------------------------------------*)
function StatusCallbackProc(hWnd : HWND;
nID : Integer;
lpsz : LongInt): LongInt;
stdcall;
var
TmpStr : string;
dwVideoNum : dword;
begin
TmpStr := StrPas(PChar(lpsz));
gCapVideoInfoLabel.Caption := TmpStr;
gCapVideoInfoLabel.Refresh;
if nID = IDS_CAP_STAT_VIDEOCURRENT then
begin
dwVideoNum := StrToInt( Copy(TmpStr, 0, Pos(' ', TmpStr)-1));
if dwVideoNum >= gdwCapNofMaxVideoFrame then
begin
capCaptureAbort(ghCapWnd);
if @gCapStatusProcedure <> nil then
gCapStatusProcedure(nil);
end;
end;
Result := 1;
end;
function CapOpenDriver : Boolean;
var
Retc : LongInt;
DriverIndex : Integer;
DriverStarted : boolean;
achDeviceName : array [0..80] of Char;
achDeviceVersion : array [0..100] of Char;
achFileName : array [0..255] of Char;
begin
Result := FALSE;
if gCapVideoArea = nil then
exit;
Result := TRUE;
// 取得窗口
ghCapWnd := capCreateCaptureWindow( PChar('KruwoSoft'),
WS_CHILD or WS_VISIBLE, 0, 0,
gCapVideoArea.Width, gCapVideoArea.Height,
gCapVideoArea.Handle, 0);
if ghCapWnd <> 0 then
begin
// 装入状态回凋函数
retc := capSetCallbackOnStatus(ghCapWnd, LongInt(0));
if retc <> 0 then
begin
retc := capSetCallbackOnStatus(ghCapWnd, LongInt(@StatusCallbackProc));
if retc <> 0 then
begin
// 打开已经安装的摄像头
DriverIndex := 0;
repeat
DriverStarted := CapInitDriver( DriverIndex );
if NOT DriverStarted then
DriverIndex := DriverIndex + 1;
until (DriverStarted = TRUE) OR (DriverIndex >= MAXVIDDRIVERS);
// 维持现在的状态
if capGetDriverDescription( DriverIndex,
achDeviceName, 80,
achDeviceVersion, 100 ) then
begin
gCapVideoDriverName := string(achDeviceName);
end;
// 保存成文件 总是在打开的时候执行这个,并且retc总是为0
StrPCopy(achFileName, gCapVideoFileName);
retc := capFileSetCaptureFile(ghCapWnd, LongInt(@achFileName));
if retc = 0 then
begin
showmessage(gCapVideoDriverName+': Error in capFileSetCaptureFile');
end;
exit;
end;
end;
end;
Result := FALSE;
CapCloseDriver;
ghCapWnd := 0;
end;