Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Dec 23rd, 2006, 8:04 AM   #1
Martin Chrzan
Newbie
 
Join Date: Dec 2006
Posts: 1
Rep Power: 0 Martin Chrzan is on a distinguished road
Delphi and webcamera catching pictures

Hello! For my program I want to download pictures from webcam.I work in Delphi 7 and I(dont know where) red about unit AVICAP32.dll whitch contain this function. So I tried create simple program which by step show 100 pictures from webcam after I click button:

 
unit Main2;

interface

{-----------------------------------------------------------------------------}

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

{-----------------------------------------------------------------------------}

const
   WM_USER = 1024;
   WM_CAP_DRIVER_CONNECT = 1034;
   WM_CAP_DRIVER_DISCONNECT = 1035;
   WM_CAP_GET_FRAME = 1084;
   WM_CAP_COPY = 1054;

   WM_CAP_START = WM_USER;
   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;

  PICWIDTH      = 640;
  PICHEIGHT     = 480;

{-----------------------------------------------------------------------------}

type
  TfmMain = class(TForm)
    Panel1    : TPanel;
    Button2   : TButton;
    procedure FormDestroy  (Sender: TObject);
    procedure FormCreate   (Sender: TObject);
    procedure Button2Click (Sender: TObject);
  private
    FCapHandle    : THandle;
  public

  end;

{*****************************************************************************}

var
  fmMain: TfmMain;

{*****************************************************************************}

implementation

{$R *.dfm}


{-----------------------------------------------------------------------------}

function capCreateCaptureWindow(lpszWindowName: LPCSTR; dwStyle: DWORD;
           x, y, nWidth, nHeight: integer; hwndParent: HWND; nID: integer): HWND; stdcall;
  external 'AVICAP32.DLL' name 'capCreateCaptureWindowA';

//------------------------------------------------------------------------------

procedure TfmMain.FormCreate(Sender: TObject);
begin
  FCapHandle:= capCreateCaptureWindow('Video', WS_CHILD or WS_VISIBLE, 0, 0, PICWIDTH, PICHEIGHT, panel1.Handle, 1);

  SendMessage(FCapHandle, WM_CAP_DRIVER_CONNECT,0,0);
  SendMessage(FCapHandle, WM_CAP_DLG_VIDEOSOURCE,0,0);
  SendMessage(FCapHandle, WM_CAP_DLG_VIDEOFORMAT,0,0);

end;

{-----------------------------------------------------------------------------}

procedure TfmMain.FormDestroy(Sender: TObject);
begin
  SendMessage(FCapHandle,WM_CAP_DRIVER_DISCONNECT, 0, 0);
end;

{-----------------------------------------------------------------------------}

procedure TfmMain.Button2Click(Sender: TObject);
Var i:integer;
begin
For i:=1 to 100 do begin		//Only for testing
SendMessage(FCapHandle,WM_CAP_GET_FRAME, 0, 0); end;
end;

end.

Program is running but is it too slow. Per 1 second it show just about 5 pictures. Does is something wrong in my program or is it error of Delphi ? In the aggregate all this system of catching pictures to panel dont conform me. I need just read single pixels in picture and a dont need to show this picture. It will be the best if the picture are saveing to some memory (canvas) – maybe it will be faster...
Thanks for advice

Last edited by Martin Chrzan; Dec 23rd, 2006 at 8:27 AM.
Martin Chrzan is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC