[vtkusers] Display OpenCV Image (IplImage) in VTK

Anant Vemuri ajar108 at gmail.com
Fri May 7 05:12:11 EDT 2010


I have also been trying to interface both Iplimage and vtkimagedata. Here is
what I did

void fromIpl2Vtk( IplImage* _src, vtkImageData* _dest )
{
    vtkImageImport *importer = vtkImageImport::New();
    if ( _dest )
    {
        importer->SetOutput( _dest );
    }
    importer->SetDataSpacing( 1, 1, 1 );
    importer->SetDataOrigin( 0, 0, 0 );
    importer->SetWholeExtent(   0, _src->width-1, 0, _src->height-1, 0,
_src->nChannels-1 );
    importer->SetDataExtentToWholeExtent();
    importer->SetDataScalarTypeToUnsignedChar();
    importer->SetNumberOfScalarComponents( _src->nChannels );
    importer->SetImportVoidPointer( _src->imageData );
    importer->Update();
}

This works, but somehow vtk only recognizes the first channel  that is blue,
which is the first channel of IplImage (BGR...BGR...) ... I was wondering if
anyone had any suggestions to fix this.

thanks.


On Tue, May 4, 2010 at 3:02 PM, Samunda Perera <samunda_n at yahoo.com> wrote:

> Dear all,
>
> I have a pointer to a image stored in memory (example void* frame or
> similar data type obtained from opencv) .
> How to display this 2D image data as a image in VTK window?
>
> Thanks & Regards,
> Samu
>
>
> _______________________________________________
> 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 VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100507/bd7dc638/attachment.htm>


More information about the vtkusers mailing list