[vtkusers] Win32VideoSource usage

Francesco Caruso guernika_devel at yahoo.it
Sun Mar 28 06:05:18 EST 2004


Hello,

I'm a newbye vtkuser.
I'm trying to display image grabbed by a webcam, but with no result :(
I get only a black window with no image in for a while...

Here  are sources of my little ( and useless ) application...

#include "vtkWin32VideoSource.h"
#include "vtkPolyDataMapper.h"
#include "vtkRenderWindow.h"
#include "vtkCamera.h"
#include "vtkActor.h"
#include "vtkRenderer.h"
#include "vtkWin32ImageMapper.h"
#include "vtkActor2D.h"

int main( int argc, char *argv[] )
{

   //vtkWin32VideoSource *cam = vtkWin32VideoSource::New();
   vtkVideoSource *cam = vtkVideoSource::New();  //In this way the
application run faster... why????
   //cam->Grab();                       I tried this too
   cam->SetPreview(1); // I can see preview, but only for a bit...

   vtkImageMapper *camMapper = vtkImageMapper::New();
   camMapper->SetInput( cam->GetOutput() );

   vtkActor2D *camActor = vtkActor2D::New();
   camActor->SetMapper( camMapper );

   vtkRenderer *ren1= vtkRenderer::New();
   ren1->AddActor2D( camActor );

   vtkRenderWindow *renWin = vtkRenderWindow::New();
   renWin->AddRenderer( ren1 );
   renWin->SetSize( 640, 480 );
    //renWin->SetFullScreen( 1 );

  int i;
  for (i = 0; i < 720; ++i)
    {
      cam->Grab();
      camMapper->SetInput( cam->GetOutput() );
      renWin->Render();
    }

  cam->Delete();
  camMapper->Delete();
  camActor->Delete();
  ren1->Delete();
  renWin->Delete();
  return 0;
}


Any hint???

Thanks in advance

bye.




More information about the vtkusers mailing list