[vtkusers] Homogeneous Transform Matrix to Camera Parameters
Müller Michael
michael.mueller at dkfz-heidelberg.de
Thu Aug 19 10:21:36 EDT 2010
Hi all,
i want to convert an estimated camera pose (for an augmented reality application) given as vtkMatrix4x4 to a vtkCamera`s position, focal-point and view-up vector. Position is trivial, but I have some doubts concerning the current calculation of the focal point and the viewUp vector which is as follows:
// camPose: vtkMatrix4x4*
double viewPlaneNormal[3];
double focalPoint[3];
double viewUp[3];
viewPlaneNormal[0] = camPose->GetElement (2,0);
viewPlaneNormal[1] = camPose->GetElement (2,1);
viewPlaneNormal[2] = camPose->GetElement (2,2);
// focal point
focalPoint[0] = position[0] - viewPlaneNormal[0];
focalPoint[1] = position[1] - viewPlaneNormal[1];
focalPoint[2] = position[2] - viewPlaneNormal[2];
// ViewUp
viewUp[0] = camPose->GetElement (1,0);
viewUp[1] = camPose->GetElement (1,1);
viewUp[2] = camPose->GetElement (1,2);
The problem is that the camera is slightly at the wrong position when using these calculated parameters. If I manually adjust the camera afterwards with
m_Renderer->GetActiveCamera()->Elevation(2.5);
m_Renderer->GetActiveCamera()->Azimuth(0.5);
the result is the one I want (the real camera and the virtual camera are pretty good aligned).
Actually, the estimated camPose has a small reprojection error, that`s why I suspect I have a mistake in setting up the camera.
The other thing which crossed my mind is the calculation of the view angle which is implemented like this:
double viewAngle = 2 * atan( ( height / 2 ) / m_FocalPoint[1] ) * 180 / vnl_math::pi;
m_Renderer->GetActiveCamera()->SetViewAngle(viewAngle);
So the question is if you see any obvious mistakes in these calculations or if you have any ideas why the camera is slightly misaligned.
Thanks in advance,
Michael
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100819/aa97f3d6/attachment.htm>
More information about the vtkusers
mailing list