[vtkusers] Reg vtkCamera and vtkimageviewer2 - No camera change reflected in the image

Anu anuradha.tcs at gmail.com
Mon Jan 18 04:10:57 EST 2010


I have a simple vtkImageViewer2 code displaying 3D data. I am trying to
display correct orientation due to ITK to vtk conversion.
but change in any of the variables of vtkCamera like viewUp is not reflected
in the image. Have tried to see user list but the code seems to be not
working.
Please help in finding whats wrong with the code.

*// Create Renderer*
vtkRenderer *ren1 = vtkRenderer::New();
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();

typedef unsigned short    PixelType;
const unsigned int      Dimension = 3;
typedef itk::Image< PixelType, Dimension >         ImageType;

*// Create the reader for the data*

typedef itk::ImageFileReader <ImageType> FileReaderType;
FileReaderType::Pointer reader = FileReaderType::New();
reader->SetFileName(argv[1]);
reader->Update();
   std::cout << "Reading and conversion Complete.." << std::endl;

*// ITK To VTK conversion*

typedef itk::ImageToVTKImageFilter <ImageType>   itktovtkConnectorType;
 itktovtkConnectorType::Pointer connector1_UC =
itktovtkConnectorType::New();
connector1_UC->SetInput(reader->GetOutput());
try
{
connector1_UC->Update();
}
catch(itk::ExceptionObject &e)
{
std::cout <<"excep in spacing"<< e<<std::endl;
}


    vtkImageViewer2 * viewer = vtkImageViewer2::New();
    viewer->SetupInteractor(iren );
    viewer->GetRenderWindow()->AddRenderer(ren1);
    viewer->SetInput( connector1_UC->GetOutput() );
    viewer->SetSlice(0);

vtkCamera *aCamera = vtkCamera::New();
aCamera->SetViewUp (0,-1, 0);
aCamera->SetPosition (0, 0, 1);
aCamera->SetFocalPoint (0, 0, 0);
viewer->GetRenderer()->SetActiveCamera(aCamera);
viewer->GetRenderer()->ResetCamera();

    viewer->SetColorWindow( 255 );
    viewer->SetColorLevel( 128 );
     viewer->Render();
     iren->Start();

return 0 ;

Thanks
Anu..
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100118/7473d491/attachment.htm>


More information about the vtkusers mailing list