视频采集中,为何保存位图后,采集窗口会停下来?(100分)

  • 主题发起人 主题发起人 whitecloud
  • 开始时间 开始时间
W

whitecloud

Unregistered / Unconfirmed
GUEST, unregistred user!
视频采集中,为何保存位图后,采集窗口会停下来?
unit Main;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
AviCapH, StdCtrls, ExtCtrls,clipbrd;

type
TForm1 = class(TForm)
Button3: TButton;
SaveDialog2: TSaveDialog;
Panel2: TPanel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
CapHandle:THandle;
CaptureParms:TCaptureParms;
procedure CreateCaptureWindow;
public
{ Public declarations }
end;

var
FrameCount : Integer = 0;
Form1: TForm1;
function OnStatus(hWnd:THandle; nID:Integer;lpStatusText:PChar):Boolean;stdcall;
function OnError(hWnd:THandle; nErrorID:Integer;lpErrorText:PChar):Boolean;stdcall;
function OnYield(hWnd:THandle):Boolean;stdcall;

implementation

{$R *.DFM}
procedure TForm1.CreateCaptureWindow;
begin
CapHandle :=capCreateCaptureWindowA('',WS_VISIBLE+WS_CHILD+WS_BORDER,0,0,Panel2.Width,Panel2.Height,Panel2.Handle,0);
capCaptureGetSetup(CapHandle,Longint(@CaptureParms),Sizeof(TCaptureParms));
with CaptureParms do
begin
dwRequestMicroSecPerFrame := 66667;
fMakeUserHitOKToCapture := False;
fAbortLeftMouse := True;
fAbortRightMouse := True;
dwIndexSize := 34952;
vKeyAbort := 27;
end;
capSetCallbackOnStatus(CapHandle,Longint(@OnStatus));
capSetCallbackOnError(CapHandle,Longint(@OnError));
capSetCallbackOnYield(CapHandle,Longint(@OnYield));
capDriverConnect (CapHandle,0);
capOverlay(CapHandle,Longint(True));
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if AviCap1.cap_Connected then
AviCap1.cap_Connected := False;
end;

procedure TForm1.Button3Click(Sender: TObject);
var
BitMap : TBitMap;
i : Integer;
FileName:array [0..50] of Char;
begin
if not SaveDialog1.Execute then
Exit;
StrPCopy(FileName,SaveDialog1.FileName);
capFileSaveDIB(CapHandle,LongInt(@FileName));
////////////////////////////////////////////////////////////////////////////////////
//????为何此后采集窗口会停下来,而切换窗口后(或用户有其它动作)又会恢复动态显示????//
/////////////////////////////////////////////////////////////////////////////////////
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
SaveDialog1.InitialDir := ExtractFilePath(Application.ExeName);
CreateCaptureWindow;
end;

end.
 

StrPCopy(FileName,SaveDialog1.FileName);
capFileSaveDIB(CapHandle,LongInt(@FileName));
你只要加上一行就可以了:

CapSetVideoLive;




 
pengyt:
找遍API中也没CapSetVideoLive这个函数呀!
 
CapSetVideoLive不是api
其实是以下的这串调用
procedure CapSetVideoLive;
begin
if ghCapWnd = 0 then exit;
capOverlay(ghCapWnd, 0);
capPreviewScale(ghCapWnd, 1);
capPreviewRate(ghCapWnd, MS_FOR_25FPS);
capPreview(ghCapWnd, 1);
end;

这些其实都是VFW提供的标准功能,只是封装
了些消息的发送就像 capPreviewScale这样.
function capPreviewScale(hwnd:THandle; f:Word):LongInt;
begin
Result := SendMessage(hwnd, WM_CAP_SET_SCALE, f, 0);
end;
 
如果你需要,我可以给一个例子你: 给我你的邮箱
 
pengyt:
十分感谢,我的地址是baino1@163.net .
 
再次感谢pengyt!
 
多人接受答案了。
 
后退
顶部