[vtkusers] Win32VideoSource usage

Simon DROUIN sdrouin at bic.mni.mcgill.ca
Mon Mar 29 10:26:07 EST 2004


Hi Francesco,

One thing is for sure: you don't need line:

camMapper->SetInput( cam->GetOutput() );

in you grabbing loop. When you call Grab(), the output of  cam will be 
modified and the Render command will force all the pipeline to update.

Some hints on why the grabbing might not work( warning: I'm not an 
expert. I've been using only vtkMILVideoSource):

1- (Sorry If it is obvious) Did you make sure video grabbing works with 
other VFW applications on your machine?

2- The vtkVideoSource sets the size of the image to to 320x240 by 
default. I know it is a pretty standard resolution, but are you sure 
your grabbing device supports it (or it might be VFW that does that)? I 
would try setting all the default parameters of cam when you know them.

3- Make sure your rendering pipeline works fine first: replace the 
vtkVideoSource object with, say, a vtkBMPReader that reads a BMP file of 
the same size as your video to make sure it is displayed correctly.

4- The grab function doesn't wait for the next frame: ie: is it possible 
that the 720 frames are displayed so fast that you don't even see them?

I'll let you know if I think of something else.

-simon


Francesco Caruso wrote:

> 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.
>
> _______________________________________________
> This is the private VTK discussion list. Please keep messages 
> on-topic. Check the FAQ at: <http://public.kitware.com/cgi-bin/vtkfaq>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>





More information about the vtkusers mailing list