话题166731的标题是: 用delphi完成摄像头的图像捕捉(讲讲原理也可) (100分)
分类:多媒体 yaoydong (1999-12-09 20:10:00)
如题,本人近期要完成一个项目,其中有一个功能就是需要捕捉摄像头的图像
各位大虾指点一二
cAkk (1999-12-09 20:24:00)
好像以前有过类似问题....肯定有.
Hexi (1999-12-09 20:27:00)
可以用Avicap32.dll,Windows自带的Dll,在深度历险中可以找到一个控件,
其中带了VFW.Pas文件,包含了所有avicap32.dll的声明,或在VC中找
VFW.H,将其翻译成Pas就可以用了。VC中有一个例子captest就是实现此功能的。(视
频捕捉,需要视霸卡)将扑捉的图象存为AVI文件。
Hexi (1999-12-09 20:30:00)
还提供了回调(callback)功能,在每捕获一帧后可以自己处理数据。
yaoyao (1999-12-09 21:23:00)
有一个控件前两天刚用过,效果很好,
如果要的话让我找找可以把源程序都给你.
天外客 (1999-12-09 21:28:00)
r
yh (1999-12-09 22:36:00)
to yaoyao,能否给我一份找过但没找到。
yhnew@163.net
CJ (1999-12-09 23:00:00)
`
yaoydong (1999-12-10 11:36:00)
yaoyao(都以为是自己的名字了)呵呵,
能否把那个发给我,谢了
yaoydong (1999-12-11 19:04:00)
现在我用的是D5,发现那个AVICAP21因为.DCR的问题装不起来,不知道各位有没有在
D5下装过.
BTW;其实我要完成的功能就是从摄像头取得图像在屏幕显示,然后按下某键把当前图像存下来.各位给给意见吧.
Hexi (1999-12-12 13:24:00)
有一个带源码的控件,你到历险中找找吧。
你可以参考vc中的例子直接调用API.
Hexi (1999-12-12 13:26:00)
我这有源代码,如果要我发给你。
CJ (1999-12-12 14:52:00)
hexi: please mailto:cjcjc@online.sh.cn
yaoydong (1999-12-13 9:10:00)
to Hexi:
把那个控件发过来吧,<a href="mailto:b964711@njupt.edu.cn">这里</a>
cAkk (1999-12-13 10:16:00)
我也有一个,不过没测试过:
<h2>Source for Video Capture</h2>
<p>
</b><pre>unit vidcap;
interface
type
capturerec = record
dwRequestMicroSecPerFrame: longint;
fMakeUserHitOKToCapture: wordbool;
wPercentDropForError: word;
fYield: wordbool;
dwIndexSize: longint;
wChunkGranularity: word;
fUsingDOSMemory: wordbool;
wNumVideoRequested: word;
fCaptureAudio: wordbool;
wNumAudioRequested: word;
vKeyAbort: word;
fAbortLeftMouse: wordbool;
fAbortRightMouse: wordbool;
fLimitEnabled: wordbool;
wTimeLimit: word;
fMCIControl: wordbool;
fStepMCIDevice: wordbool;
dwMCIStartTime: longint;
dwMCIStopTime: longint;
fStepCaptureAt2x: wordbool;
wStepCaptureAverageFrames: word;
dwAudioBufferSize: longint;
fDisableWriteCache: wordbool;
AVStreamMaster: word;
end;
procedure InitVariables;
function CreateVideo: integer;
procedure CreateCapWin;
procedure ShowCapWin;
procedure HideCapWin;
procedure KillCapWin;
procedure ShowVideoParamsWindow;
procedure ShowCompressionWindow;
procedure UserMessage(msg: string);
function StreamCallback(wnd: THandle;
vh: longint): wordbool;
export;
var
framespersec,
framecount,
framestopcount: integer;
videofilename: string;
cparams,
captureparams: capturerec;
implementation
{
this prototype needs to be listed to access the AVICAP function
}
function capCreateCaptureWindow(var lpszWindowName;
dwStyle: longint;
x: integer;
y: integer;
nWidth: integer;
nHeight: integer;
anhwnd: THandle;
nID: integer): THandle;
far;
external 'avicap';
procedure InitVariables;
begin
{ This is used by the callback to auto-stop after the given
number of frames have been captured. }
framestopcount := 0;
{ AVICAP will default to creating the file CAPTURE.AVI in the
root directory of the drive the program is called from. This
variable can store a path/name so that you have some better
control over where it gets captured to. }
videofilename := 'c:/mydir/testcap.avi';
{ The frame capture rate is dependant on many conditions. These
are addressed in the article. For now, we'll set it to MAX. }
framespersec := 30;
end;
procedure CreateVideo;
begin
InitVariables;
CreateCapWin;
{ Delete any capture file if it exists }
if(FileExists(videofilename)) then
DeleteFile(videofilename);
{ There are no frames captured yet }
framecount := 0;
{ Tell AVICAP to begin
capturing }
smreturn := SendMessage(hWndC, WM_USER + 62, 0, 0);
KillCapWin;
end;
{
Callback from AVICAP.DLL... every frame that gets captured
generates a function call from AVICAP. In this case we are
using it strictly to count the number of captured frames.
This callback gets initialized by CreateCapWin().
}
function StreamCallback(wnd: THandle;
vh: longint): wordbool;
begin
if(framestopcount > 0) then
begin
inc(framecount);
{ note the frame number }
if(framecount > framestopcount ) then
{ Tell AVICAP to abort the operation. }
SendMessage(hWndC, WM_USER + 69, 0, 0);
end;
{ Reassure AVICAP that all is OK. }
result := wordbool(1);
end;
{
This procedure creates the capture window and initializes
all of the capture parameters.
}
procedure CreateCapWin;
var
capavi: array[0..40] of char;
captit: array[0..40] of char;
smreturn: longint;
apntr: pointer;
asize: integer;
begin
{
STEP 1: INIT THE CAPTURE WINDOW AND GET CONNECTED TO
THE DRIVER
}
strpcopy(capavi, videofilename);
{ captured video file name }
strpcopy(captit, 'capture win');
{ capture window }
(*
SEE THE ARTICLE TEXT ABOUT THE FOLLOWING WINDOW CREATION ROUTINE
*)
hWndC := capCreateCaptureWindow ( captit, WS_CHILD or WS_VISIBLE, 0, 0,
320, 240, main.handle, 0);
ShowWindow(hWndC, SW_SHOW);
{ Tell AVICAP to connect to the Capture driver. }
smreturn := SendMessage(hWndC, WM_USER + 10, 0, 0);
if(smreturn <> 0) then
begin
usermessage( 'Connected' );
{ feedback }
{ tell AVICAP what the name of the file to capture to is }
apntr := addr(capavi);
SendMessage(hWndC, WM_USER + 20, 0, longint(apntr));
{ STEP 2: SET IMAGE PREVIEW UP }
{ Set preview rate at 30 frames per second, in mSec.
1000 mSec/30 frames = 33 mSec. }
SendMessage(hWndC, WM_USER + 52, 33, 0);
{ Now go ahead and preview }
SendMessage(hWndC, WM_USER + 50, 1, 0);
{ STEP 3: INITIALIZE CAPTURE PARAMETERS }
{ First, the capture parameters structure gets initialized
by asking AVICAP to fill it in for us. }
apntr := addr(captureparams);
asize := sizeof(captureparams);
SendMessage(hWndC, WM_USER + 65, asize, longint(apntr));
{ then
start setting up the preferences: }
{ 1 = capture audio, 0 = disable }
captureparams.fCaptureAudio := wordbool(0);
(*
The time limit params are used to force a stop of the
video capture at a specified time, just in case
anything goes wrong. The params here are filled out
to stop capture automatically after 15 seconds just
for the sake of illustration.
*)
{ 1 = enable time limiting, 0 = disable }
captureparams.fLimitEnabled := wordbool(1);
{ In this case, 15 seconds of video, translated to hex }
captureparams.wTimeLimit := word($0E);
{ max error rate = 1%. This is somewhat hardware dependant. }
captureparams.wPercentDropForError := 1;
{ these are the most common frame rates }
if(framespersec = 30) then
captureparams.dwRequestMicroSecPerFrame := 33334 { 30 fps }
else
captureparams.dwRequestMicroSecPerFrame := 41667;
{ 24 fps }
{ 0 = automatic mode, 1 = put up an OK button to initiate }
captureparams.fMakeUserHitOKToCapture := wordbool(0);
{ 1 = abort capture on Left button click, 1 = disable }
captureparams.fAbortLeftMouse := wordbool(0);
{ 1 = abort capture on Right button click, 1 = disable }
captureparams.fAbortRightMouse := wordbool(0);
{ escape key aborts capturing }
captureparams.vKeyAbort := VK_ESCAPE;
(*
These parameters are listed but aren't required for general
purpose video capture. Refer to the Win32 SDK discussion of
AVICAP to see if your intended application will be affected.
captureparams.wChunkGranularity := 0;
captureparams.dwIndexSize := 0;
captureparams.fUsingDOSMemory := byte(0);
{do
n't usedo
S memory }
captureparams.fStepMCIDevice := 0;
captureparams.fMCIControl := 0;
captureparams.fStepCaptureAt2x := 0;
captureparams.fDisableWriteCache := byte(0);
captureparams.wStepCaptureAverageFrames := 3;
*)
{ Now write the capture parameters }
apntr := addr(captureparams);
asize := sizeof(captureparams);
SendMessage(hWndC, WM_USER + 64, asize, longint(apntr));
{ tell AVICAP where to find the framecount callback }
SendMessage(hWndC, WM_USER + 6, 0, longint(addr(StreamCallback)));
end else
begin
usermessage( 'Invalid video driver.');
killcapwin;
{ just to be safe. It *is* windows, after all... }
end;
end;
{ show the capture window (including the live video) }
procedure ShowCapWin;
begin
ShowWindow(hWndC, SW_SHOW);
end;
{ hide the capture window }
procedure HideCapWin;
begin
ShowWindow(hWndC, SW_HIDE);
end;
{ destroy the capture window used by AVICAP }
procedure KillCapWin;
begin
ShowWindow(hWndC, SW_HIDE);
DestroyWindow(hWndC);
end;
{ Show the video format dialog. This is supplied by
the capture driver. All we need todo
is tell
AVICAP to make the proper call to the driver. }
procedure ShowVideoParamsWindow;
begin
ShowCapWin;
SendMessage(hWndC, WM_USER + 41, 0, 0);
{ allow this to happen }
application.processmessages;
HideCapWin;
end;
{ Show the video compression options dialog supplied by the
capture driver. This works like the ShowVideoParamsWindow
procedure. }
procedure ShowCompressionWindow;
begin
ShowCapWin;
SendMessage(hWndC, WM_USER + 46, 0, 0);
{ allow this to happen }
application.processmessages;
HideCapWin;
end;
{ display a message to the user }
procedure UserMessage(msg: string);
begin
{
use for troubleshooting or your own messages...
main.messagelabel.caption := msg;
}
end;
end.
</pre>
Hexi (1999-12-13 10:36:00)
Unit AviCap;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, extctrls,
AviCapH,unit1;
type
TAviCap = class(TCustomControl)
private
{ Private Declarations }
RequestMicroSecPerFrame:dword;
MakeUserHitOKToCapture:LongBool;
PercentDropForError:Byte;
Yield:bool;
IndexSize:dword;
ChunkGranularity:dword;
UsingDOSMemory:Bool;
NumVideoRequested:dword;
CaptureAudio:Bool;
NumAudioRequested:Byte;
KeyAbort:Word;
AbortLeftMouse:bool;
AbortRightMouse:bool;
LimitEnabled:bool;
TimeLimit:Byte;
MCIControl:bool;
StepMCIDevice:bool;
MCIStartTime:dword;
MCIStopTime:dword;
StepCaptureAt2x:bool;
StepCaptureAverageFrames:Byte;
AudioBufferSize:dword;
DisableWriteCache:bool;
StreamMaster:Word;
FConnected: boolean;
FDriverDescripton: TStringList;
FAviFileNAme:String;
FOverlay:boolean;
FScale:boolean;
FCaptureParms:TCaptureParms;
dummy:Boolean;
protected
{ Protected Declarations }
procedure Connect(b:Boolean);
procedure SetAviFileName(S:String);
procedure SetOverlay(b:boolean);
procedure SetScale(b:boolean);
procedure Disconnect;
Procedure DlgSource(B:Boolean);
Procedure DlgFormat(B:Boolean);
Procedure DlgCompression(B:Boolean);
Procedure DlgDisplay(B:Boolean);
public
{ Public Declarations }
DC:HDC;
FCapWndHandle: THandle;
constructor Create(AOwner: TComponent);
override;
procedure paint;override;
procedure StartCapture;
procedure Stopcapture;
property cap_DriverDescripton: TStringList read FDriverDescripton;
property cap_WndHandle: THandle read FCapWndHandle;
published
property Canvas;
property cap_Connected: boolean read FConnected write connect;
property cap_DlgVideoCompression: boolean read dummy write DlgCompression;
property cap_DlgVideoSourece: boolean read dummy write DlgSource;
property cap_DlgVideoDisplay: boolean read dummy write DlgDisplay;
property cap_DlgVideoFormat: boolean read dummy write DlgFormat;
property cap_AviFileName:String read FAviFileNAme write SetAviFileNAme;
property cap_Overlay:Boolean read FOverlay write SetOverlay;
property cap_Scale:Boolean read FScale write SetScale;
property cap_OptRequestMicroSecPerFrame
WORD read RequestMicroSecPerFrame
write RequestMicroSecPerFrame;
property cap_OptMakeUserHitOKToCapture:Bool read MakeUserHitOKToCapture
write MakeUserHitOKToCapture;
property cap_OptPercentDropForError:Byte read PercentDropForError
write PercentDropForError;
property cap_OptYield:Bool read Yield
write Yield;
property cap_OptIndexSize:dword read IndexSize
write IndexSize;
property cap_OptChunkGranularity:dword read ChunkGranularity
write ChunkGranularity;
property cap_OptUsingDOSMemory:Bool read UsingDOSMemory
write UsingDOSMemory;
property cap_OptNumVideoRequested:dword read NumVideoRequested
write NumVideoRequested;
property cap_OptCaptureAudio:LongBool read CaptureAudio
write CaptureAudio;
property cap_OptNumAudioRequested:Byte read NumAudioRequested
write NumAudioRequested;
property cap_OptKeyAbort:Word read KeyAbort
write KeyAbort;
property cap_OptAbortLeftMouse:Bool read AbortLeftMouse
write AbortLeftMouse;
property cap_OptAbortRightMouse:Bool read AbortRightMouse
write AbortRightMouse;
property cap_OptLimitEnabled:Bool read LimitEnabled
write LimitEnabled;
property cap_OptTimeLimit:Byte read TimeLimit
write TimeLimit;
property cap_OptMCIControl:Bool read MCIControl
write MCIControl;
property cap_OptStepMCIDevice:Bool read StepMCIDevice
write StepMCIDevice;
property cap_OptMCIStartTime:dword read MCIStartTime
write MCIStartTime;
property cap_OptMCIStopTime:dword read MCIStopTime
write MCIStopTime;
property cap_OptStepCaptureAt2x:Bool read StepCaptureAt2x
write StepCaptureAt2x;
property cap_OptStepCaptureAverageFrames:Byte read StepCaptureAverageFrames
write StepCaptureAverageFrames;
property cap_OptAudioBufferSize:dword read AudioBufferSize
write AudioBufferSize;
property cap_OptDisableWriteCache:Bool read DisableWriteCache
write DisableWriteCache;
property cap_OptAVStreamMaster:Word read StreamMaster
write StreamMaster;
end;
procedure Register;
implementation
//{$R *.DCR}
constructor TAviCap.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
parent:=AOwner as TWinCOntrol;
FCapWndHandle:=capCreateCaptureWindowA('',WS_VISIBLE+WS_CHILD+WS_BORDER,
0,0,0,0,handle,0);
FAviFileNAMe:='nul';
capCaptureGetSetup (FCapWndHandle,WParam(@FCaptureParms),LParam(SizeOf(TCaptureParms)));
with FCaptureParmsdo
begin
RequestMicroSecPerFrame:=dwRequestMicroSecPerFrame;
MakeUserHitOKToCapture:=fMakeUserHitOKToCapture;
PercentDropForError:=wPercentDropForError;
Yield:=fYield;
IndexSize:=dwIndexSize;
ChunkGranularity:=wChunkGranularity;
UsingDOSMemory:=fUsingDOSMemory;
NumVideoRequested:=wNumVideoRequested;
CaptureAudio:=fCaptureAudio;
NumAudioRequested:=wNumAudioRequested;
KeyAbort:=vKeyAbort;
AbortLeftMouse:=fAbortLeftMouse;
AbortRightMouse:=fAbortRightMouse;
LimitEnabled:=fLimitEnabled;
TimeLimit:=wTimeLimit;
MCIControl:=fMCIControl;
StepMCIDevice:=fStepMCIDevice;
MCIStartTime:=dwMCIStartTime;
MCIStopTime:=dwMCIStopTime;
StepCaptureAt2x:=fStepCaptureAt2x;
StepCaptureAverageFrames:=wStepCaptureAverageFrames;
AudioBufferSize:=dwAudioBufferSize;
DisableWriteCache:=fDisableWriteCache;
StreamMaster:=AVStreamMaster;
end;
FOverlay:=True;
end;
procedure TAviCap.Connect(b:Boolean);
begin
if b then
begin
TextOut(dc,10,10,'Connecting.please wait!',24);
fconnected:=capDriverConnect(FCapWndHandle,0);
SetOverlay(FOverlay);
end
else
disconnect;
end;
procedure TAviCap.Disconnect;
var
B:boolean;
begin
b:=FOverlay;
SetOverlay(False);
capDriverDisconnect(FCapWndHandle);
fconnected:=False;
SetOverlay(b);
end;
procedure TAviCap.Paint;
begin
inherited Paint;
SetWindowPos(FCapWndHandle,HWND_TOP,0,0,width,height,SWP_SHOWWINDOW);
if dc=0 then
dc:=Getdc(FCapWndHandle);
If csDesigning in ComponentState then
TextOut(dc,10,10,PChar(NAme),Length(NAme));
end;
procedure TAviCap.SetAviFileName(S:String);
begin
capFileSetCaptureFile (FCapWndHandle, LParam(PChar(s)));
FAVIFileNAme:=s;
end;
procedure TAviCap.SetOverlay(b:boolean);
begin
capOverlay (FCapWndHandle, WPARAM(b));
FOverlay:=b;
end;
procedure TAviCap.SetScale(b:boolean);
begin
capPreviewScale (FCapWndHandle, WPARAM(b));
FScale:=b;
end;
procedure TAviCAp.StartCapture;
begin
SetOverlay(false);
capCapturesetsetup(FCapWndHandle,WParam(@FCaptureParms),LParam(SizeOf(TCaptureParms)));
capSetCallbackOnFrame(FCapWndHandle,integer(@CallBackFun));
end;
procedure TAviCAp.StopCapture;
begin
capCaptureStop(FCapWndHandle);
end;
Procedure TAviCap.DlgSource(B:Boolean);
begin
capDlgVideoSource (FCapWndHandle);
end;
Procedure TAviCAp.DlgFormat(B:Boolean);
begin
capDlgVideoFormat (FCapWndHandle);
end;
Procedure TAviCap.DlgCompression(B:Boolean);
begin
capDlgVideoCompression (FCapWndHandle);
end;
Procedure TAviCap.DlgDisplay(B:Boolean);
begin
capDlgVideoDisplay (FCapWndHandle);
end;
procedure Register;
begin
RegisterComponents('Sample', [TAviCap]);
end;
end.
{
****************************************************************************
* *
* Translated from avicap.h *
* *
* Main include file. *
* *
* Microsoft Video for Windows Sample Capture Class *
* *
* *
* C/C++ Run Time Library - Version 8.0 *
* *
* Copyright (c) 1994, 1997 by Borland International *
* All Rights Reserved. *
* *
* *
****************************************************************************
}
unit AviCapH;
interface
uses windows,messages, SysUtils;
// ------------------------------------------------------------------
// Window Messages WM_CAP... which can be sent to an AVICAP window
// ------------------------------------------------------------------
// Defines start of the message range
const
avicap32='avicap32.dll';
WM_CAP_START= WM_USER;
// start of unicode messages
WM_CAP_UNICODE_START= WM_USER+100;
WM_CAP_GET_CAPSTREAMPTR= (WM_CAP_START+ 1);
WM_CAP_SET_CALLBACK_ERROR= (WM_CAP_START+ 2) ;
WM_CAP_SET_CALLBACK_STATUS= (WM_CAP_START+ 3);
WM_CAP_SET_CALLBACK_YIELD= (WM_CAP_START+ 4);
WM_CAP_SET_CALLBACK_FRAME= (WM_CAP_START+ 5);
WM_CAP_SET_CALLBACK_VIDEOSTREAM= (WM_CAP_START+ 6);
WM_CAP_SET_CALLBACK_WAVESTREAM= (WM_CAP_START+ 7);
WM_CAP_GET_USER_DATA =(WM_CAP_START+ 8);
WM_CAP_SET_USER_DATA =(WM_CAP_START+ 9) ;
WM_CAP_DRIVER_CONNECT =(WM_CAP_START+ 10);
WM_CAP_DRIVER_DISCONNECT =(WM_CAP_START+ 11);
WM_CAP_DRIVER_GET_NAME =(WM_CAP_START+ 12);
WM_CAP_DRIVER_GET_VERSION =(WM_CAP_START+ 13);
WM_CAP_DRIVER_GET_CAPS =(WM_CAP_START+ 14);
WM_CAP_FILE_SET_CAPTURE_FILE =(WM_CAP_START+ 20);
WM_CAP_FILE_GET_CAPTURE_FILE =(WM_CAP_START+ 21);
WM_CAP_FILE_SAVEAS =(WM_CAP_START+ 23);
WM_CAP_FILE_SAVEDIB =(WM_CAP_START+ 25);
// out of order to save on ifdefs
WM_CAP_FILE_ALLOCATE =(WM_CAP_START+ 22);
WM_CAP_FILE_SET_INFOCHUNK =(WM_CAP_START+ 24);
WM_CAP_EDIT_COPY =(WM_CAP_START+ 30);
WM_CAP_SET_AUDIOFORMAT =(WM_CAP_START+ 35);
WM_CAP_GET_AUDIOFORMAT =(WM_CAP_START+ 36);
WM_CAP_DLG_VIDEOFORMAT =(WM_CAP_START+ 41);
WM_CAP_DLG_VIDEOSOURCE =(WM_CAP_START+ 42);
WM_CAP_DLG_VIDEODISPLAY =(WM_CAP_START+ 43);
WM_CAP_GET_VIDEOFORMAT =(WM_CAP_START+ 44);
WM_CAP_SET_VIDEOFORMAT =(WM_CAP_START+ 45);
WM_CAP_DLG_VIDEOCOMPRESSION =(WM_CAP_START+ 46);
WM_CAP_SET_PREVIEW =(WM_CAP_START+ 50);
WM_CAP_SET_OVERLAY =(WM_CAP_START+ 51);
WM_CAP_SET_PREVIEWRATE =(WM_CAP_START+ 52);
WM_CAP_SET_SCALE =(WM_CAP_START+ 53);
WM_CAP_GET_STATUS =(WM_CAP_START+ 54);
WM_CAP_SET_SCROLL =(WM_CAP_START+ 55);
WM_CAP_GRAB_FRAME =(WM_CAP_START+ 60);
WM_CAP_GRAB_FRAME_NOSTOP =(WM_CAP_START+ 61);
WM_CAP_SEQUENCE =(WM_CAP_START+ 62);
WM_CAP_SEQUENCE_NOFILE =(WM_CAP_START+ 63);
WM_CAP_SET_SEQUENCE_SETUP =(WM_CAP_START+ 64);
WM_CAP_GET_SEQUENCE_SETUP =(WM_CAP_START+ 65);
WM_CAP_SET_MCI_DEVICE =(WM_CAP_START+ 66);
WM_CAP_GET_MCI_DEVICE =(WM_CAP_START+ 67);
WM_CAP_STOP =(WM_CAP_START+ 68);
WM_CAP_ABORT =(WM_CAP_START+ 69);
WM_CAP_SINGLE_FRAME_OPEN =(WM_CAP_START+ 70);
WM_CAP_SINGLE_FRAME_CLOSE =(WM_CAP_START+ 71);
WM_CAP_SINGLE_FRAME =(WM_CAP_START+ 72);
WM_CAP_PAL_OPEN =(WM_CAP_START+ 80);
WM_CAP_PAL_SAVE =(WM_CAP_START+ 81);
WM_CAP_PAL_PASTE =(WM_CAP_START+ 82);
WM_CAP_PAL_AUTOCREATE =(WM_CAP_START+ 83);
WM_CAP_PAL_MANUALCREATE =(WM_CAP_START+ 84);
// Following added post VFW 1.1
WM_CAP_SET_CALLBACK_CAPCONTROL =(WM_CAP_START+ 85);
WM_CAP_END =WM_CAP_SET_CALLBACK_CAPCONTROL;
function capCreateCaptureWindowA (
lpszWindowName
Char;
dwStyle
WORD;
x,y,nWidth,nHeight:Integer;
hwndParent:HWnd;nID:Integer):hwnd;stdcall;
external avicap32;
function capGetDriverDescriptionA (
wDriverIndex:UINT;
lpszName
Char;cbName:Integer;
lpszVer
Char;cbVer:Integer):Boolean;stdcall;
external avicap32;
procedure capSetCallbackOnError(hCapWnd:hwnd;
fpProc:Lparam);
procedure capSetCallbackOnStatus(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetCallbackOnYield(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetCallbackOnFrame(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetCallbackOnVideoStream(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetCallbackOnWaveStream(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetCallbackOnCapControl(hCapWnd:hwnd;
fpProc:LParam);
procedure capSetUserData(hCapWnd:hwnd;lUser:LParam);
procedure capGetUserData(hCapWnd:hwnd);
function capDriverConnect(hCapWnd:hwnd;
i:wParam):Boolean;
procedure capDriverDisconnect(hCapWnd:hwnd);
procedure capDriverGetName(hCapWnd:hwnd;
szName:wParam;
wSize:LParam);
procedure capDriverGetVersion(hCapWnd:hwnd;
szVer:wParam;
wSize:LParam);
procedure capDriverGetCaps(hCapWnd:hwnd;
s:wParam;
wSize:LParam);
procedure capFileSetCaptureFile(hCapWnd:hwnd;
szName :LPARAM);
procedure capFileGetCaptureFile(hCapWnd:hwnd;
szName :wPARAM;
wSize :lPARAM);
procedure capFileAlloc(hCapWnd:hwnd;
dwSize :LPARAM);
procedure capFileSaveAs(hCapWnd:hwnd;
szName :LPARAM);
procedure capFileSetInfoChunk(hCapWnd:hwnd;
lpInfoChunk :LPARAM);
procedure capFileSaveDIB(hCapWnd:hwnd;
szName :LPARAM);
procedure capEditCopy(hCapWnd:hwnd);
procedure capSetAudioFormat(hCapWnd:hwnd;
s :WPARAM;
wSize :LPARAM);
procedure capGetAudioFormat(hCapWnd:hwnd;
s :WPARAM;
wSize :LPARAM);
procedure capGetAudioFormatSize(hCapWnd:hwnd);
procedure capDlgVideoFormat(hCapWnd:hwnd);
procedure capDlgVideoSource(hCapWnd:hwnd);
procedure capDlgVideoDisplay(hCapWnd:hwnd);
procedure capDlgVideoCompression(hCapWnd:hwnd);
procedure capGetVideoFormat(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
procedure capGetVideoFormatSize(hCapWnd:hwnd);
procedure capSetVideoFormat(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
procedure capPreview(hCapWnd:hwnd;
f :WPARAM);
procedure capPreviewRate(hCapWnd:hwnd;
wMS :WPARAM);
procedure capOverlay(hCapWnd:hwnd;
f :WPARAM);
procedure capPreviewScale(hCapWnd:hwnd;
f :WPARAM);
procedure capGetStatus(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
procedure capSetScrollPos(hCapWnd:hwnd;
lpP :LPARAM);
procedure capGrabFrame(hCapWnd:hwnd);
procedure capGrabFrameNoStop(hCapWnd:hwnd);
procedure capCaptureSequence(hCapWnd:hwnd);
procedure capCaptureSequenceNoFile(hCapWnd:hwnd);
procedure capCaptureStop(hCapWnd:hwnd);
procedure capCaptureAbort(hCapWnd:hwnd);
procedure capCaptureSingleFrameOpen(hCapWnd:hwnd);
procedure capCaptureSingleFrameClose(hCapWnd:hwnd);
procedure capCaptureSingleFrame(hCapWnd:hwnd);
procedure capCaptureGetSetup(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
procedure capCaptureSetSetup(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
procedure capSetMCIDeviceName(hCapWnd:hwnd;
szName:LPARAM);
procedure capGetMCIDeviceName(hCapWnd:hwnd;
szName:LPARAM;
wSize:WPARAM);
procedure capPaletteOpen(hCapWnd:hwnd;
szName:LPARAM);
procedure capPaletteSave(hCapWnd:hwnd;
szName:LPARAM);
procedure capPalettePaste(hCapWnd:hwnd);
procedure capPaletteAuto(hCapWnd:hwnd;
iFrames:WPARAM;
iColors :LPARAM);
procedure capPaletteManual(hCapWnd:hwnd;
fGrab :WPARAM;
iColors :LPARAM);
// ------------------------------------------------------------------
// Structures
// ------------------------------------------------------------------
type
TCapDriverCaps =packed Record
wDeviceIndex:UINT;
// Driver index in system.ini
fHasOverlay:BOOL;
// Can device overlay?
fHasDlgVideoSource:BOOL;
// Has Video source dlg?
fHasDlgVideoFormat:BOOL;
// Has Format dlg?
fHasDlgVideoDisplay:BOOL;
// Has External out dlg?
fCaptureInitialized:BOOL;
// Driver ready to capture?
fDriverSuppliesPalettes:BOOL;
// Can driver make palettes?
// following always NULL on Win32.
hVideoIn:THANDLE;
// Driver In channel
hVideoOut:THANDLE;
// Driver Out channel
hVideoExtIn:THANDLE;
// Driver Ext In channel
hVideoExtOut:THANDLE;
// Driver Ext Out channel
end;
type
TCapStatus = packed record
uiImageWidth:UINT ;
// Width of the image
uiImageHeight:UINT ;
// Height of the image
fLiveWindow:BOOL ;
// Now Previewing video?
fOverlayWindow:BOOL ;
// Now Overlaying video?
fScale:BOOL ;
// Scale image to client?
ptScroll:TPOINT ;
// Scroll position
fUsingDefaultPalette:BOOL ;
// Using default driver palette?
fAudioHardware:BOOL ;
// Audio hardware present?
fCapFileExists:BOOL ;
//do
es capture file exist?
dwCurrentVideoFrame
WORD ;
// # of video frames cap'td
dwCurrentVideoFramesDropped
WORD ;// # of video frames dropped
dwCurrentWaveSamples
WORD ;
// # of wave samples cap'td
dwCurrentTimeElapsedMS
WORD ;
// Elapsed capture duration
hPalCurrent:HPALETTE ;
// Current palette in use
fCapturingNow:BOOL ;
// Capture in progress?
dwReturn
WORD ;
// Error value after any operation
wNumVideoAllocated:UINT ;
// Actual number of video buffers
wNumAudioAllocated:UINT ;
// Actual number of audio buffers
end;
type
// video data block header
LPByte=PByteArray;
Videohdr=packed record
lpData:LPBYTE;
//pointer to locked data buffer
dwBufferLength
WORD;
//Length of data buffer
dwBytesUsed
WORD ;
// Bytes actually used
dwTimeCaptured
WORD ;
// Milliseconds from start of stream
dwUser
WORD ;
//for client's use
dwFlags
WORD ;
//assorted flags (see defines)
dwReserved:array[0..3] of DWORD;
// reserved for driver
end;
LPVideoHdr=^VideoHdr;
TCaptureParms = packed Record
dwRequestMicroSecPerFrame
WORD ;
// Requested capture rate
fMakeUserHitOKToCapture:BOOL ;
// Show "Hit OK to cap"
dlg?
wPercentDropForError:UINT ;
// Give error msg if > (10%)
fYield:BOOL ;
// Capture via background task?
dwIndexSize
WORD ;
// Max index size in frames (32K)
wChunkGranularity:UINT ;
// Junk chunk granularity (2K)
fUsingDOSMemory:BOOL ;
// Usedo
S buffers?
wNumVideoRequested:UINT ;
// # video buffers, If 0, autocalc
fCaptureAudio:BOOL ;
// Capture audio?
wNumAudioRequested:UINT ;
// # audio buffers, If 0, autocalc
vKeyAbort:UINT ;
// Virtual key causing abort
fAbortLeftMouse:BOOL ;
// Abort on left mouse?
fAbortRightMouse:BOOL ;
// Abort on right mouse?
fLimitEnabled:BOOL ;
// Use wTimeLimit?
wTimeLimit:UINT ;
// Seconds to capture
fMCIControl:BOOL ;
// Use MCI video source?
fStepMCIDevice:BOOL ;
// Step MCI device?
dwMCIStartTime
WORD ;
// Time to start in MS
dwMCIStopTime
WORD ;
// Time to stop in MS
fStepCaptureAt2x:BOOL ;
// Perform spatial averaging 2x
wStepCaptureAverageFrames:UINT ;
// Temporal average n Frames
dwAudioBufferSize
WORD ;
// Size of audio bufs (0 = default)
fDisableWriteCache:BOOL ;
// Attempt to disable write cache
AVStreamMaster
WORD;
end;
type
TByteRec = record
Lo, Hi: Byte;
end;
TWordRec = record
Low, High: TByteRec;
end;
Type
FOURCC=TWordRec;
function mmioFOURCC(const c0,c1,c2,c3:Char):FOURCC;
type
TCapInfoChunk = packed record
fccInfoID:FOURCC ;
// Chunk ID, "ICOP"
for copyright
lpData
ointer ;
// pointer to data
cbData:LONGINT ;
// size of lpData
end;
// ------------------------------------------------------------------
// CapControlCallback states
// ------------------------------------------------------------------
const
CONTROLCALLBACK_PREROLL = 1;
//* Waiting to start capture */
CONTROLCALLBACK_CAPTURING= 2;
//* Now capturing */
// ------------------------------------------------------------------
// New Information chunk IDs
// ------------------------------------------------------------------
// DIGITIZATION_TIME = mmioFOURCC ('I','D','I','T');
// infotypeSMPTE_TIME mmioFOURCC ('I','S','M','P')
// ------------------------------------------------------------------
// String IDs from status and error callbacks
// ------------------------------------------------------------------
{
IDS_CAP_begin
300 /* "Capture Start"
*/
IDS_CAP_END 301 /* "Capture End"
*/
IDS_CAP_INFO 401 /* "%s"
*/
IDS_CAP_OUTOFMEM 402 /* "Out of memory"
*/
IDS_CAP_FILEEXISTS 403 /* "File '%s' exists -- overwrite it?"
*/
IDS_CAP_ERRORPALOPEN 404 /* "Error opening palette '%s'"
*/
IDS_CAP_ERRORPALSAVE 405 /* "Error saving palette '%s'"
*/
IDS_CAP_ERRORDIBSAVE 406 /* "Error saving frame '%s'"
*/
IDS_CAP_DEFAVIEXT 407 /* "avi"
*/
IDS_CAP_DEFPALEXT 408 /* "pal"
*/
IDS_CAP_CANTOPEN 409 /* "Cannot open '%s'"
*/
IDS_CAP_SEQ_MSGSTART 410 /* "Select OK to start capture/nof video sequence/nto %s."
*/
IDS_CAP_SEQ_MSGSTOP 411 /* "Hit ESCAPE or click to end capture"
*/
IDS_CAP_VIDEDITERR 412 /* "An error occurred while trying to run VidEdit."
*/
IDS_CAP_READONLYFILE 413 /* "The file '%s' is a read-only file."
*/
IDS_CAP_WRITEERROR 414 /* "Unable to write to file '%s'./nDisk may be full."
*/
IDS_CAP_NODISKSPACE 415 /* "There is no space to create a capture file on the specified device."
*/
IDS_CAP_SETFILESIZE 416 /* "Set File Size"
*/
IDS_CAP_SAVEASPERCENT 417 /* "SaveAs: %2ld%% Hit Escape to abort."
*/
IDS_CAP_DRIVER_ERROR 418 /* Driver specific error message */
IDS_CAP_WAVE_OPEN_ERROR 419 /* "Error: Cannot open the wave input device./nCheck sample size, frequency, and channels."
*/
IDS_CAP_WAVE_ALLOC_ERROR 420 /* "Error: Out of memory for wave buffers."
*/
IDS_CAP_WAVE_PREPARE_ERROR 421 /* "Error: Cannot prepare wave buffers."
*/
IDS_CAP_WAVE_ADD_ERROR 422 /* "Error: Cannot add wave buffers."
*/
IDS_CAP_WAVE_SIZE_ERROR 423 /* "Error: Bad wave size."
*/
IDS_CAP_VIDEO_OPEN_ERROR 424 /* "Error: Cannot open the video input device."
*/
IDS_CAP_VIDEO_ALLOC_ERROR 425 /* "Error: Out of memory for video buffers."
*/
IDS_CAP_VIDEO_PREPARE_ERROR 426 /* "Error: Cannot prepare video buffers."
*/
IDS_CAP_VIDEO_ADD_ERROR 427 /* "Error: Cannot add video buffers."
*/
IDS_CAP_VIDEO_SIZE_ERROR 428 /* "Error: Bad video size."
*/
IDS_CAP_FILE_OPEN_ERROR 429 /* "Error: Cannot open capture file."
*/
IDS_CAP_FILE_WRITE_ERROR 430 /* "Error: Cannot write to capture file. Disk may be full."
*/
IDS_CAP_RECORDING_ERROR 431 /* "Error: Cannot write to capture file. Data rate too high or disk full."
*/
IDS_CAP_RECORDING_ERROR2 432 /* "Error while recording"
*/
IDS_CAP_AVI_INIT_ERROR 433 /* "Error: Unable to initialize for capture."
*/
IDS_CAP_NO_FRAME_CAP_ERROR 434 /* "Warning: No frames captured./nConfirm that vertical sync interrupts/nare configured and enabled."
*/
IDS_CAP_NO_PALETTE_WARN 435 /* "Warning: Using default palette."
*/
IDS_CAP_MCI_CONTROL_ERROR 436 /* "Error: Unable to access MCI device."
*/
IDS_CAP_MCI_CANT_STEP_ERROR 437 /* "Error: Unable to step MCI device."
*/
IDS_CAP_NO_AUDIO_CAP_ERROR 438 /* "Error: No audio data captured./nCheck audio card settings."
*/
IDS_CAP_AVI_DRAWDIB_ERROR 439 /* "Error: Unable to draw this data format."
*/
IDS_CAP_COMPRESSOR_ERROR 440 /* "Error: Unable to initialize compressor."
*/
IDS_CAP_AUDIO_DROP_ERROR 441 /* "Error: Audio data was lost during capture, reduce capture rate."
*/
/* status string IDs */
IDS_CAP_STAT_LIVE_MODE 500 /* "Live window"
*/
IDS_CAP_STAT_OVERLAY_MODE 501 /* "Overlay window"
*/
IDS_CAP_STAT_CAP_INIT 502 /* "Setting up for capture - Please wait"
*/
IDS_CAP_STAT_CAP_FINI 503 /* "Finished capture, now writing frame %ld"
*/
IDS_CAP_STAT_PALETTE_BUILD 504 /* "Building palette map"
*/
IDS_CAP_STAT_OPTPAL_BUILD 505 /* "Computing optimal palette"
*/
IDS_CAP_STAT_I_FRAMES 506 /* "%d frames"
*/
IDS_CAP_STAT_L_FRAMES 507 /* "%ld frames"
*/
IDS_CAP_STAT_CAP_L_FRAMES 508 /* "Captured %ld frames"
*/
IDS_CAP_STAT_CAP_AUDIO 509 /* "Capturing audio"
*/
IDS_CAP_STAT_VIDEOCURRENT 510 /* "Captured %ld frames (%ld dropped);
//%d.%03d sec."
*/
IDS_CAP_STAT_VIDEOAUDIO 511 /* "Captured %d.%03d sec. %ld frames (%ld dropped);
//(%d.%03d fps). %ld audio bytes (%d,%03d sps)"
*/
IDS_CAP_STAT_VIDEOONLY 512 /* "Captured %d.%03d sec. %ld frames (%ld dropped);
//(%d.%03d fps)"
*/
IDS_CAP_STAT_FRAMESDROPPED 513 /* "Dropped %ld of %ld frames (%d.%02d%%);
//during capture."
*/
}
implementation
function mmioFOURCC(const c0,c1,c2,c3:Char):FOURCC;
begin
result.High.Hi:=Byte(c0);
result.High.Lo:=Byte(c1);
result.Low.Hi:=Byte(c2);
result.Low.Lo:=Byte(c3);
end;
procedure capSetCallbackOnError(hCapWnd:hwnd;
fpProc:Lparam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_ERROR, 0, fpProc)
end;
procedure capSetCallbackOnStatus(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_Status, 0, fpProc)
end;
procedure capSetCallbackOnYield(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_YIELD, 0, fpProc)
end;
procedure capSetCallbackOnFrame(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_FRAME, 0, fpProc)
end;
procedure capSetCallbackOnVideoStream(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_VideoSTREAM, 0, fpProc)
end;
procedure capSetCallbackOnWaveStream(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_WAVESTREAM , 0, fpProc)
end;
procedure capSetCallbackOnCapControl(hCapWnd:hwnd;
fpProc:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_CALLBACK_CapControl , 0, fpProc)
end;
procedure capGetUserData(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_GET_USER_DATA , 0, 0)
end;
procedure capSetUserData(hCapWnd:hwnd;lUser:LParam);
begin
SendMessage(hCapWnd, WM_CAP_SET_USER_DATA , 0, lUser)
end;
function capDriverConnect(hCapWnd:hwnd;
i:wParam):Boolean;
begin
result:=SendMessage(hCapWnd, WM_CAP_DRIVER_CONNECT ,i , 0)<>0;
end;
procedure capDriverDisconnect(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_DRIVER_DISCONNECT ,0 , 0)
end;
procedure capDriverGetName(hCapWnd:hwnd;
szName:wParam;
wSize:LParam);
begin
SendMessage(hCapWnd, WM_CAP_DRIVER_Get_Name ,szName , wSize)
end;
procedure capDriverGetVersion(hCapWnd:hwnd;
szVer:wParam;
wSize:LParam);
begin
SendMessage(hCapWnd, WM_CAP_DRIVER_Get_VERSION ,szVer , wSize)
end;
procedure capDriverGetCaps(hCapWnd:hwnd;
s:wParam;
wSize:LParam);
begin
SendMessage(hCapWnd, WM_CAP_DRIVER_Get_CAPS ,s , wSize)
end;
procedure capFileSetCaptureFile(hCapWnd:hwnd;
szName :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_SET_CAPTURE_FILE ,0 , szName)
end;
procedure capFileGetCaptureFile(hCapWnd:hwnd;
szName :wPARAM;
wSize :lPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_GET_CAPTURE_FILE , szName,wSize)
end;
procedure capFileAlloc(hCapWnd:hwnd;
dwSize :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_ALLOCATE , 0,dwSize)
end;
procedure capFileSaveAs(hCapWnd:hwnd;
szName :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_SAVEAS , 0,szName)
end;
procedure capFileSetInfoChunk(hCapWnd:hwnd;
lpInfoChunk :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_SET_INFOCHUNK , 0,lpInfoChunk)
end;
procedure capFileSaveDIB(hCapWnd:hwnd;
szName :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_FILE_SAVEDIB , 0,szName)
end;
procedure capEditCopy(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_EDIT_COPY , 0,0)
end;
procedure capSetAudioFormat(hCapWnd:hwnd;
s :WPARAM;
wSize :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_AUDIOFORMAT , s,wSize)
end;
procedure capGetAudioFormat(hCapWnd:hwnd;
s :WPARAM;
wSize :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_AUDIOFORMAT , s,wSize)
end;
procedure capGetAudioFormatSize(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_GET_AUDIOFORMAT , 0,0)
end;
procedure capDlgVideoFormat(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_DLG_VIDEOFORMAT , 0,0)
end;
procedure capDlgVideoSource(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_DLG_VIDEOSOURCE , 0,0)
end;
procedure capDlgVideoDisplay(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_DLG_VIDEODISPLAY , 0,0)
end;
procedure capDlgVideoCompression(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_DLG_VIDEOCOMPRESSION , 0,0)
end;
procedure capGetVideoFormat(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_VIDEOFORMAT , s,wSize)
end;
procedure capGetVideoFormatSize(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_GET_VIDEOFORMAT , 0,0)
end;
procedure capSetVideoFormat(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_VIDEOFORMAT , 0,0)
end;
procedure capPreview(hCapWnd:hwnd;
f :WPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_PREVIEW , f,0)
end;
procedure capPreviewRate(hCapWnd:hwnd;
wMS :WPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_PREVIEWRATE , wMS,0)
end;
procedure capOverlay(hCapWnd:hwnd;
f :WPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_OVERLAY , f,0)
end;
procedure capPreviewScale(hCapWnd:hwnd;
f :WPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_SCALE , f,0)
end;
procedure capGetStatus(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_STATUS , s,wSize)
end;
procedure capSetScrollPos(hCapWnd:hwnd;
lpP :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_SCROLL , 0,lpP)
end;
procedure capGrabFrame(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_GRAB_FRAME , 0,0)
end;
procedure capGrabFrameNoStop(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_GRAB_FRAME_NOSTOP , 0,0)
end;
procedure capCaptureSequence(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_SEQUENCE , 0,0)
end;
procedure capCaptureSequenceNoFile(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_SEQUENCE_NOFILE , 0,0)
end;
procedure capCaptureStop(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_Stop , 0,0)
end;
procedure capCaptureAbort(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_ABORT , 0,0)
end;
procedure capCaptureSingleFrameOpen(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_SINGLE_FRAME_OPEN , 0,0)
end;
procedure capCaptureSingleFrameClose(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_SINGLE_FRAME_CLOSE , 0,0)
end;
procedure capCaptureSingleFrame(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_SINGLE_FRAME , 0,0)
end;
procedure capCaptureGetSetup(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_SEQUENCE_SETUP , s,wSize)
end;
procedure capCaptureSetSetup(hCapWnd:hwnd;
s:WPARAM;
wSize:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_SEQUENCE_SETUP , s,wSize)
end;
procedure capSetMCIDeviceName(hCapWnd:hwnd;
szName:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_SET_MCI_DEVICE , 0,szName)
end;
procedure capGetMCIDeviceName(hCapWnd:hwnd;
szName:LPARAM;
wSize:WPARAM);
begin
SendMessage(hCapWnd, WM_CAP_GET_MCI_DEVICE , wSize,szName)
end;
procedure capPaletteOpen(hCapWnd:hwnd;
szName:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_PAL_OPEN , 0,szName)
end;
procedure capPaletteSave(hCapWnd:hwnd;
szName:LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_PAL_SAVE , 0,szName)
end;
procedure capPalettePaste(hCapWnd:hwnd);
begin
SendMessage(hCapWnd, WM_CAP_PAL_PASTE , 0,0)
end;
procedure capPaletteAuto(hCapWnd:hwnd;
iFrames:WPARAM;
iColors :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_PAL_AUTOCREATE , iFrames,iColors)
end;
procedure capPaletteManual(hCapWnd:hwnd;
fGrab :WPARAM;
iColors :LPARAM);
begin
SendMessage(hCapWnd, WM_CAP_PAL_MANUALCREATE , fGrab,iColors)
end;
end.
Hexi (1999-12-13 10:43:00)
unit Unit1;
{该单元是用来截取捕获图象数据
进行处理——输出坐标。}
interface
uses
sysUtils,Avicaph,graphics,windows;
const
SWidth=319;
SHeight=239;
type
ColorArr=packed array[0..SHeight,0..SWidth] of Byte;
var
x,y:integer;
buf:ColorArr;
procedure CallBackFun(h:HWND;lpv:LPVideoHdr);stdcall;
procedure stopdrawing;
implementation
uses
wly;
procedure CallBackFun(h:HWND;lpv:LPVideoHdr);
const
gray=20;
//基准象素点颜色值
var
i,j:integer;
a,b,ax,ay,bx,by:integer;
dc:hdc;
begin
//取坐标
move(lpv^.lpdata^,buf,lpv^.dwbytesused);//将捕获数据放到缓冲区中
a:=0;b:=0;ax:=0;bx:=0;ay:=0;by:=0;
dc:=getdc(Form1.Panel1.handle);
for i:=0 to SHeightdo
begin
for j:=0 to SWidth do
begin
if buf[i,j]>gray then
begin
inc(a);ax:=ax+j;ay:=ay+i;
Windows.setpixel(dc,j,i,clWhite);
end
else
begin
inc(b);bx:=bx+j;by:=by+i;
Windows.setpixel(dc,j,i,clBlack);
end;
end;
end;
if (a=0)or(b=0) then
exit
else
if a<b then
begin
x:=ax div a;y:=SHeight-ay div a;
end
else
begin
x:=bx div b;y:=SHeight-by div b;
end;
end;
procedure stopdrawing;//恢复窗口
var
dcc:HDC;
i,j:integer;
begin
dcc:=getdc(Form1.Panel1.handle);
for i:=0 to SHeightdo
for j:=0 to SWidthdo
Windows.setpixel(dcc,j,SHeight-i,clwhite);
end;
end.
www (1999-12-13 10:44:00)
到深度历险down一个利用 Microsoft Video for Windows 提供的 AVICAP32.DLL
撷取 AVI 档画面的构件
yzhu (1999-12-13 20:24:00)
to yaoyao, 我也要一份, thank you!
<A HREF="mailto:yzhu@126.com">yzhu@126.com</A>
yaoydong (1999-12-14 10:55:00)
首先感谢各位大虾这么热心的为我解答.
to cakk:
感谢为我提供了一个框架
to hexi:
您贴的第一个就是avicap21吧,第二个没贴完,请全部贴完好吗
谢谢大家
Hexi (1999-12-14 11:00:00)
你查看源文件就可看到了。
sunstone (2000-01-10 0:51:00)
to hexi:
您能给我mail一分avicap21的原码吗? 我现在急用!!! 谢谢
sunstone@263.net
sunstone (2000-01-10 1:26:00)
to hexi:
忘了还要avicap32.dll接口函数说明(vfw.pas)文档
谢谢!
sunstone@263.net
Dick (2000-01-10 8:13:00)
yaoyao, Henxi, Cakk诸位大侠,小弟正在作视频捕捉方面的开发,
请将几位的宝贵冬冬发到这里:
kundeng@163.net
感激涕零叩首10000000000000次!
yaoydong (2000-01-10 10:22:00)
问题已经解决,谢谢各位
Dbjam (2001-01-29 16:53:00)
留一份给我好吗。
dbjam@netease.com
Ironhero (2002-01-29 16:06:00)
上面各位大侠,在捕获帧后,怎么压缩这些数据,再提供一些思路吧!
tuday (2002-03-11 20:52:00)
gz
cAkk-20,CJ-10,Dick-10,Hexi-40,sunstone-10,yaoyao-10,的回答最终被接受。