<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.E-MailFormatvorlage17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 2.0cm 70.85pt;}
div.WordSection1
        {page:WordSection1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=DE link=blue vlink=purple>

<div class=WordSection1>

<p class=MsoNormal><span lang=EN-US>Hi all,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>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:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>// camPose: vtkMatrix4x4*</span><span
lang=EN-US><o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>double
viewPlaneNormal[3];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>double
focalPoint[3];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>double
viewUp[3];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  viewPlaneNormal[0]
= camPose-&gt;GetElement (2,0);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US> 
viewPlaneNormal[1] = camPose-&gt;GetElement (2,1);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US> 
viewPlaneNormal[2] = camPose-&gt;GetElement (2,2); <o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  // focal point<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  focalPoint[0]
= position[0] - viewPlaneNormal[0];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  focalPoint[1]
= position[1] - viewPlaneNormal[1];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  focalPoint[2]
= position[2] - viewPlaneNormal[2];<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  // ViewUp<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  viewUp[0] = camPose-&gt;GetElement
(1,0);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  viewUp[1] = camPose-&gt;GetElement
(1,1);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  viewUp[2] = camPose-&gt;GetElement
(1,2);<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>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<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>m_Renderer-&gt;GetActiveCamera()-&gt;Elevation(2.5);<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>m_Renderer-&gt;GetActiveCamera()-&gt;Azimuth(0.5);<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>the result is the one I want (the real
camera and the virtual camera are pretty good aligned). <o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Actually, the estimated camPose has a small
reprojection error, that`s why I suspect I have a mistake in setting up the
camera.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>The other thing which crossed my mind is
the calculation of the view angle which is implemented like this:<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US>  double
viewAngle = 2 * atan( ( height / 2 )  / m_FocalPoint[1] ) * 180 / vnl_math::pi;<o:p></o:p></span></p>

<p class=MsoNormal style='margin-left:35.4pt'><span lang=EN-US> 
m_Renderer-&gt;GetActiveCamera()-&gt;SetViewAngle(viewAngle);<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>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.<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Thanks in advance,<o:p></o:p></span></p>

<p class=MsoNormal><span lang=EN-US>Michael<o:p></o:p></span></p>

</div>

</body>

</html>