WebCam upravljanje, kako?

Vse o večpredstavnosti (zvok, video, DirectShow in podobno).
GJ
Prispevkov: 1078
Pridružen: 13.03.2004 12:34:48

WebCam upravljanje, kako?

Odgovor Napisal/-a GJ » 13.04.2006 20:39:45

Ma sem kmalu ugotovu, da Twain ni to to. Ker poleg tega da je skrajno počasen, pa interface je nemogoč :P mi povrh vsega pa ne podpira vseh nastavitev, bolje rečeno niti resolucije ne moreš spremeniti programsko ( pač ni implementirano v gonilcih za to kamero).

No sem si pol downloadu Logitech QuickCam SDK.
Lepo inštaliram pa jasno nič ne dela. :o
Eni čist tretji dll-ji javljajo napake. Štala.. Ugotovim, da stvari že dolgo časa ne obnaljajo tako kot bi morali. Verzija SDK-ja je še vedno 1.0 in več kot 5 let stara.
No pa in sem le pogledal katere ActiveX mi je registriralo pri nalaganju gonilcev za kamero in najdem HPortal2.dll prevedem in ugotovim, da se vsebina bolj ali manj ujema s tisto v helpu za QuickCam SDK.

Uporabim komponento napišem..

Koda: Izberi vse

 
procedure TForm1.FormShow(Sender: TObject);
begin
  VideoPortal1.PrepareControl('QCSDK', 'HKEY_LOCAL_MACHINE\Software\QCSDK', 0);
  VideoPortal1.EnableUIElements(UIELEMENT_STATUSBAR, 0, 1);
  VideoPortal1.ConnectCamera(0);
  VideoPortal1.EnablePreview := 1;
end;
 
..in dela full hitr in z dostopom do funkcij, no ja vsaj tistih, ki so dokumentirane v QuickCam SDK.. :D


LP GJ
Kdor se zadnji smeje, se smeje zadnji!

Delphin
Prispevkov: 76
Pridružen: 24.07.2004 17:00:27

WebCam upravljanje, kako?

Odgovor Napisal/-a Delphin » 19.04.2006 22:28:46

Mogoče butasto ampak kako naj uporabim DSPack na D2006

xtreme
Prispevkov: 890
Pridružen: 11.04.2003 23:07:41

WebCam upravljanje, kako?

Odgovor Napisal/-a xtreme » 20.04.2006 00:04:15

Mogoče butasto ampak kako naj uporabim DSPack na D2006
Poglej tole temo
Let's make dreams a reality

Gumby
Prispevkov: 63
Pridružen: 04.02.2002 15:39:14

WebCam upravljanje, kako?

Odgovor Napisal/-a Gumby » 20.04.2006 12:10:25

Jaz sem se takole lotil... (sorry za malo daljsi post :))

Koda: Izberi vse

 unit uCap;

interface

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

  type
    CAPDRIVERCAPS=record
      wDeviceIndex:cardinal;
      fHasOverlay,
      fHasDlgVideoSource,
      fHasDlgVideoFormat,
      fHasDlgVideoDisplay,
      fCaptureInitialized,
      fDriverSuppliesPalettes:longbool;
      hVideoIn,
      hVideoOut,
      hVideoExtIn,
      hVideoExtOut:Cardinal;
  end;
  pCAPDRIVERCAPS=^CAPDRIVERCAPS;

  type
    CAPSTATUS=record
      uiImageWidth,
      uiImageHeight:cardinal;
      fLiveWindow,
      fOverlayWindow,
      fScale:longbool;
      ptScroll:TPoint;
      fUsingDefaultPalette,
      fAudioHardware,
      fCapFileExists:longbool;
      dwCurrentVideoFrame,
      dwCurrentVideoFramesDropped,
      dwCurrentWaveSamples,
      dwCurrentTimeElapsedMS,
      hPalCurrent:cardinal;
      fCapturingNow:longbool;
      dwReturn,
      wNumVideoAllocated,
      wNumAudioAllocated:cardinal;
  end;
  pCAPSTATUS=^CAPSTATUS;

  type
    WAVEFORMATEX=record
      wFormatTag,
      nChannels:word;
      nSamplesPerSec,
      nAvgBytesPerSec:cardinal;
      nBlockAlign,
      wBitsPerSample,
      cbSize:dword;
  end;
  pWAVEFORMATEX=^WAVEFORMATEX;

  type
    CAPINFOCHUNK=record
      fccInfoID:cardinal;
      lpData:pointer;
      cbDataLen:cardinal;
  end;
  pCAPINFOCHUNK=^CAPINFOCHUNK;

  type
    CAPTUREPARMS=record
      dwRequestMicroSecPerFrame:cardinal;
      fMakeUserHitOKToCapture:longbool;
      wPercentDropForError:cardinal;
      fYield:longbool;
      dwIndexSize,
      wChunkGranularity:cardinal;
      fUsingDOSMemory:longbool;
      wNumVideoRequested:cardinal;
      fCaptureAudio:longbool;
      wNumAudioRequested,
      vKeyAbort:cardinal;
      fAbortLeftMouse,
      fAbortRightMouse,
      fLimitEnabled:longbool;
      wTimeLimit:cardinal;
      fMCIControl,
      fStepMCIDevice:longbool;
      dwMCIStartTime,
      dwMCIStopTime:cardinal;
      fStepCaptureAt2x:longbool;
      wStepCaptureAverageFrames:cardinal;
      dwAudioBufferSize:cardinal;
      fDisableWriteCache:longbool;
      AVStreamMaster:cardinal;
  end;
  pCAPTUREPARMS=^CAPTUREPARMS;

  type
    VIDEOHDR=record
      lpData:pointer;
      dwBufferLength,
      dwBytesUsed,
      dwTimeCaptured,
      dwUser,
      dwFlags:cardinal;
      dwReserved:array [0..3] of cardinal;
  end;
  pVIDEOHDR=^VIDEOHDR;

  const VHDR_DONE = 1;          
  const VHDR_PREPARED = 2;      
  const VHDR_INQUEUE = 4;       
  const VHDR_KEYFRAME = 8;

  function VideoStreamCallback(hWnd:cardinal; vHeader:pVIDEOHDR):cardinal; stdcall;
  function FrameCallback(hWnd:cardinal; vHeader:pVIDEOHDR):cardinal; stdcall;
  function CapControlCallback (hWnd,nState:cardinal):Cardinal; stdcall;
  function ErrorCallBack (hWnd,nId:Cardinal; nDescription:pansichar):cardinal; stdcall;
  function StatusCallBack (hWnd,nId:Cardinal; nDescription:pansichar):cardinal; stdcall;

  function capCreateCaptureWindowA(windowName:PAnsiChar; dwstyle, x, y, cx, cy, parentHwnd,nId:cardinal):cardinal; stdcall; external 'avicap32.dll';
  function capGetDriverDescriptionA(drvIndex:cardinal; Name:PAnsiChar; NameLen:cardinal; Description:PAnsiChar;DescLen:cardinal):cardinal; stdcall; external 'avicap32.dll';

  const WM_CAP_START = WM_USER ;

  const WM_CAP_GET_CAPSTREAMPTR  =         (WM_CAP_START+  1) ;

  const WM_CAP_SET_CALLBACK_ERRORA  =      (WM_CAP_START+  2) ;
  const WM_CAP_SET_CALLBACK_STATUSA  =     (WM_CAP_START+  3) ;

  const WM_CAP_SET_CALLBACK_YIELD =        (WM_CAP_START+  4) ;
  const WM_CAP_SET_CALLBACK_FRAME =        (WM_CAP_START+  5) ;
  const WM_CAP_SET_CALLBACK_VIDEOSTREAM  = (WM_CAP_START+  6) ;
  const WM_CAP_SET_CALLBACK_WAVESTREAM =   (WM_CAP_START+  7) ;
  const WM_CAP_GET_USER_DATA =		   (WM_CAP_START+  8) ;
  const WM_CAP_SET_USER_DATA =		   (WM_CAP_START+  9) ;

  const WM_CAP_FILE_ALLOCATE =             (WM_CAP_START+  22);
  const WM_CAP_FILE_SET_INFOCHUNK =        (WM_CAP_START+  24);

  const WM_CAP_DRIVER_CONNECT =            (WM_CAP_START+  10);
  const WM_CAP_DRIVER_DISCONNECT=          (WM_CAP_START+  11);
  const WM_CAP_DRIVER_GET_NAMEA=           (WM_CAP_START+  12);
  const WM_CAP_DRIVER_GET_VERSIONA =       (WM_CAP_START+  13);
  const WM_CAP_DRIVER_GET_CAPS=            (WM_CAP_START+  14);

  const WM_CAP_FILE_SET_CAPTURE_FILEA =    (WM_CAP_START+  20);
  const WM_CAP_FILE_GET_CAPTURE_FILEA=     (WM_CAP_START+  21);
  const WM_CAP_FILE_SAVEASA =              (WM_CAP_START+  23) ;
  const WM_CAP_FILE_SAVEDIBA =             (WM_CAP_START+  25) ;

  const WM_CAP_EDIT_COPY =                 (WM_CAP_START+  30) ;
  const WM_CAP_SET_AUDIOFORMAT =           (WM_CAP_START+  35) ;
  const WM_CAP_GET_AUDIOFORMAT =           (WM_CAP_START+  36) ;

  const WM_CAP_GET_VIDEOFORMAT  =          (WM_CAP_START+  44) ;
  const WM_CAP_SET_VIDEOFORMAT  =          (WM_CAP_START+  45) ;

  const WM_CAP_DLG_VIDEOFORMAT=            (WM_CAP_START+  41);
  const WM_CAP_DLG_VIDEOSOURCE=            (WM_CAP_START+  42);
  const WM_CAP_DLG_VIDEODISPLAY=           (WM_CAP_START+  43);
  const WM_CAP_DLG_VIDEOCOMPRESSION =      (WM_CAP_START+  46) ;

  const WM_CAP_SET_PREVIEW=                (WM_CAP_START+  50);
  const WM_CAP_SET_OVERLAY=                (WM_CAP_START+  51);
  const WM_CAP_SET_PREVIEWRATE =           (WM_CAP_START+  52);
  const WM_CAP_SET_SCALE =                 (WM_CAP_START+  53);
  const WM_CAP_GET_STATUS =                (WM_CAP_START+  54);
  const WM_CAP_SET_SCROLL  =               (WM_CAP_START+  55) ;

  const WM_CAP_GRAB_FRAME =                (WM_CAP_START+  60);
  const WM_CAP_GRAB_FRAME_NOSTOP =         (WM_CAP_START+  61) ;

  const WM_CAP_SEQUENCE  =                 (WM_CAP_START+  62) ;
  const WM_CAP_SEQUENCE_NOFILE =           (WM_CAP_START+  63) ;
  const WM_CAP_SET_SEQUENCE_SETUP =        (WM_CAP_START+  64) ;
  const WM_CAP_GET_SEQUENCE_SETUP =        (WM_CAP_START+  65) ;

  const WM_CAP_STOP =                      (WM_CAP_START+  68)  ;
  const WM_CAP_ABORT =                     (WM_CAP_START+  69)  ;

  const WM_CAP_SET_MCI_DEVICEA =           (WM_CAP_START+  66);
  const WM_CAP_GET_MCI_DEVICEA =           (WM_CAP_START+  67);

  const WM_CAP_SINGLE_FRAME_OPEN =         (WM_CAP_START+  70) ;
  const WM_CAP_SINGLE_FRAME_CLOSE =        (WM_CAP_START+  71) ;
  const WM_CAP_SINGLE_FRAME  =             (WM_CAP_START+  72) ;

  const WM_CAP_PAL_OPENA  =                (WM_CAP_START+  80) ;
  const WM_CAP_PAL_SAVEA  =                (WM_CAP_START+  81);
  const WM_CAP_PAL_PASTE  =                (WM_CAP_START+  82) ;
  const WM_CAP_PAL_AUTOCREATE =            (WM_CAP_START+  83) ;
  const WM_CAP_PAL_MANUALCREATE  =         (WM_CAP_START+  84) ;
  const WM_CAP_SET_CALLBACK_CAPCONTROL =   (WM_CAP_START+  85) ;

  type
    TCapturedStringList=array [0..9] of string;

  type
    TCapture=class;

    Callback_Video=procedure (AOwner:TCapture; vHeader:pVIDEOHDR) of object;
    Callback_Control=function (AOwner:TCapture; nState:cardinal):longbool of object;
    Callback_Error_Status=procedure (AOwner:TCapture; nId:Cardinal; nDescription:pansichar) of object;

    TCapture=class

  private
    wParentW:cardinal;
    wX,wY,wCX,wCY:cardinal;
    wStyle:cardinal;
    wName:string;
    wHandle:cardinal;
    wRate:cardinal;
    wPrev:longbool;
    wIdx:cardinal;
    wScale:longbool;
    wOverlay:longbool;
    wAlloc:cardinal;
    wSingleFrm:longbool;

    cbVideoStream:Callback_Video;
    cbFrame:Callback_Video;
    cbCapCtrl:Callback_Control;
    cbError:Callback_Error_Status;
    cbStatus:Callback_Error_Status;

  protected
    procedure SetPreview (sPrev:longbool);
    procedure SetScale (sScale:longbool);
    procedure SetOverlay (sOverlay:longbool);
    procedure SetName (const sName:string);
    procedure SetCapFile (const sName:string);
    function GetCapFile:string;
    procedure SetX (X:cardinal);
    procedure SetY (Y:cardinal);
    procedure SetCX (CX:cardinal);
    procedure SetCY (CY:cardinal);
    procedure BoundWindow;
    procedure SetAllocFile(sLen:cardinal);
    procedure SetSingleFrame(sFrame:longbool);
    function GetInit:longbool;

  public
    function CreateCaptureWindow(ParentHandle:cardinal):longbool;
    procedure Show;
    function Connect(index:cardinal):longbool;
    function Disconnect:longbool;

    function SetCaptureFileInfoChunk (const infoChunk:CAPINFOCHUNK):longbool;
    function SetPreviewRate(FrameRate:cardinal):longbool;
    procedure Scroll (X,Y:cardinal); stdcall;

    property Preview:longbool read wPrev write SetPreview;
    property Scale:longbool read wScale write SetScale;
    property Overlay:longbool read wOverlay write SetOverlay;
    property SingleFrameCapture:longbool read wSingleFrm write SetSingleFrame;
    property CaptureFilename:string read GetCapFile write SetCapFile;
    property PreallocateCaptureFile:cardinal read wAlloc write SetAllocFile;
    property Initialized:longbool read GetInit;
    procedure VideoSourceDialog;
    procedure VideoDisplayDialog;
    procedure VideoFormatDialog;

    function VideoBufferToClipboard:longbool;

    function FrameToBitmapFile (const fileName:string):longbool;
    function FrameToJpgFile(const fileName: string; const bmpName: string; jpgCompression: integer): longbool;
    function FrameStill:longbool;
    function CaptureStartSingleFrame:longbool;

    class function GetIndexedCaptureDrivers (var names, descriptions:TCapturedStringList):longbool;

    function GetCurrentCaptureDriver (var DriverName,DriverDescription:string) :longbool;
    function GetCurrentIndexedDeviceCapabilities(var DevCap:CAPDRIVERCAPS):longbool;
    function GetStatus (var cap:CAPSTATUS):longbool;
    function GetVideoFormat (var bmpInfo:BITMAPINFO):longbool;
    function SetVideoFormat (const bmpInfo:BITMAPINFO):longbool;
    function GetCaptureSettings (var captureSettings:CAPTUREPARMS):longbool;
    function SetCaptureSettings (const captureSettings:CAPTUREPARMS):longbool;

    destructor Destroy;

    procedure SetWindowBound(X,Y,Width,Height:cardinal);

    property X:cardinal read wX write SetX;
    property Y:cardinal read wY write SetY;
    property Width:cardinal read wCX write SetCx;
    property Height:cardinal read wCY write SetCy;
    property Handle:cardinal read wHandle;
    property WindowName:string read wName write SetName;

    property CallBackVideoStream:Callback_Video write cbVideoStream;
    property CallBackFrame:Callback_Video write cbFrame;
    property CallBackCaptureControl:Callback_Control write cbCapCtrl;
    property CallBackError:Callback_Error_Status write cbError;
    property CallBackStatus:Callback_Error_Status write cbStatus;
end;

implementation

{ TCapture }
function TCapture.Connect(index:cardinal): longbool;
begin
  result := longbool(SendMessage (wHandle, WM_CAP_DRIVER_CONNECT, index, 0));
  if result then
    wIdx := index;
end;

function TCapture.Disconnect: longbool;
begin
  result := longbool(SendMessage (wHandle, WM_CAP_DRIVER_DISCONNECT, wIdx, 0));
end;

function TCapture.SetPreviewRate(frameRate:cardinal):longbool;
begin
  result := longbool(SendMessage (wHandle, WM_CAP_SET_PREVIEWRATE, frameRate, 0));
  if result then
    wRate := frameRate;
end;

function TCapture.CreateCaptureWindow(ParentHandle:cardinal):longbool;
begin
  if wHandle = 0 then
  begin
    wParentW := ParentHandle;
    if wParentW <> 0 then
      wStyle := wStyle or WS_CHILD;

    wHandle := capCreateCaptureWindowA(pointer(wName), wStyle, wX, wY, wCx, wCy, wParentW, 0);
    result := longbool(wHandle);
    if result then
    begin
      SetProp(WHandle,PAnsiChar('OwnerObject'),Integer(Pointer(self)));
      SendMessage (wHandle, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, Integer(Addr(VideoStreamCallback)));
      SendMessage (wHandle, WM_CAP_SET_CALLBACK_FRAME, 0, Integer(Addr(FrameCallback)));
      SendMessage (wHandle, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, Integer(Addr(CapControlCallback)));
      SendMessage (wHandle, WM_CAP_SET_CALLBACK_ERRORA, 0, Integer(Addr(ErrorCallback)));
      SendMessage (wHandle, WM_CAP_SET_CALLBACK_STATUSA, 0, Integer(Addr(StatusCallback)));
    end;
  end;
end;

destructor TCapture.Destroy;
begin
  if wHandle <> 0 then
  begin
    Disconnect;
    RemoveProp(wHandle, PAnsiChar('OwnerObject'));
    DestroyWindow(wHandle);
    wHandle := 0;
  end;
end;

procedure TCapture.Show;
begin
  ShowWindow(wHandle, 1);
end;

class function TCapture.GetIndexedCaptureDrivers(var names, descriptions: TCapturedStringList): longbool;
var
  x    :cardinal;
  lLen :cardinal;
begin
  for x := 0 to 9 do
  begin
    setLength(names[x],256);
    setLength(descriptions[x],256);
    capGetDriverDescriptionA(x, Pointer(names[x]), 256, Pointer(descriptions[x]), 256);

    lLen := LStrLen(Pointer(names[x]));
    setLength(names[x], lLen);

    lLen := LStrLen(Pointer(descriptions[x]));
    setLength(descriptions[x], lLen);
  end;
end;

function TCapture.GetCurrentCaptureDriver (var driverName, driverDescription:string) :longbool;
var
  lLen :cardinal;
begin
  result := false;
  SetLength(driverName, 256);
  SetLength(driverDescription, 256);

  if SendMessage(wHandle, WM_CAP_DRIVER_GET_NAMEA, 256, Integer(Pointer(result))) = 0 then exit;
  lLen := LStrLen(Pointer(driverName));
  setLength(driverName, lLen);

  SendMessage(wHandle, WM_CAP_DRIVER_GET_VERSIONA, 256, Integer(Pointer(driverDescription)));
  lLen := LStrLen(Pointer(driverDescription));
  setLength(driverDescription, lLen);

  result := true;
end;

procedure TCapture.VideoSourceDialog;
begin
  SendMessage(wHandle, WM_CAP_DLG_VIDEOSOURCE, 0, 0);
end;

procedure TCapture.VideoDisplayDialog;
begin
  SendMessage(wHandle, WM_CAP_DLG_VIDEODISPLAY, 0, 0);
end;

procedure TCapture.VideoFormatDialog;
begin
  SendMessage(wHandle, WM_CAP_DLG_VIDEOFORMAT, 0, 0);
end;

function TCapture.GetCurrentIndexedDeviceCapabilities(var devCap:CAPDRIVERCAPS): longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_DRIVER_GET_CAPS, SizeOf(CAPDRIVERCAPS), Integer(Addr(devCap))));
end;

procedure TCapture.SetPreview(sPrev: longbool);
begin
  wPrev := sPrev;
  SendMessage(wHandle, WM_CAP_SET_PREVIEW, Integer(sPrev), 0);
end;

procedure TCapture.SetScale(sScale: longbool);
begin
  wScale := sScale;
  SendMessage(wHandle, WM_CAP_SET_SCALE, Integer(sScale), 0);
end;

procedure TCapture.SetOverlay(sOverlay: longbool);
begin
  wOverlay := sOverlay;
  SendMessage(wHandle, WM_CAP_SET_OVERLAY, Integer(sOverlay), 0);
end;

procedure TCapture.SetName(const sName: string);
begin
  wName := sName;
  if wHandle <> 0 then
    SetWindowText(wHandle,Pointer(sName));
end;

procedure TCapture.SetCapFile(const sName: string);
begin
  SendMessage(wHandle, WM_CAP_FILE_SET_CAPTURE_FILEA, 0, Integer(Pointer(sName)));
end;

function  TCapture.GetCapFile:string;
var
  lLen :cardinal;
begin
  SetLength(result, 1024);
  SendMessage(wHandle, WM_CAP_FILE_GET_CAPTURE_FILEA, 1024, Integer(Pointer(result)));
  lLen := LStrLen(Pointer(result));
  SetLength(result,llen);
end;

procedure TCapture.SetCX(CX: cardinal);
begin
  wCX := CX;
  BoundWindow;
end;

procedure TCapture.SetCY(CY: cardinal);
begin
  wCY := CY;
  BoundWindow;
end;

procedure TCapture.SetX(X: cardinal);
begin
  wX := X;
  BoundWindow;
end;

procedure TCapture.SetY(Y: cardinal);
begin
  wY := Y;
  BoundWindow;
end;

procedure TCapture.BoundWindow;
begin
  SetWindowPos(wHandle, 0, wX, wY, wCx, wCy, SWP_NOACTIVATE or SWP_NOOWNERZORDER or SWP_NOZORDER);
end;

procedure TCapture.SetWindowBound(X, Y, Width, Height: cardinal);
begin
  wX  := x;
  wY  := y;
  wCx := Width;
  wCy := Height;
  BoundWindow;
end;

procedure TCapture.SetAllocFile(sLen: cardinal);
begin
  if SendMessage(wHandle, WM_CAP_FILE_ALLOCATE, 0, sLen) <> 0 then wAlloc := sLen;
end;

function TCapture.GetStatus(var cap: CAPSTATUS): longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_GET_STATUS, SizeOf(CAPSTATUS), Integer(Addr(cap))));
end;

function TCapture.GetVideoFormat(var bmpInfo: BITMAPINFO): longbool;
begin
  result := LongBool(SendMessage (wHandle,WM_CAP_GET_VIDEOFORMAT, SizeOf(BITMAPINFO), Integer(Addr(bmpInfo))));
end;

function TCapture.SetVideoFormat(const bmpInfo: BITMAPINFO): longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_SET_VIDEOFORMAT, SizeOf(BITMAPINFO), Integer(Addr(bmpInfo))));
end;

procedure TCapture.Scroll(X,Y:cardinal);
begin
  SendMessage(wHandle, WM_CAP_SET_SCROLL, 0, Integer(Addr(X)));
end;

function TCapture.SetCaptureFileInfoChunk(const infoChunk: CAPINFOCHUNK):longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_FILE_SET_INFOCHUNK, 0, Integer(Addr(infoChunk))));
end;

function TCapture.GetCaptureSettings(var captureSettings: CAPTUREPARMS): longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_GET_SEQUENCE_SETUP, SizeOf(CAPTUREPARMS), Integer(Addr(captureSettings))));
end;

function TCapture.SetCaptureSettings(const captureSettings: CAPTUREPARMS): longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_SET_SEQUENCE_SETUP, SizeOf(CAPTUREPARMS), Integer(Addr(captureSettings))));
end;

function VideoStreamCallback(hWnd:cardinal;vHeader:pVIDEOHDR):cardinal; stdcall;
var
  owner:TCapture;
begin
  owner := TCapture(GetProp(hwnd,PAnsiChar('OwnerObject')));
  if assigned(owner.cbVideoStream) then
    owner.cbVideoStream(owner,vHeader);
end;

function FrameCallback(hWnd:cardinal; vHeader:pVIDEOHDR):cardinal; stdcall;
var
  owner:TCapture;
begin
  owner := TCapture(GetProp(hwnd, PAnsiChar('OwnerObject')));
  if assigned(owner.cbFrame) then
    owner.cbFrame(owner,vHeader);
end;

function CapControlCallback(hWnd, nState:cardinal):cardinal; stdcall;
var
  owner:TCapture;
begin
  owner := TCapture(GetProp(hWnd, PAnsiChar('OwnerObject')));
  if assigned(owner.cbCapCtrl) then
    result := cardinal(owner.cbCapCtrl(owner,nState))
  else
    result := $FFFFFFFF;
end;

function ErrorCallback(hWnd,nId:Cardinal; nDescription:PAnsiChar):cardinal; stdcall;
var
  owner:TCapture;
begin
  owner := TCapture(GetProp(hwnd,PAnsiChar('OwnerObject')));
  if assigned(owner.cbError) then
    owner.cbError(owner, nId, nDescription) ;
end;

function StatusCallback(hWnd,nId:Cardinal; nDescription:PAnsiChar):cardinal; stdcall;
var
  owner:TCapture;
begin
  owner := TCapture(GetProp(hwnd,PAnsiChar('OwnerObject')));
  if assigned(owner.cbStatus ) then
    owner.cbStatus(owner, nId, nDescription);
end;

procedure TCapture.SetSingleFrame(sFrame: longbool);
begin
  if sFrame then
  begin
    if SendMessage(wHandle, WM_CAP_SINGLE_FRAME_OPEN, 0, 0) = 0 then exit;
  end
  else
  begin
    if SendMessage(wHandle, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0) = 0 then exit;
  end;
  wSingleFrm := sFrame;
end;

function TCapture.CaptureStartSingleFrame: longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_SINGLE_FRAME, 0, 0));
end;

function TCapture.VideoBufferToClipboard: longbool;
begin
  result := LongBool(SendMessage(wHandle, WM_CAP_EDIT_COPY, 0, 0));
end;

function TCapture.FrameToBitmapFile(const fileName: string): longbool;
begin
   result := LongBool(SendMessage(wHandle,WM_CAP_FILE_SAVEDIBA,0,Integer(Pointer(fileName))));
end;

function TCapture.FrameToJpgFile(const fileName: string; const bmpName: string; jpgCompression: integer): longbool;
var
  tempBmp :TBitmap;
  jpgImage: TJpegImage;
begin
  try
    tempBmp := TBitmap.Create;
    tempBmp.SaveToFile(bmpName);
    if LongBool(SendMessage(wHandle,WM_CAP_FILE_SAVEDIBA,0,Integer(Pointer(bmpName)))) then
    begin
      jpgImage := TJpegImage.Create;
      tempBmp.LoadFromFile(bmpName);
      jpgImage.Assign(tempBmp);
      jpgImage.CompressionQuality := jpgCompression;
      jpgImage.SaveToFile(fileName);
      result := true;
    end
    else
      result := false;
  finally
    tempBmp.Free;
    jpgImage.Free;
  end;
end;

function TCapture.FrameStill: longbool;
begin
  result := LongBool(SendMessage(wHandle,WM_CAP_GRAB_FRAME,0,0));
  if result then
    wPrev := false;
end;

function TCapture.GetInit: longbool;
begin
  result := longbool(wHandle);
end;

end. 
Tale se v bistvu 'pogovarja' z WDM gonilnikom WebCam-a in lepo deluje z vsemi Logitech-ovimi, Trust-ovimi (in najbrz se s kaksnimi) WebCam-i...
Za Capture slikice pa ga klices nekako takole:

Koda: Izberi vse

 procedure TfrmCapture.SaveAsJPG(Sender: TObject);
var Rec  : TSearchRec;
    i    : integer;
begin
  if TCap.Initialized then
  begin

    if Length(Trim(jpgFilePrefix))=0 then
    begin
      MessageBox(handle, PAnsiChar('Nastavi ime JPG datoteke. '), PAnsiChar('Opozorilo'), MB_ICONWARNING);
      jpgFilePrefix := 'AL';
    end;

    jpgFileSufix := '????';
    jpgFileName := Trim(folder) + '\' + Trim(jpgFilePrefix) + Trim(jpgFileSufix) + '.jpg';
    if FindFirst(jpgFileName, faAnyFile - faDirectory, Rec) = 0 then
    try
      repeat
        jpgFileSufix := Rec.Name;
      until FindNext(Rec) <> 0;
    finally
      FindClose(Rec);
    end;
    if jpgFileSufix <> '????' then
    begin
      jpgFileSufix := LeftStr(jpgFileSufix, Pos('.',jpgFileSufix) - 1);
      jpgFileSufix := RightStr(jpgFileSufix, Length(jpgFileSufix) - Length(jpgFilePrefix));
      i := StrToInt(jpgFileSufix) + 1;
      jpgFileSufix := format('%.4d',[i]);
    end
    else
      jpgFileSufix := '0001';

    jpgFileName := Trim(folder) + '\' + Trim(jpgFilePrefix) + Trim(jpgFileSufix) + '.jpg';

    if not TCap.FrameToJpgFile(jpgFileName,'Temp.bmp',jpgCompression) then
      MessageBox(handle, PAnsiChar('Ne morem shraniti slike.'), PAnsiChar('Napaka'), MB_ICONWARNING)
    else
      reStatus.Lines.Add('Slika ' + jpgFileName + ' uspešno shranjena');

  end;
end;
 
Upam, da nisem mimo vsekal s tem postom, sem pa se prav pred kratkim s tem ukvarjal (sem moral naredit eno app, ki zajema jpg slikice z WebCam-a). Meni zelo lepo deluje...

LP, Gumby

Domen91
Prispevkov: 139
Pridružen: 27.07.2004 09:18:02

WebCam upravljanje, kako?

Odgovor Napisal/-a Domen91 » 10.07.2006 17:06:49

Gumby, a bi se dalo ta program in kodo ti poslat na moj e-mail naslov: domenc@web-boy.net, ker men neki noče complie.

Lepo prosim ter LP domen

G16
Prispevkov: 462
Pridružen: 11.02.2005 21:54:48

WebCam upravljanje, kako?

Odgovor Napisal/-a G16 » 18.10.2007 20:37:52

Ma sem kmalu ugotovu, da Twain ni to to. Ker poleg tega da je skrajno počasen, pa interface je nemogoč :P mi povrh vsega pa ne podpira vseh nastavitev, bolje rečeno niti resolucije ne moreš spremeniti programsko ( pač ni implementirano v gonilcih za to kamero).

No sem si pol downloadu Logitech QuickCam SDK.
Lepo inštaliram pa jasno nič ne dela. :o
Eni čist tretji dll-ji javljajo napake. Štala.. Ugotovim, da stvari že dolgo časa ne obnaljajo tako kot bi morali. Verzija SDK-ja je še vedno 1.0 in več kot 5 let stara.
No pa in sem le pogledal katere ActiveX mi je registriralo pri nalaganju gonilcev za kamero in najdem HPortal2.dll prevedem in ugotovim, da se vsebina bolj ali manj ujema s tisto v helpu za QuickCam SDK.

Uporabim komponento napišem..

Koda: Izberi vse

 
procedure TForm1.FormShow(Sender: TObject);
begin
  VideoPortal1.PrepareControl('QCSDK', 'HKEY_LOCAL_MACHINESoftwareQCSDK', 0);
  VideoPortal1.EnableUIElements(UIELEMENT_STATUSBAR, 0, 1);
  VideoPortal1.ConnectCamera(0);
  VideoPortal1.EnablePreview := 1;
end;
 
..in dela full hitr in z dostopom do funkcij, no ja vsaj tistih, ki so dokumentirane v QuickCam SDK.. :D


LP GJ
Ta tema je bila ustvarjena že nekaj časa nazaj a me vseeno zanima:
Kako bi lahko trenutno sliko shranil v TBitmap?
Napisal G16 (nekdanji G11,G14,G15°) Uporabljam: Delphi7 Ent.
http://delphi4u.awardspace.com/
Čas teče naprej...

M.C
Prispevkov: 630
Pridružen: 24.02.2003 14:27:43

WebCam upravljanje, kako?

Odgovor Napisal/-a M.C » 19.10.2007 10:03:34

ne najdem kje sem tole dobil, bla pa je ena nemška stran, rabiš videocap, avicap dcu:

Koda: Izberi vse

 
unit VideoCap;

 
interface  

 
uses Windows, Dialogs, Controls, SysUtils, StdCtrls, MMSystem, AviCap;  

 
const  
  MAXVIDDRIVERS = 10;  
  MS_FOR_15FPS  = 66;  
  MS_FOR_20FPS  = 50;  
  MS_FOR_30FPS  = 33;  
  MS_FOR_25FPS  = 20;    //(*)MCINIT(28.10.2005 10:31:21) rate in msec  

 
type  
  TCapStatusProc = procedure(Sender: TObject) of object;  

 
var  
  ghCapWnd                : THandle;  
  gCapVideoArea           : TWinControl;  
  gCapVideoDriverName     : string;  
  gdwCapNofMaxVideoFrame  : DWord;  
  gCapVideoFileName       : string;  
  gCapSingleImageFileName : string;  
  gCapVideoInfoLabel      : TLabel;  
  gCapStatusProcedure     : TCapStatusProc;  

 
  procedure CapSetVideoArea( Container: TWinControl );  
  procedure CapSetVideoFileName( FileName : string );  
  procedure CapSetSingleImageFileName( FileName : string );  
  procedure CapSetInfoLabel( InfoLabel : TLabel );  
  procedure CapSetStatusProcedure( StatusProc : TCapStatusProc );  

 
  function  CapOpenDriver : Boolean;  
  function  CapInitDriver( Index : Integer ): Boolean;  
  procedure CapCloseDriver;  
  procedure CapShow;  
  procedure CapSetCapSec( NofMaxVideoFrame : Integer );  
  procedure CapStart;  
  procedure CapStop;  
  function  CapHasDlgVFormat  : Boolean;  
  function  CapHasDlgVDisplay : Boolean;  
  function  CapHasDlgVSource  : Boolean;  
  procedure CapDlgVFormat;  
  procedure CapDlgVDisplay;  
  procedure CapDlgVSource;  
  procedure CapSetVideoOverlay;  
  procedure CapSetVideoLive;  
  procedure CapGrabSingleFrame;  

 
implementation  

 
(*---------------------------------------------------------------*)  
(*--- C A P - V I D E O  D R I V E R  ---*)  
(*---------------------------------------------------------------*)  

 
(*---------------------------------------------------------------*)  
procedure CapSetVideoArea( Container: TWinControl );  
begin  
  gCapVideoArea  := Container;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetVideoFileName( FileName : string );  
begin  
  gCapVideoFileName := FileName;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetSingleImageFileName( FileName : string );  
begin  
  gCapSingleImageFileName := FileName;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetInfoLabel( InfoLabel : TLabel );  
begin  
  gCapVideoInfoLabel := InfoLabel;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetStatusProcedure( StatusProc : TCapStatusProc );  
begin  
  gCapStatusProcedure := StatusProc;  
end;  

 
(*---------------------------------------------------------------*)  
(* -- Video For Windows Status Callback Function --- *)  
(*---------------------------------------------------------------*)  
function StatusCallbackProc(hWnd : HWND; nID : Integer; lpsz : LongInt): LongInt; stdcall;  
var  
  TmpStr     : string;  
  dwVideoNum : Integer;  
begin  
  //(*)MCINIT(28.10.2005 10:31:21)  hWnd:           Application main window handle  
  //(*)MCINIT(28.10.2005 10:31:21)  nID:            Status code for the current status  
  //(*)MCINIT(28.10.2005 10:31:21)  lpStatusText:   Status text string for the current status  

 
  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;  

 
    //(*)MCINIT(28.10.2005 10:31:21) Create the Video Capture Window  
  ghCapWnd := capCreateCaptureWindow( PChar('KruwoSoft'),  
              WS_CHILD or WS_VISIBLE, 0, 0,  
              gCapVideoArea.Width, gCapVideoArea.Height,  
              gCapVideoArea.Handle, 0);  
  if ghCapWnd <> 0 then  
  begin  
      //(*)MCINIT(28.10.2005 10:31:21) Install Status-Callback-Function  
    retc := capSetCallbackOnStatus(ghCapWnd, LongInt(0));  
    if retc <> 0 then  
    begin  
      retc := capSetCallbackOnStatus(ghCapWnd, LongInt(@StatusCallbackProc));  
      if retc <> 0 then  
      begin  
          //(*)MCINIT(28.10.2005 10:31:21) Open Installed Video Driver  
        DriverIndex := 0;  
        repeat  
          DriverStarted := CapInitDriver( DriverIndex );  
          if NOT DriverStarted then DriverIndex := DriverIndex + 1;  
        until (DriverStarted = TRUE) OR (DriverIndex >= MAXVIDDRIVERS);  

 
          //(*)MCINIT(28.10.2005 10:31:21) Keep Name of Video Driver  
        if capGetDriverDescription( DriverIndex,  
                                    achDeviceName,    80,  
                                    achDeviceVersion, 100 ) then  
        begin  
          gCapVideoDriverName := string(achDeviceName);  
        end;  

 
          //(*)MCINIT(28.10.2005 10:31:21) Set Capture FileName  
        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;  

 
(*---------------------------------------------------------------*)  
function CapInitDriver( Index : Integer ): Boolean;  
var  
  Retc             : LongInt;  
  CapParms         : TCAPTUREPARMS;  
begin  

 
   Result := FALSE;  
  if ghCapWnd = 0 then exit;  

 
    //(*)MCINIT(28.10.2005 10:31:21) Connect to Video Capture Driver  
  if capDriverConnect(ghCapWnd, Index) <> 0 then  
  begin  
    retc := capCaptureGetSetup(ghCapWnd, LongInt(@CapParms), sizeof(TCAPTUREPARMS));  
    if retc <> 0 then  
    begin  
//(*)MCINIT(28.10.2005 10:31:21)        CapParms.dwRequestMicroSecPerFrame := 40000;    //(*)MCINIT(28.10.2005 10:31:21) 25 FPS Requested capture rate  
//(*)MCINIT(28.10.2005 10:31:21)        CapParms.dwRequestMicroSecPerFrame := 100000;    //(*)MCINIT(28.10.2005 10:31:21) 10 FPS Requested capture rate  
      CapParms.dwRequestMicroSecPerFrame := 66667;    //(*)MCINIT(28.10.2005 10:31:21) 15 FPS Requested capture rate  
      CapParms.fLimitEnabled    := FALSE;  
      CapParms.fCaptureAudio    := FALSE;    //(*)MCINIT(28.10.2005 10:31:21) NO Audio  
      CapParms.fMCIControl      := FALSE;  
      CapParms.fYield           := TRUE;  
      CapParms.vKeyAbort        := VK_ESCAPE;  
      CapParms.fAbortLeftMouse  := FALSE;  
      CapParms.fAbortRightMouse := FALSE;  

 
      retc := capCaptureSetSetup(ghCapWnd, LongInt(@CapParms), sizeof(TCAPTUREPARMS));  
      if retc = 0 then exit;  
    end;  
    Result := TRUE;  
  end;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapCloseDriver;  
begin  
  if ghCapWnd <> 0 then  
  begin  
    capSetCallbackOnStatus(ghCapWnd, LongInt(0));  
    capDriverDisconnect( ghCapWnd );  
    DestroyWindow( ghCapWnd ) ;  
    ghCapWnd := 0;  
  end;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapShow;  
begin  
  if ghCapWnd = 0 then exit;  

 
     //(*)MCINIT(28.10.2005 10:31:21) Start Video overlay by default  
  capPreviewScale(ghCapWnd, 1);  
  capPreviewRate(ghCapWnd, MS_FOR_25FPS);  
  capOverlay(ghCapWnd, 0);  
  capPreview(ghCapWnd, 1);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetCapSec( NofMaxVideoFrame : Integer );  
begin  
  gdwCapNofMaxVideoFrame := DWord( NofMaxVideoFrame );  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapStart;  
begin  
  if ghCapWnd = 0 then exit;  
    //(*)MCINIT(28.10.2005 10:31:21) Start video capture to file  
  capCaptureSequence( ghCapWnd );  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapStop;  
begin  
  if ghCapWnd = 0 then exit;  
    //(*)MCINIT(28.10.2005 10:31:21) Stop video capture to file  
  capCaptureAbort(ghCapWnd);  
end;  

 
(*---------------------------------------------------------------*)  
function  CapHasDlgVFormat  : Boolean;  
var  
  CDrvCaps : TCapDriverCaps;  
begin  
  Result := TRUE;  
  if ghCapWnd = 0 then exit;  

 
  capDriverGetCaps(ghCapWnd, LongInt(@CDrvCaps), sizeof(TCapDriverCaps));  
  Result := CDrvCaps.fHasDlgVideoFormat;  
end;  

 
(*---------------------------------------------------------------*)  
function  CapHasDlgVDisplay : Boolean;  
var  
  CDrvCaps : TCapDriverCaps;  
begin  
  Result := TRUE;  
  if ghCapWnd = 0 then exit;  

 
  capDriverGetCaps(ghCapWnd, LongInt(@CDrvCaps), sizeof(TCapDriverCaps));  
  Result := CDrvCaps.fHasDlgVideoDisplay;  
end;  

 
(*---------------------------------------------------------------*)  
function  CapHasDlgVSource  : Boolean;  
var  
  CDrvCaps : TCapDriverCaps;  
begin  
  Result := TRUE;  
  if ghCapWnd = 0 then exit;  

 
  capDriverGetCaps(ghCapWnd, LongInt(@CDrvCaps), sizeof(TCapDriverCaps));  
  Result := CDrvCaps.fHasDlgVideoSource;  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapDlgVFormat;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capDlgVideoFormat(ghCapWnd);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapDlgVDisplay;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capDlgVideoDisplay(ghCapWnd);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapDlgVSource;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capDlgVideoSource(ghCapWnd);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetVideoOverlay;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capPreview(ghCapWnd, 0);  
  capOverlay(ghCapWnd, 1);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapSetVideoLive;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capOverlay(ghCapWnd, 0);  
  capPreviewScale(ghCapWnd, 1);  
  capPreviewRate(ghCapWnd, MS_FOR_25FPS);  
  capPreview(ghCapWnd, 1);  
end;  

 
(*---------------------------------------------------------------*)  
procedure CapGrabSingleFrame;  
var  
  achSingleFileName  : array [0..255] of Char;  
begin  
  if ghCapWnd = 0 then exit;  

 
  capGrabFrame(ghCapWnd);  
   StrPCopy(achSingleFileName, gCapSingleImageFileName);  
  capFileSaveDIB(ghCapWnd, LongInt(@achSingleFileName));  
end;  

 
initialization  
  ghCapWnd                := 0;  
  gCapVideoArea           := nil;  
  gCapVideoDriverName     := 'No Driver';  
  gdwCapNofMaxVideoFrame  := 0;  
  gCapVideoFileName       := 'Video.avi';  
  gCapSingleImageFileName := 'Image.bmp';  
  gCapVideoInfoLabel      := nil;  
  gCapStatusProcedure     := nil;  

 
end. 

Koda: Izberi vse

  

unit AviCap;

 
interface  

 
uses  
  Windows, MMSystem, Messages;

 
const  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  Window Messages  WM_CAP... which can be sent to an AVICAP window  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  

 
  //(*)MCINIT(28.10.2005 10:31:21) Defines start of the message range  
  WM_CAP_START                    = WM_USER;  

 
  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_ALLOCATE            = (WM_CAP_START+  22);  
  WM_CAP_FILE_SAVEAS              = (WM_CAP_START+  23);  
  WM_CAP_FILE_SET_INFOCHUNK       = (WM_CAP_START+  24);  
  WM_CAP_FILE_SAVEDIB             = (WM_CAP_START+  25);  

 
  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);  

 
    //(*)MCINIT(28.10.2005 10:31:21) Following added post VFW 1.1  
  WM_CAP_SET_CALLBACK_CAPCONTROL  = (WM_CAP_START+  85);  

 
  //(*)MCINIT(28.10.2005 10:31:21) Defines end of the message range  
  WM_CAP_END                      = WM_CAP_SET_CALLBACK_CAPCONTROL;  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  Message crackers for above  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
function capSetCallbackOnError (hwnd : THandle; fpProc:LongInt):LongInt;  
function capSetCallbackOnStatus(hwnd : THandle; fpProc:LongInt):LongInt;  
function capSetCallbackOnYield (hwnd : THandle; fpProc:LongInt):LongInt;  
function capSetCallbackOnFrame (hwnd : THandle; fpProc:LongInt):LongInt;  

 
function capSetCallbackOnVideoStream(hwnd:THandle; fpProc:LongInt):LongInt;  
function capSetCallbackOnWaveStream (hwnd:THandle; fpProc:LongInt):LongInt;  
function capSetCallbackOnCapControl (hwnd:THandle; fpProc:LongInt):LongInt;  
function capSetUserData(hwnd:THandle; lUser:LongInt):LongInt;  
function capGetUserData(hwnd:THandle):LongInt;  
function capDriverConnect(hwnd:THandle; I: Word) : LongInt;  

 
function capDriverDisconnect(hwnd:THandle):LongInt;  
function capDriverGetName(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  
function capDriverGetVersion(hwnd:THandle; szVer:LongInt; wSize:Word):LongInt;  
function capDriverGetCaps(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  

 
function capFileSetCaptureFile(hwnd:THandle; szName:LongInt):LongInt;  
function capFileGetCaptureFile(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  
function capFileAlloc(hwnd:THandle; dwSize:LongInt):LongInt;  
function capFileSaveAs(hwnd:THandle; szName:LongInt):LongInt;  
function capFileSetInfoChunk(hwnd:THandle; lpInfoChunk:LongInt):LongInt;  
function capFileSaveDIB(hwnd:THandle; szName:LongInt):LongInt;  

 
function capEditCopy(hwnd : THandle):LongInt;  

 
function capSetAudioFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
function capGetAudioFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
function capGetAudioFormatSize(hwnd:THandle):LongInt;  

 
function capDlgVideoFormat(hwnd:THandle):LongInt;  
function capDlgVideoSource(hwnd:THandle):LongInt;  
function capDlgVideoDisplay(hwnd:THandle):LongInt;  
function capDlgVideoCompression(hwnd:THandle):LongInt;  

 
function capGetVideoFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
function capGetVideoFormatSize(hwnd:THandle):LongInt;  
function capSetVideoFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  

 
function capPreview(hwnd:THandle; f:Word):LongInt;  
function capPreviewRate(hwnd:THandle; wMS:Word):LongInt;  
function capOverlay(hwnd:THandle; f:Word):LongInt;  
function capPreviewScale(hwnd:THandle; f:Word):LongInt;  
function capGetStatus(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
function capSetScrollPos(hwnd:THandle; lpP:LongInt):LongInt;  

 
function capGrabFrame(hwnd:THandle):LongInt;  
function capGrabFrameNoStop(hwnd:THandle):LongInt;  

 
function capCaptureSequence(hwnd:THandle):LongInt;  
function capCaptureSequenceNoFile(hwnd:THandle):LongInt;  
function capCaptureStop(hwnd:THandle):LongInt;  
function capCaptureAbort(hwnd:THandle):LongInt;  

 
function capCaptureSingleFrameOpen(hwnd:THandle):LongInt;  
function capCaptureSingleFrameClose(hwnd:THandle):LongInt;  
function capCaptureSingleFrame(hwnd:THandle):LongInt;  

 
function capCaptureGetSetup(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
function capCaptureSetSetup(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  

 
function capSetMCIDeviceName(hwnd:THandle; szName:LongInt):LongInt;  
function capGetMCIDeviceName(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  

 
function capPaletteOpen(hwnd:THandle; szName:LongInt):LongInt;  
function capPaletteSave(hwnd:THandle; szName:LongInt):LongInt;  
function capPalettePaste(hwnd:THandle):LongInt;  
function capPaletteAuto(hwnd:THandle; iFrames:Word; iColors:LongInt):LongInt;  
function capPaletteManual(hwnd:THandle; fGrab:Word; iColors:LongInt):LongInt;  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  Structures  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
type  
  PCapDriverCaps = ^TCapDriverCaps;  
  TCapDriverCaps = record  
    wDeviceIndex            :WORD;           //(*)MCINIT(28.10.2005 10:31:21) Driver index in system.ini  
    fHasOverlay             :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Can device overlay?  
    fHasDlgVideoSource      :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Has Video source dlg?  
    fHasDlgVideoFormat      :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Has Format dlg?  
    fHasDlgVideoDisplay     :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Has External out dlg?  
    fCaptureInitialized     :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Driver ready to capture?  
    fDriverSuppliesPalettes :BOOL;           //(*)MCINIT(28.10.2005 10:31:21) Can driver make palettes?  
    hVideoIn                :THANDLE;        //(*)MCINIT(28.10.2005 10:31:21) Driver In channel  
    hVideoOut               :THANDLE;        //(*)MCINIT(28.10.2005 10:31:21) Driver Out channel  
    hVideoExtIn             :THANDLE;        //(*)MCINIT(28.10.2005 10:31:21) Driver Ext In channel  
    hVideoExtOut            :THANDLE;        //(*)MCINIT(28.10.2005 10:31:21) Driver Ext Out channel  
  end;  

 
  PCapStatus = ^TCapStatus;  
  TCapStatus = packed record  
    uiImageWidth                :UINT;      //(*)MCINIT(28.10.2005 10:31:21) Width of the image  
    uiImageHeight               :UINT;      //(*)MCINIT(28.10.2005 10:31:21) Height of the image  
    fLiveWindow                 :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Now Previewing video?  
    fOverlayWindow              :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Now Overlaying video?  
    fScale                      :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Scale image to client?  
    ptScroll                    :TPOINT;    //(*)MCINIT(28.10.2005 10:31:21) Scroll position  
    fUsingDefaultPalette        :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Using default driver palette?  
    fAudioHardware              :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Audio hardware present?  
    fCapFileExists              :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Does capture file exist?  
    dwCurrentVideoFrame         :DWORD;     //(*)MCINIT(28.10.2005 10:31:21) # of video frames cap'td  
    dwCurrentVideoFramesDropped :DWORD;     //(*)MCINIT(28.10.2005 10:31:21) # of video frames dropped  
    dwCurrentWaveSamples        :DWORD;     //(*)MCINIT(28.10.2005 10:31:21) # of wave samples cap'td  
    dwCurrentTimeElapsedMS      :DWORD;     //(*)MCINIT(28.10.2005 10:31:21) Elapsed capture duration  
    hPalCurrent                 :HPALETTE;  //(*)MCINIT(28.10.2005 10:31:21) Current palette in use  
    fCapturingNow               :BOOL;      //(*)MCINIT(28.10.2005 10:31:21) Capture in progress?  
    dwReturn                    :DWORD;     //(*)MCINIT(28.10.2005 10:31:21) Error value after any operation  
    wNumVideoAllocated          :WORD;      //(*)MCINIT(28.10.2005 10:31:21) Actual number of video buffers  
    wNumAudioAllocated          :WORD;      //(*)MCINIT(28.10.2005 10:31:21) Actual number of audio buffers  
  end;  

 
  PCaptureParms = ^TCaptureParms;  
  TCaptureParms = record                    //(*)MCINIT(28.10.2005 10:31:21) Default values in parenthesis  
    dwRequestMicroSecPerFrame :DWORD;    //(*)MCINIT(28.10.2005 10:31:21) Requested capture rate  
    fMakeUserHitOKToCapture   :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Show "Hit OK to cap" dlg?  
    wPercentDropForError      :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Give error msg if > (10%)  
    fYield                    :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Capture via background task?  
    dwIndexSize               :DWORD;    //(*)MCINIT(28.10.2005 10:31:21) Max index size in frames (32K)  
    wChunkGranularity         :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Junk chunk granularity (2K)  
    fUsingDOSMemory           :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Use DOS buffers?  
    wNumVideoRequested        :WORD;     //(*)MCINIT(28.10.2005 10:31:21) # video buffers, If 0, autocalc  
    fCaptureAudio             :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Capture audio?  
    wNumAudioRequested        :WORD;     //(*)MCINIT(28.10.2005 10:31:21) # audio buffers, If 0, autocalc  
    vKeyAbort                 :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Virtual key causing abort  
    fAbortLeftMouse           :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Abort on left mouse?  
    fAbortRightMouse          :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Abort on right mouse?  
    fLimitEnabled             :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Use wTimeLimit?  
    wTimeLimit                :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Seconds to capture  
    fMCIControl               :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Use MCI video source?  
    fStepMCIDevice            :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Step MCI device?  
    dwMCIStartTime            :DWORD;    //(*)MCINIT(28.10.2005 10:31:21) Time to start in MS  
    dwMCIStopTime             :DWORD;    //(*)MCINIT(28.10.2005 10:31:21) Time to stop in MS  
    fStepCaptureAt2x          :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Perform spatial averaging 2x  
    wStepCaptureAverageFrames :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Temporal average n Frames  
    dwAudioBufferSize         :DWORD;    //(*)MCINIT(28.10.2005 10:31:21) Size of audio bufs (0 = default)  
    fDisableWriteCache        :BOOL;     //(*)MCINIT(28.10.2005 10:31:21) Attempt to disable write cache  
    AVStreamMaster            :WORD;     //(*)MCINIT(28.10.2005 10:31:21) Indicates whether the audio stream  
                                         //(*)MCINIT(28.10.2005 10:31:21)   controls the clock when writing an AVI file.  
  end;  

 
  PCapInfoChunk = ^TCapInfoChunk;  
  TCapInfoChunk = record  
    fccInfoID :FOURCC;     //(*)MCINIT(28.10.2005 10:31:21) Chunk ID, "ICOP" for copyright  
    lpData    :LongInt;   //(*)MCINIT(28.10.2005 10:31:21) pointer to data  
    cbData    :LongInt;   //(*)MCINIT(28.10.2005 10:31:21) size of lpData  
  end;  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  Callback Definitions  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
type  
  TCAPSTATUSCALLBACK  = function(hWnd:HWND; nID:Integer; lpsz:LongInt):LongInt; stdcall;  
  TCAPYIELDCALLBACK   = function(hWnd:HWND):LongInt; stdcall;  
  TCAPERRORCALLBACK   = function(hWnd:HWND; nID:Integer; lpsz:LongInt):LongInt; stdcall;  
  TCAPVIDEOCALLBACK   = function(hWnd:HWND; lpVHdr:LongInt):LongInt; stdcall;  
  TCAPWAVECALLBACK    = function(hWnd:HWND; lpWHdr:LongInt):LongInt; stdcall;  
  TCAPCONTROLCALLBACK = function(hWnd:HWND; nState:Integer):LongInt; stdcall;  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  CapControlCallback states  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
Const  
  CONTROLCALLBACK_PREROLL         = 1;  //(*)MCINIT(28.10.2005 10:31:21) Waiting to start capture  
  CONTROLCALLBACK_CAPTURING       = 2;   //(*)MCINIT(28.10.2005 10:31:21) Now capturing  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21)  The only exported functions from AVICAP.DLL  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  function capCreateCaptureWindow (  
              lpszWindowName  : PChar;  
              dwStyle         : DWord;  
               x, y            : Integer;  
              nWidth, nHeight : Integer;  
              hwndParent      : THandle;  
              nID             : Integer ) : THandle; stdcall;  

 
  function capGetDriverDescription (  
              wDriverIndex : DWord;  
              lpszName     : PChar;  
              cbName       : Integer;  
              lpszVer      : PChar;  

 
              cbVer        : Integer ) : Boolean; stdcall;  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21) New Information chunk IDs  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
(*  
  infotypeDIGITIZATION_TIME  = mmioStringToFOURCC(PChar('IDIT'), MMIO_TOUPPER);  
  infotypeSMPTE_TIME         = mmioStringToFOURCC(PChar('ISMP'), MMIO_TOUPPER);  
*)  

 
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
  //(*)MCINIT(28.10.2005 10:31:21) String IDs from status and error callbacks  
  //(*)MCINIT(28.10.2005 10:31:21) ------------------------------------------------------------------  
Const  
  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." *)  

 
const  
  AVICAP32 = 'AVICAP32.dll';  

 
implementation  

 
(* Externals from AVICAP.DLL *)  
function capGetDriverDescription; external AVICAP32 name 'capGetDriverDescriptionA';  
function capCreateCaptureWindow;  external AVICAP32 name 'capCreateCaptureWindowA';  

 

 
(* Message crackers for above *)  
function capSetCallbackOnError(hwnd : THandle; fpProc:LongInt) : LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_ERROR, 0, fpProc);  
end;  

 
function capSetCallbackOnStatus(hwnd : THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_STATUS, 0, fpProc);  
end;  

 
function capSetCallbackOnYield (hwnd : THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_YIELD, 0, fpProc);  
end;  

 
function capSetCallbackOnFrame (hwnd : THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_FRAME, 0, fpProc);  
end;  

 
function capSetCallbackOnVideoStream(hwnd:THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_VIDEOSTREAM, 0, fpProc);  
end;  

 
function capSetCallbackOnWaveStream (hwnd:THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_WAVESTREAM, 0, fpProc);  
end;  

 
function capSetCallbackOnCapControl (hwnd:THandle; fpProc:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_CALLBACK_CAPCONTROL, 0, fpProc);  
end;  

 
function capSetUserData(hwnd:THandle; lUser:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_USER_DATA, 0, lUser);  
end;  

 
function capGetUserData(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_USER_DATA, 0, 0);  
end;  

 
function capDriverConnect(hwnd:THandle; I: Word) : LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DRIVER_CONNECT, I, 0);  
end;  

 
function capDriverDisconnect(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DRIVER_DISCONNECT, 0, 0);  
end;  

 
function capDriverGetName(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DRIVER_GET_NAME, wSize, szName);  
end;  

 
function capDriverGetVersion(hwnd:THandle; szVer:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DRIVER_GET_VERSION, wSize, szVer);  
end;  

 
function capDriverGetCaps(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DRIVER_GET_CAPS, wSize, s);  
end;  

 
function capFileSetCaptureFile(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_SET_CAPTURE_FILE, 0, szName);  
end;  

 
function capFileGetCaptureFile(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_GET_CAPTURE_FILE, wSize, szName);  
end;  

 
function capFileAlloc(hwnd:THandle; dwSize:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_ALLOCATE, 0, dwSize);  
end;  

 
function capFileSaveAs(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_SAVEAS, 0, szName);  
end;  

 
function capFileSetInfoChunk(hwnd:THandle; lpInfoChunk:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_SET_INFOCHUNK, 0, lpInfoChunk);  
end;  

 
function capFileSaveDIB(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_FILE_SAVEDIB, 0, szName);  
end;  

 
function capEditCopy(hwnd : THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_EDIT_COPY, 0, 0);  
end;  

 
function capSetAudioFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_AUDIOFORMAT, wSize, s);  
end;  

 
function capGetAudioFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_AUDIOFORMAT, wSize, s);  
end;  

 
function capGetAudioFormatSize(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_AUDIOFORMAT, 0, 0);  
end;  

 
function capDlgVideoFormat(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DLG_VIDEOFORMAT, 0, 0);  
end;  

 
function capDlgVideoSource(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DLG_VIDEOSOURCE, 0, 0);  
end;  

 
function capDlgVideoDisplay(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DLG_VIDEODISPLAY, 0, 0);  
end;  

 
function capDlgVideoCompression(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_DLG_VIDEOCOMPRESSION, 0, 0);  
end;  

 
function capGetVideoFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_VIDEOFORMAT, wSize, s);  
end;  

 
function capGetVideoFormatSize(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_VIDEOFORMAT, 0, 0);  
end;  

 
function capSetVideoFormat(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_VIDEOFORMAT, wSize, s);  
end;  

 
function capPreview(hwnd:THandle; f:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_PREVIEW, f, 0);  
end;  

 
function capPreviewRate(hwnd:THandle; wMS:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_PREVIEWRATE, wMS, 0);  
end;  

 
function capOverlay(hwnd:THandle; f:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_OVERLAY, f, 0);  
end;  

 
function capPreviewScale(hwnd:THandle; f:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_SCALE, f, 0);  
end;  

 
function capGetStatus(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_STATUS, wSize, s);  
end;  

 
function capSetScrollPos(hwnd:THandle; lpP:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_SCROLL, 0, lpP);  
end;  

 
function capGrabFrame(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GRAB_FRAME, 0, 0);  
end;  

 
function capGrabFrameNoStop(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GRAB_FRAME_NOSTOP, 0, 0);  
end;  

 
function capCaptureSequence(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SEQUENCE, 0, 0);  
end;  

 
function capCaptureSequenceNoFile(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SEQUENCE_NOFILE, 0, 0);  
end;  

 
function capCaptureStop(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_STOP, 0, 0);  
end;  

 
function capCaptureAbort(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_ABORT, 0, 0);  
end;  

 
function capCaptureSingleFrameOpen(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SINGLE_FRAME_OPEN, 0, 0);  
end;  

 
function capCaptureSingleFrameClose(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SINGLE_FRAME_CLOSE, 0, 0);  
end;  

 
function capCaptureSingleFrame(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SINGLE_FRAME, 0, 0);  
end;  

 
function capCaptureGetSetup(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_SEQUENCE_SETUP, wSize, s);  
end;  

 
function capCaptureSetSetup(hwnd:THandle; s:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_SEQUENCE_SETUP, wSize, s);  
end;  

 
function capSetMCIDeviceName(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_SET_MCI_DEVICE, 0, szName);  
end;  

 
function capGetMCIDeviceName(hwnd:THandle; szName:LongInt; wSize:Word):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_GET_MCI_DEVICE, wSize, szName);  
end;  

 
function capPaletteOpen(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_PAL_OPEN, 0, szName);  
end;  

 
function capPaletteSave(hwnd:THandle; szName:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_PAL_SAVE, 0, szName);  
end;  

 
function capPalettePaste(hwnd:THandle):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_PAL_PASTE, 0, 0);  
end;  

 
function capPaletteAuto(hwnd:THandle; iFrames:Word; iColors:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_PAL_AUTOCREATE, iFrames, iColors);  
end;  

 
function capPaletteManual(hwnd:THandle; fGrab:Word; iColors:LongInt):LongInt;  
begin  
  Result := SendMessage(hwnd, WM_CAP_PAL_MANUALCREATE, fGrab, iColors);  
end;  

 

 
end. 

in potem na formi nekaj v temle smislu:

Koda: Izberi vse

  

procedure TFormProdajaKartA.StartVideoPreview;
var  
	MyCapStatusProc : TCapStatusProc;
begin
	CapCloseDriver();

	//(*)MCINIT(28.10.2005 10:31:21) Start CAP -  Video
	CapSetVideoArea(PanelVideo);
	CapSetInfoLabel(Label12);
	MyCapStatusProc := CAPStatus;
	CapSetStatusProcedure(MyCapStatusProc);

	if CapOpenDriver then
	begin
		CapSetCapSec(15 * 3);
		CapShow;
	end;
end;


  procedure TFormProdajaKartA.ButtonSaveClick(Sender: TObject);
var
  panelDC:HDC;
	destBitmap: Tbitmap;
begin

  {
  destBitmap := TBitmap.Create;
  destBitmap.HandleType := bmDIB ;

	destBitmap.Width := PanelVideo.Width;
	destBitmap.Height := PanelVideo.Height;
  destBitmap.Canvas.FillRect(ClientRect);//(*)MCINIT(28.10.2005 10:31:21) tole ima effect clear
	panelDC := getDc(PanelVideo.Handle);

	BitBlt(destBitmap.Canvas.Handle,0,0,destBitmap.Width, destBitmap.Height,panelDC,0,0,SRCCOPY);
	ImageFOTO.Canvas.FillRect(ClientRect);//(*)MCINIT(28.10.2005 10:31:21) tole ima effect clear

	destBitmap.SaveToFile('test.bmp');
	ImageFOTO.Picture.LoadFromFile('test.bmp');



	if ((Sender <> nil) and SavePictureDialog.Execute()) then
	begin
		destBitmap.SaveToFile(SavePictureDialog.FileName);
		EditFOTO.Text := SavePictureDialog.FileName;
	end;
  }
LP
Order is heavens first rule. Therefore some must be better than the rest.

G16
Prispevkov: 462
Pridružen: 11.02.2005 21:54:48

WebCam upravljanje, kako?

Odgovor Napisal/-a G16 » 03.01.2008 14:28:11

Sem uporabil kodo od M.C.- ja in sicer to:

Koda: Izberi vse

procedure TForm1.FormShow(Sender: TObject);
begin

  VideoPortal1.PrepareControl('QCSDK', 'HKEY_LOCAL_MACHINE\Software\QCSDK', 0);
  VideoPortal1.ConnectCamera(0);
  VideoPortal1.EnablePreview := 1;

end;
...

var
destBitmap: Tbitmap;
panelDC:HDC;
begin


  destBitmap := TBitmap.Create;
  destBitmap.HandleType := bmDIB ;

	destBitmap.Width := VideoPortal1.Width;
	destBitmap.Height := VideoPortal1.Height;
  destBitmap.Canvas.FillRect(ClientRect);
	panelDC := getDc(VideoPortal1.Handle);

	BitBlt(destBitmap.Canvas.Handle,0,0,destBitmap.Width, destBitmap.Height,panelDC,0,0,SRCCOPY);
Kod je delala izvrstno - na Logitech-ovi QuickCam. :D
Samo kasneje, ko sem menjaval web kamero, pa so nastale težave. VideoPortal ni več hotel zajemati slik.

Nova kamera:
Canyon camera web cnr-wcam413

Ali bi se dalo kako komponento pripraviti, do tega, da bi delovala tudi na tej kameri?

Za vse nasvete hvala.
Napisal G16 (nekdanji G11,G14,G15°) Uporabljam: Delphi7 Ent.
http://delphi4u.awardspace.com/
Čas teče naprej...

G16
Prispevkov: 462
Pridružen: 11.02.2005 21:54:48

WebCam upravljanje, kako?

Odgovor Napisal/-a G16 » 20.01.2008 15:53:08

Res nihče ne ve?
Napisal G16 (nekdanji G11,G14,G15°) Uporabljam: Delphi7 Ent.
http://delphi4u.awardspace.com/
Čas teče naprej...

MP002
Prispevkov: 735
Pridružen: 21.02.2002 15:39:44

WebCam upravljanje, kako?

Odgovor Napisal/-a MP002 » 21.01.2008 03:43:34

A si probu zgoraj omenjen DSPack?
Ima tud demo za zajem sličic.
Nisem še naletel na kamero (ali TV tuner), ki s tem neb delala.

Odgovori