[vtkusers] VTK 4.0 , camera set-up and texture-mapping

Dorothy Wang dorothy.a.wang at imperial.ac.uk
Tue May 17 07:09:10 EDT 2005


Hello,

I am using VTK 4.0 under Redhat Linux 7.2. I have been trying to set up the
VTK camera using results from a camera calibration and to render a
texture-mapped plane into the scene. The texture used is an image taken with
the camera that I am trying to model. I have noticed that the rendered
texture-mapped plane is a stretched version of the original image. The
stretch seems to be parallel to the x-axis, with the y-axis as the invariant
line. The calculations used to set up the VTK camera have been checked and
seem fine.

I was wondering if anyone else has come across something similar or can see
if there is a camera variable that I have omitted to set? The relevant
section of my code, with the calculations that I use can be found below.

Any help is greatly appreciated.

Best wishes,

Dorothy


-------------------------------------------------------------------------
 // Results from camera calibration are:
 // fc(1) and fc(2) are the elements of the focal length vector
 // cc(1) and cc(2) are the elements of the principal point vector
 // nx is the width of the image (usually 720)
 // ny is the height of the image (usually 576)

 // Set Camera properties according to calibration results
 (renderer->GetActiveCamera())->SetPosition( 0, 0, 0 );
 (renderer->GetActiveCamera())->SetFocalPoint( 0, 0, 10000 );
 (renderer->GetActiveCamera())->SetViewUp( 0.0, -1.0, 0.0 );

 // (cc(1) - (nx-1)/2)/ fc(1)
 // corresponding calculation (but negate final value) for the second
element of vector
  (renderer->GetActiveCamera())->SetViewShear(-0.0084,0.0281, 0.0 );

 // (2 * atan((ny-1)/2 / fc(2)))/pi*180
 (renderer->GetActiveCamera())->SetViewAngle(33.2144 );

 (renderer->GetActiveCamera())->SetClippingRange( 40.0, 4000.0 );

 // 3000 x (nx-1)/2 / fc(1)
 float PlaneWid = 1224.6;

 // 3000 x (ny-1)/2 / fc(2)
 float PlaneHt = 896.5410;

 // ((nx-1)/2 - cc(1)) * 3000 / fc(1)
 // similar calculation for second element of vector
 vtkPlaneSource *plane = vtkPlaneSource::New();
 plane->SetOrigin( (25.3413 - PlaneWid), (84.3909 + PlaneHt), 3000.0 );
 plane->SetPoint1( (25.3413 + PlaneWid), (84.3909 + PlaneHt), 3000.0 );
 plane->SetPoint2( (25.3413 - PlaneWid), (84.3909 - PlaneHt), 3000.0 );

 //texture-mapping code follows...

 ---------------------------------------------------------------------------
--




More information about the vtkusers mailing list