[vtkusers] Some question of the using of vtkWin32VideoSource

zhangzhijun zjzhang at ee.cuhk.edu.hk
Mon May 21 11:37:34 EDT 2001


Dear all:
         When using the vtkWin32VideoSource, I find some question, I want to
know
whether you can help me to overcome them:
          I use this code to display a video from the camera, this is the
code:
I think every time when a vtkWin32VideoSource object is created , it must be
deleted
in the program otherwise the hardware will not be accessed next time when
the application
is executed. I encounter this kind of question, in which every time there
will be a
message box saying"can't find video hardware". because I use a for loop in
the
program and it seems it's a infinite loop because when I close the window,
and I open
the window again, I will be give this "can't find video hardware"
information . but How
to solve it?
void main( int argc, char *argv[] )
{
  vtkRenderer *ren = vtkRenderer::New();
  vtkRenderWindow *renWindow = vtkRenderWindow::New();
  renWindow->AddRenderer(ren);
  renWindow->SetSize( 320, 240 );
  vtkRenderWindowInteractor *Interactor=vtkRenderWindowInteractor::New();
  Interactor->SetRenderWindow(renWindow);
  vtkWin32VideoSource *videoSource=vtkWin32VideoSource::New();
  videoSource->SetFrameBufferSize(50);
  videoSource->SetNumberOfOutputFrames(50);
  videoSource->Grab();
  vtkImageViewer *imageViewer=vtkImageViewer::New();
  imageViewer->SetInput(videoSource->GetOutput());
  imageViewer->GetImageWindow()->DoubleBufferOn();
  imageViewer->SetColorWindow(255);
  imageViewer->SetColorLevel(127.5);
  imageViewer->SetZSlice(0);
  vtkImageData* imageData=vtkImageData::New();
  imageData=imageViewer->GetInput();
  vtkImageMapper* imageMapper=vtkImageMapper::New();
  imageMapper->SetInput(imageData);
  imageMapper->SetColorWindow(100);
  imageMapper->SetColorLevel(100);
  vtkActor2D *actor=vtkActor2D::New();
  actor->SetMapper(imageMapper);
  ren->AddActor(actor);
  for (int i=0;i=1;i++)
  {
  videoSource->Grab();
  renWindow->Render();
  }
  videoSource->Stop();
  if (videoSource)
   videoSource->Delete();
  if (imageViewer)
   imageViewer->Delete();
}


regards,
zj zhang





More information about the vtkusers mailing list