[vtkusers] Storing SmartPointers in a vector

Alexis Cheng acheng_1221 at hotmail.com
Mon Feb 14 17:48:30 EST 2011


Hi all,

I'm attempting to grab a series of images from a real time source and store them into a vector for future processing. The problem that I am having is that when I try to access the vector, it returns an image from the real time source as opposed to the one that I had previously stored. Below is a sample of my code.

///////////////////////////////////////////
typedef itk::Image< unsigned char, 2 > FixedImageType;
typedef itk::VTKImageToImageFilter<FixedImageType> VTKImageToITKImageType;

vector<vtkSmartPointer<vtkImageData>> ImagePanorama;

                for (int i = 0; i < 50; i++)
                {
                    vtkSmartPointer<vtkImageData> USImageStitch = vtkSmartPointer<vtkImageData>::New();
                    USImageStitch->SetScalarTypeToUnsignedChar();
                    USImageStitch->SetDimensions(640,480,1);
                    USImageStitch->SetSpacing(1,1,1);
                    USImageStitch = sonixGrabber->GetOutput();
                    USImageStitch->Update();
                        
                    ImagePanorama.push_back(USImageStitch);
                    Sleep(100);
                }

                for (vector<vtkSmartPointer<vtkImageData>>::iterator PanoramaIterator = ImagePanorama.begin();PanoramaIterator < ImagePanorama.end()-1;PanoramaIterator++)
                {
                    VTKImageToITKImageType::Pointer VTKToITKConnector1 = VTKImageToITKImageType::New();
                    VTKToITKConnector1->SetInput(*PanoramaIterator);
                    VTKToITKConnector1->Update();

                    VTKImageToITKImageType::Pointer VTKToITKConnector2 = VTKImageToITKImageType::New();
                    VTKToITKConnector2->SetInput(*(PanoramaIterator+1));
                    VTKToITKConnector2->Update();
                }
//////////////////////////////////////////

The iterators are returning the real time image as opposed to the stored image. I'm not quite sure what the problem may be. Has anybody worked with smartpointers and vectors? Thank you all in advance.

Regards,
Alexis Cheng
Electrical Engineering
University of British Columbia
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20110214/84536508/attachment.htm>


More information about the vtkusers mailing list