[Insight-users] Connecting Output from vtkWin32VideoSource to ITK

Luis Ibanez luis.ibanez at kitware.com
Tue Oct 20 18:57:06 EDT 2009


Hi Peter,

Passing the output of the vtkWin32VideoSource to
an ITK filter should work fine.

We have done that for IGSTK

                 http://www.igstk.org


In particular in the

         igstkWebcamWinVideoImager.cxx

and

           igstkWebCameraTracker.cxx


One of the key things to do, is to make the calls:

  videoSource->Grab();
  videoSource->UpdateWholeExtent();

Before you call Update() in the ITK filter that is receiving
the converted vtkImageData.

BTW in the code that you posted, I couldn't find any trace
of the vtkWin32VideoSource instance.

Maybe you posted an incomplete section of the code ?

So, your code,
doesn't seem to correspond to your question.


     Regards


            Luis


-------------------------------------------------------------------
On Tue, Oct 20, 2009 at 6:33 AM, PeterW <p.worel at ast-jena.de> wrote:
>
> Hello,
>
> I'm new in using ITK and VTK. I'm using vtkWin32VideoSource to grab images
> from a framegrabber and I want to use ITK filters on these images. The
> problem is to get ITK to work with VTK-images. I tried different approaches
> like the "itkVTKImageToImageFilter.h" /"itkImageToVTKImageFilter.h" or the
> "vtkKWImage.h"/"vtkKWImageIO.h" but I didn't get ITK to work with the input
> from VTK. I testet a few
> things like...
>
>        //WindowInteractor
>        vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>
>        //Bild einladen
>        //vtkJPEGReader *reader = vtkJPEGReader::New();
>        vtkBMPReader *reader = vtkBMPReader::New();
>        reader->SetFileName("D:/Tests/ITK+VTK-Test1/src/test24.bmp");
>
>        vtkImageCast *caster = vtkImageCast::New();
>        caster->SetInput(reader->GetOutput());
>        caster->SetOutputScalarTypeToFloat();
>        caster->Modified();
>        caster->Update();
>
>        //ITK-Part
>        typedef itk::Image<float, 2> ImageType;
>        typedef itk::VTKImageToImageFilter<ImageType> InputFilterType;
>        typedef itk::ImageToVTKImageFilter<ImageType> OutputFilterType;
>        //typedef itk::GradientMagnitudeImageFilter<ImageType,ImageType>
> FilterType;
>
>        InputFilterType::Pointer vtktoitk = InputFilterType::New();
>        OutputFilterType::Pointer itktovtk = OutputFilterType::New();
>        //FilterType::Pointer itkfilter1 = FilterType::New();
>
>        //VTK-Import
>        vtktoitk->SetInput(caster->GetOutput());
>        vtktoitk->GetImporter()->Update();
>        vtktoitk->Update();
>
>        //ITK-Filter1
>        //itkfilter1->SetInput(vtktoitk->GetOutput());
>        //itkfilter1->Update();
>
>        //VTK-Export
>        itktovtk->SetInput(vtktoitk->GetOutput());
>        itktovtk->Update();
>
>
>        //VTK-Part2
>
>        //Image-Viewer
>        vtkImageViewer *viewer = vtkImageViewer::New();
>        viewer->SetInput(itktovtk->GetOutput());
>        viewer->SetupInteractor(iren);
>        viewer->SetColorWindow(255);
>        viewer->SetColorLevel(128);
>        viewer->Render();
>
>        //Anzeigen
>        iren->Initialize();
>        iren->Start();
>
>        //Aufräumen
>        reader->Delete();
>        viewer->Delete();
>        iren->Delete();
>
> ...but I alway get exceptions in connection to itkLightObject. To read a
> file via ITK and manage the ouput with VTK is no problem but I want to
> achieve to use the input from vtkWin32VideoSource and I don't know a way to
> get ITK to work with a framegrabber, so I have to use VTK-input. Could be
> that I make a few poor mistakes, but I don't know how to get on with the
> problem. So can someone please help me?
> Thanks in avanced.
>
> Peter
>
> PS: Please excuse my poor English.
> --
> View this message in context: http://n2.nabble.com/Connecting-Output-from-vtkWin32VideoSource-to-ITK-tp3857870p3857870.html
> Sent from the ITK Insight Users mailing list archive at Nabble.com.
> _____________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the ITK FAQ at: http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list