webcam

webcam

Postby Silvio » Fri Jan 19, 2007 10:52 am

can I link with two or four webcam into a program with the thefull class

I have a red i can link with IP address...

I wanted create a dialog with four webcam control : it is possible ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby karinha » Fri Jan 19, 2007 11:17 am

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7190
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Postby Silvio » Sat Jan 20, 2007 2:41 am

thank But I want insert 4 webcam into a window ...
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rochinha » Sat Jan 20, 2007 7:32 am

Silvio

You need create a small webcam capture service with webcam32.prg and install in other machines.

The machines will be capture images and save in a especific directory, ex: c:\webcams\01, c:\webcams\02, c:\webcams\03.

In the app with four bitmaps, you insert a refresh and load bitmaps in c:\webcams\01, c:\webcams\02, c:\webcams\03.

Or if your webcam works with a multicapture board, you can setup the outpu to pictures names numbered webcam1.jpg, webcam2.jpg, webcam3.jpg and show it in the dialog with bitmap controls.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Silvio » Sun Jan 21, 2007 12:24 am

CAN YOU SEND A SMALL TEST FOR IT
i WANTED ANIMATION FOR EACH WEBCAM...
i CAN INSERT 4 CAM ON 4 ip DIFFERENT
CAN i CALL ALL THEM IN A PROGRAM ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rochinha » Sun Jan 21, 2007 4:43 pm

Silvio

I'n not have a example but this code can help you:

See the line:

oCapture := TCapCapture():New( 25,25,320,240, oWnd , 0)

You can create other objects, just add new coords to new object

oCapture1 := TCapCapture():New( 25,25,320,240, oWnd , 0)
oCapture2 := TCapCapture():New( 350,300,320,240, oWnd , 0)

I can use VirtualCamera for test with this example.

Code: Select all  Expand view
/*
   Example the class TCapCapture for Fivewin
  (c)2003 by Rafa Carmona( Thefull )

  Software under Licencia GPL. http://www.gnu.org para saber mas.
           ( Tiene la misma exception que [x]Harbour )
*/

#INCLUDE "Fivewin.CH"

Function Main()
   Local a,x
   Local  oWnd, oCapture,  nRate := 10, oMenu, nFrames := 15
   LOCAL aDrivers
   LOCAL i

   MENU oMenu
        MENUITEM "FramesPerSec"   ACTION ( MsgGet("Frames","Frames Per Second:",@nFrames),oCapture:FramesPerSec(nFrames) )
        MENUITEM "Rate View"      ACTION ( MsgGet("Rate Preview","Rate Preview:",@nRate),oCapture:PreviewRate( nRate ))
        MENUITEM "Video Setup"    ACTION oCapture:SetupVideo()
        MENUITEM "Video Compress" ACTION oCapture:VideoCompression()
        MENUITEM "Start Capture"  ACTION (  oCapture:SetFile(".\pepe.avi") ,;
                                           oCapture:StartCapture() )
        MENUITEM "Stop Capture"   ACTION  oCapture:StopCapture()
   ENDMENU

   DEFINE WINDOW oWnd  TITLE "Cap-Fivewin (c)2003 by Rafa Carmona(Thefull)" MENU oMenu MDI

   oCapture := TCapCapture():New( 25,25,320,240, oWnd , 0)

   IF oCapture:Conect()
      oCapture:PreviewRate( nRate )
      oCapture:Preview(.T.)
     * oCapture:Overlay( .T. )
   ELSE
      ? "No connect.... ;( "
  *    oWnd:End()
   ENDIF


  // En fase de pruebas
  /*
  aDrivers := WC_Capturas()
  ? Len( aDrivers )

  for i := 1 to Len( aDrivers )
    ? "Driver: " + aDrivers[i][1] + "  Version: " + aDrives[i][2]
  next
*/
   ACTIVATE WINDOW oWnd

   oCapture:End()

Return NIL
/*
   Implemetation Class TCapCapture for Fivewin.
   (c)2003 by Rafa Carmona( Thefull )
   Beta 4

*/

CLASS TCapCapture FROM TControl

      CLASSDATA lRegistered AS LOGICAL
      DATA hWndC
      DATA nIndex INIT 0    // By Default index first found

      METHOD New() CONSTRUCTOR
      METHOD Conect()  INLINE  ConectDriver( ::hWndC, ::nIndex )
      METHOD End()     INLINE  DisConectDriver( ::hWndC )
      METHOD StartCapture()          INLINE Capture( ::hWndC )
      METHOD StopCapture()           INLINE CaptureStop( ::hWndC )
      METHOD Preview( lPreview )     INLINE CapPreview( ::hWndC, lPreview )
      METHOD PreviewRate( nRate )    INLINE CapPreviewRate( ::hWndC, nRate )
      METHOD PreViewScale( lScale )  INLINE CapPreviewScale( ::hWndC,lScale )
      METHOD CreateWndCapture()
      METHOD FileSaveAs( cFileName ) INLINE CapFileSaveAs( ::hWndC, cFilename )
      METHOD SetFile( cFile )        INLINE CapFileSetCaptureFile( ::hWndC, cFile )
      METHOD SetupCapture()          INLINE CapCaptureSetSetup( ::hWndC )
      METHOD SetupVideo()            INLINE SetupVideo( ::hWndC )
      METHOD Overlay( lMode )        INLINE CapOverlay( ::hWndC, lMode )
      METHOD FramesPerSec( nFrames ) INLINE CapFramesPerSec( ::hWndC, nFrames )
      METHOD VideoCompression()      INLINE CapDlgVideoCompression( ::hWndC )
      METHOD ListDrivers()

END CLASS



METHOD New( nTop, nLeft, nWidth, nHeight, oWnd , nIndex ) CLASS TCapCapture

   DEFAULT nTop := 0, nLeft := 0,;
           oWnd := GetWndDefault(),;
           nWidth := 200,;
           nHeight := 200

   ::nTop := nTop
   ::nLeft := nLeft
   ::nBottom   = ::nTop + nHeight - 1
   ::nRight    = ::nLeft + nWidth - 1
   ::nStyle    = nOR( WS_CHILD, WS_VISIBLE  )
   ::nId       = ::GetNewId()
   ::oWnd      = oWnd

   ::nIndex := nIndex

   ::Register( nOR( CS_VREDRAW, CS_HREDRAW ) )

   if ! Empty( oWnd:hWnd )
      ::Create()
      ::Default()
      ::lVisible = .t.
      oWnd:AddControl( Self )
   else
      oWnd:DefControl( Self )
*      ::lVisible  = .f.
   endif

   IF ::ListDrivers() > 0
      ::CreateWndCapture()
   ELSE
     ?"Not found Drivers..."
   ENDIF

return Self


METHOD ListDrivers() CLASS TCapCapture
   Local aDrivers :=  CapGetDrivers() , oCombo, cItem := ""
   Local oDlg
*  IF Len( aDrivers ) > 1 // Si hay mas de un driver , permite seleccionarlo
*     DEFINE Dialog oDlg TITLE  "Select Driver Capture"
      // Se produce un GPF. Adivina por que ;(
      * @1,1 COMBOBOX oCombo VAR cItem ITEMS aDrivers OF oDlg SIZE 100,100 ;
           *VALID ( ::nIndex := oCombo:nAt - 1,.t. )
*      ACTIVATE DIALOG oDlg
*   ENDIF

Return( Len( aDrivers ) )

METHOD CreateWndCapture() CLASS TCapCapture

::hWndC := CaptureWin( "My First Capture FROM FIVEH!!!", ::nStyle,;
                           ::nTop, ::nLeft, ::nWidth, ::nHeight, ::oWnd:hWnd, ::nIndex )


RETURN SELF



/*
   Implementation language C for [x]Harbour
   (c)2003 by Rafa Carmona ( Thefull )
   Beta 4
*/

#pragma BEGINDUMP

#include <windows.h>
#include <vfw.h>
#include "hbapi.h"


HB_FUNC( CAPTUREWIN )
{


  HWND VFWAPI hVentana =  capCreateCaptureWindow( hb_parc( 1 ), (DWORD) hb_parnl( 2 ),
                            hb_parni( 3 ) ,hb_parni( 4 ),hb_parni( 5 ),hb_parni( 6 ),
                            (HWND) hb_parnl( 7 ), hb_parni(8) ) ;

   hb_retnl( (LONG) hVentana ) ;

}

HB_FUNC( CAPTURE )
{

  hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_SEQUENCE, 0, 0L) );

}

HB_FUNC( CAPTURESTOP )
{
   hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_STOP, 0, 0L) );
}

HB_FUNC( CAPCAPTURESEQUENCENOFILE )
{
   hb_retl( capCaptureSequenceNoFile( (HWND) hb_parnl(1) ) );
}

HB_FUNC( CONECTDRIVER )
{
   // hb_retl( SendMessage ( (HWND) hb_parnl( 1 ), WM_CAP_DRIVER_CONNECT, 0 , 0L) );
   hb_retl( capDriverConnect( (HWND) hb_parnl( 1 ), hb_parni(2) ) );
}

HB_FUNC( DISCONECTDRIVER )
{
   hb_retl( capDriverDisconnect( (HWND) hb_parnl( 1 ) ));
}

HB_FUNC( CAPCAPTURESETSETUP )
{
   CAPTUREPARMS Capture;
   hb_retl( capCaptureSetSetup( (HWND) hb_parnl( 1 ), &Capture, sizeof( CAPTUREPARMS ) ));
}

HB_FUNC( CAPGRABFRAME )
{
   hb_retl( capGrabFrame( (HWND) hb_parnl( 1 ) ) );
}

HB_FUNC( CAPFILESAVEAS )
{
   hb_retl( capFileSaveAs( (HWND) hb_parnl(1), hb_parc( 2 )));
}

HB_FUNC( CAPFILESETCAPTUREFILE )
{
  BOOL fResult;
  fResult = capFileSetCaptureFile( (HWND)hb_parnl(1), (LPSTR) hb_parc(2) );
  // preallocate a file of 5 MB.
  capFileAlloc( (HWND) hb_parnl(1), (1024L * 1024L * 5));

  hb_retl( fResult );
}

HB_FUNC( CAPPREVIEW )
{
   hb_retl( capPreview( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ));
}

HB_FUNC( CAPPREVIEWSCALE )
{
   hb_retl( capPreviewScale( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ));
}

HB_FUNC( CAPPREVIEWRATE )
{
   hb_retl( capPreviewRate( (HWND) hb_parnl( 1 ), hb_parni( 2 ) ));
}


HB_FUNC( CAPDLGVIDEOSOURCE )
{
   hb_retl( capDlgVideoSource( (HWND) hb_parnl( 1 ) ) );
}

HB_FUNC( CAPDLGVIDEODISPLAY )
{
   hb_retl( capDlgVideoDisplay( (HWND) hb_parnl( 1 ) ) );
}

HB_FUNC( CAPDLGVIDEOCOMPRESSION )
{
   hb_retl( capDlgVideoCompression( (HWND) hb_parnl(1)) );
}

HB_FUNC( SETUPVIDEO )
{
   CAPDRIVERCAPS CapDriverCaps;
   CAPSTATUS CapStatus;

   capDriverGetCaps( (HWND) hb_parnl( 1 ), &CapDriverCaps, sizeof (CAPDRIVERCAPS));

   // Video source dialog box.
   if (CapDriverCaps.fHasDlgVideoSource)
       capDlgVideoSource( (HWND) hb_parnl( 1 ) );

   // Video format dialog box.
   if (CapDriverCaps.fHasDlgVideoFormat)
      {
       capDlgVideoFormat( (HWND) hb_parnl( 1 ) );

       // Are there new image dimensions?
       capGetStatus( (HWND) hb_parnl( 1 ), &CapStatus, sizeof (CAPSTATUS));
       // New Dimensions of Window
       SetWindowPos( (HWND) hb_parnl( 1 ), NULL, 0, 0, CapStatus.uiImageWidth,
                      CapStatus.uiImageHeight, SWP_NOZORDER | SWP_NOMOVE);

       // If so, notify the parent of a size change.
      }

    // Video display dialog box.
    if (CapDriverCaps.fHasDlgVideoDisplay)
        capDlgVideoDisplay( (HWND) hb_parnl( 1 ) );
}

HB_FUNC( CAPFRAMESPERSEC )  // hWnd, framesperSec
{
  CAPTUREPARMS CaptureParms;
  float FramesPerSec = (FLOAT)hb_parnl( 2 );

  capCaptureGetSetup( (HWND)hb_parnl(1), &CaptureParms, sizeof(CAPTUREPARMS));
  CaptureParms.dwRequestMicroSecPerFrame = (DWORD) (1.0e6 / FramesPerSec);
  hb_retl( capCaptureSetSetup( (HWND)hb_parnl(1), &CaptureParms, sizeof (CAPTUREPARMS)) );
}

HB_FUNC( CAPOVERLAY )
{
   CAPDRIVERCAPS CapDrvCaps;
   capDriverGetCaps( (HWND) hb_parnl( 1 ), &CapDrvCaps, sizeof (CAPDRIVERCAPS));

   if (CapDrvCaps.fHasOverlay)
       hb_retl( capOverlay( (HWND) hb_parnl( 1 ), hb_parl( 2 ) ) );
   else
       hb_retl( FALSE );
}

HB_FUNC( CAPGETDRIVERS )
{
  char szDeviceName[80];
  char szDeviceVersion[80];
  int wIndex;
  // Maximos dispositivos a tratar. Del 0...9
  hb_reta(10);

  for (wIndex = 0; wIndex < 10; wIndex++)
      {
       if (capGetDriverDescription (wIndex, szDeviceName,
           sizeof (szDeviceName), szDeviceVersion,
           sizeof (szDeviceVersion)))
        {
          // Append name to list of installed capture drivers
         // and then let the user select a driver to use.
         //MessageBox( GetActiveWindow(), szDeviceName, szDeviceVersion, MB_SYSTEMMODAL  );
         hb_storc( szDeviceName , -1, ( wIndex + 1 ) );
    }
    }

}

// Codigo por Jose Lalin en base de pruebas.
// Gracias Jose!!!

#include "hbapiitm.h"

HB_FUNC( WC_CAPTURAS )
{

  // He cambiado la declaracion porque capGetDrivers necesita un puntero
  // a la memoria donde almacenar szDeviceName y szDeviceVersion
  LPSTR szDeviceName[80];
  LPSTR szDeviceVersion[80];
  int wIndex;
  int wDevices;

  PHB_ITEM pReturn;

  for( wIndex = 0; wIndex < 10; wIndex++ )
  {
    if( capGetDriverDescription( wIndex, szDeviceName,
          sizeof( szDeviceName ), szDeviceVersion,
          sizeof( szDeviceVersion ) ) )
    {
      wDevices = wIndex + 1;

    }
  }


  pReturn = hb_itemArrayNew( wDevices  );

  for( wIndex = 0; wIndex <  wDevices ; wIndex++ )
  {
    if( capGetDriverDescription( wIndex, szDeviceName,
          sizeof( szDeviceName ), szDeviceVersion,
          sizeof( szDeviceVersion ) ) )
    {
      PHB_ITEM pDriver  = hb_itemPutC( NULL, (char*) szDeviceName );
      PHB_ITEM pVersion = hb_itemPutC( NULL, (char*) szDeviceVersion );
      PHB_ITEM pSub = hb_itemArrayNew( 2 );

      hb_itemArrayPut( pSub, 1, pDriver );
      hb_itemArrayPut( pSub, 2, pVersion );

      hb_itemRelease( pDriver );
      hb_itemRelease( pVersion );

      hb_itemArrayPut( pReturn, wIndex + 1, pSub );

      hb_itemRelease( pSub );

    }
  }

  hb_itemReturn( pReturn );
  hb_itemRelease( pReturn );
}

#pragma ENDDUMP
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Silvio » Sun Jan 21, 2007 11:17 pm

oCapture := TCapCapture():New( 25,25,320,240, oWnd , 0)
oCapture1 := TCapCapture():New( 350,25,320,240, oWnd , 0)
oCapture2 := TCapCapture():New( 675,25,320,240, oWnd , 0)

when I must connect a cam
I must write it for each cam

IF oCapture:Conect()
oCapture:PreviewRate( nRate )
oCapture:Preview(.T.)
* oCapture:Overlay( .T. )
ELSE
? "No connect.... ;( "
* oWnd:End()
ENDIF

How I can connect to a IP to connect each cam ?

I can explain ..
on the same pc I can use only a driver for one cam ....
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rochinha » Mon Jan 22, 2007 11:38 pm

See

Configure each cam to save a file in a directory with names cam1.avi, cam2.avi, etc...

Put this code in your application:

Code: Select all  Expand view
oCapture:SetFile("directory\cam1.avi"); oCapture:StartCapture()
oCapture1:SetFile("directory\cam2.avi"); oCapture1:StartCapture()
oCapture2:SetFile("directory\cam3.avi"); oCapture2:StartCapture()


your pc 1 have one cam saving the file cam1.avi in ?:\directory
your pc 2 have one cam saving the file cam2.avi in ?:\directory
your pc 3 have one cam saving the file cam3.avi in ?:\directory

Your application capture this files and show in defined video areas on your code:

Code: Select all  Expand view
oCapture := TCapCapture():New( 25,25,320,240, oWnd , 0)
oCapture1 := TCapCapture():New( 350,25,320,240, oWnd , 0)
oCapture2 := TCapCapture():New( 675,25,320,240, oWnd , 0)


The example works with file and not work with IPs, sorry.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo

Postby Silvio » Tue Jan 23, 2007 9:34 am

ok but can I installed 3 or four cam into a pc or use in a pc webcam installed on other pc and use it on tcip or tsocket ?
?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Postby Rochinha » Wed Jan 24, 2007 1:14 am

At your criteria.

The solution below use fixed files in one shared pc on a lan.

If you need use internet or intranet you can use stream, TActivex and Media Player and Windows Media Encoder.

The solution is here:

Creating a web cam feed with WME.
Rochinha
 
Posts: 309
Joined: Sun Jan 08, 2006 10:09 pm
Location: Brasil - Sao Paulo


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 22 guests