<DIV >&nbsp;</DIV>
<DIV>Hi,</DIV>
<DIV>&nbsp;</DIV>
<DIV>I encoutered a strange problem. I need to reuse landmark registration for several times.</DIV>
<DIV>In FourViewsTrackingWithCT application, I see that when the second set of image and tracker</DIV>
<DIV>landmarks were set, the landmark registration could not give the correct result.</DIV>
<DIV>&nbsp;</DIV>
<DIV>Here is an example, could anyone find anything wrong in the following code?</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>#if defined(_MSC_VER)<BR>#pragma warning( disable : 4786 )<BR>#endif</DIV>
<DIV>#include &lt;iostream&gt;<BR>#include "igstkLandmark3DRegistration.h"<BR>#include "igstkLandmark3DRegistrationErrorEstimator.h"<BR>#include "itkLogger.h"<BR>#include "itkStdStreamLogOutput.h"<BR>#include "itkObject.h"<BR>#include "itkCommand.h"<BR>#include "itkMacro.h"</DIV>
<DIV>#include "igstkEvents.h"<BR>#include "igstkTransform.h"</DIV>
<DIV>&nbsp;</DIV>
<DIV>class Landmark3DRegistrationGetTransformCallback: public itk::Command<BR>{<BR>public:<BR>&nbsp;typedef Landmark3DRegistrationGetTransformCallback&nbsp;&nbsp;&nbsp; Self;<BR>&nbsp;typedef itk::SmartPointer&lt;Self&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Pointer;<BR>&nbsp;typedef itk::Command&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Superclass;<BR>&nbsp;itkNewMacro(Self);<BR>&nbsp;<BR>&nbsp;typedef igstk::TransformModifiedEvent TransformModifiedEventType;<BR>&nbsp;<BR>&nbsp;void Execute( const itk::Object *caller, const itk::EventObject &amp; event )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;<BR>&nbsp;void Execute( itk::Object *caller, const itk::EventObject &amp; event )<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;std::cout&lt;&lt; " TransformEvent is thrown" &lt;&lt; std::endl;<BR>&nbsp;&nbsp;const TransformModifiedEventType * transformEvent =<BR>&nbsp;&nbsp;&nbsp;dynamic_cast &lt; const TransformModifiedEventType* &gt; ( &amp;event );<BR>&nbsp;&nbsp;m_Transform = transformEvent-&gt;Get();<BR>&nbsp;&nbsp;m_EventReceived = true;<BR>&nbsp;&nbsp;&nbsp; } <BR>&nbsp;bool GetEventReceived()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;return m_EventReceived;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;igstk::Transform GetTransform()<BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;return m_Transform;<BR>&nbsp;&nbsp;&nbsp; }&nbsp; <BR>protected:<BR>&nbsp;<BR>&nbsp;Landmark3DRegistrationGetTransformCallback()&nbsp;&nbsp; <BR>&nbsp;&nbsp;&nbsp; {<BR>&nbsp;&nbsp;m_EventReceived = true;<BR>&nbsp;&nbsp;&nbsp; }<BR>&nbsp;<BR>private:<BR>&nbsp;bool m_EventReceived;<BR>&nbsp;igstk::Transform m_Transform;<BR>};</DIV>
<DIV>int main( int argv, char * argc[] )<BR>{<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;igstk::RealTimeClock::Initialize();<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;typedef itk::Logger&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LoggerType;<BR>&nbsp;typedef itk::StdStreamLogOutput&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; LogOutputType;<BR>&nbsp;&nbsp;&nbsp; <BR>&nbsp;typedef igstk::Landmark3DRegistration<BR>&nbsp;&nbsp;Landmark3DRegistrationType;<BR>&nbsp;typedef igstk::Landmark3DRegistration::LandmarkPointContainerType<BR>&nbsp;&nbsp;LandmarkPointContainerType;<BR>&nbsp;typedef igstk::Landmark3DRegistration::LandmarkImagePointType <BR>&nbsp;&nbsp;LandmarkImagePointType;<BR>&nbsp;typedef igstk::Landmark3DRegistration::LandmarkTrackerPointType<BR>&nbsp;&nbsp;LandmarkTrackerPointType;<BR>&nbsp;typedef Landmark3DRegistrationType::TransformType::OutputVectorType <BR>&nbsp;&nbsp;OutputVectorType;<BR>&nbsp;typedef igstk::Transform&nbsp; TransformType;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Landmark3DRegistrationType::Pointer landmarkRegister = <BR>&nbsp;&nbsp;Landmark3DRegistrationType::New();</DIV>
<DIV>&nbsp;<BR>&nbsp;LandmarkImagePointType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; imagePoint;<BR>&nbsp;LandmarkTrackerPointType&nbsp;&nbsp;&nbsp; trackerPoint;<BR>&nbsp;</DIV>
<DIV>&nbsp;<BR>&nbsp;<BR>&nbsp;typedef itk::VersorRigid3DTransform&lt;double&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; VersorRigid3DTransformType;<BR>&nbsp;typedef VersorRigid3DTransformType::ParametersType ParametersType;<BR>&nbsp;<BR>&nbsp;TransformType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; transform;<BR>&nbsp;ParametersType&nbsp;&nbsp;&nbsp;&nbsp; parameters(6);<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;Landmark3DRegistrationGetTransformCallback::Pointer lrtcb =<BR>&nbsp;&nbsp;Landmark3DRegistrationGetTransformCallback::New();<BR>&nbsp;landmarkRegister-&gt;AddObserver( igstk::TransformModifiedEvent(), lrtcb );<BR>&nbsp;<BR>&nbsp;typedef igstk::Landmark3DRegistrationErrorEstimator&nbsp;&nbsp; ErrorEstimatorType;<BR>&nbsp;<BR>&nbsp;typedef ErrorEstimatorType::TargetPointType&nbsp;&nbsp; TargetPointType;<BR>&nbsp;typedef ErrorEstimatorType::ErrorType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ErrorType;<BR>&nbsp;<BR>&nbsp;ErrorType&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; landmarkRegistrationError;<BR>&nbsp;<BR>&nbsp;// test landmark registration reuse<BR>&nbsp;if(1)<BR>&nbsp;{<BR>&nbsp;&nbsp;imagePoint[0] =&nbsp; 78.3163;<BR>&nbsp;&nbsp;imagePoint[1] =&nbsp; 15.3252;<BR>&nbsp;&nbsp;imagePoint[2] =&nbsp; 16;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;trackerPoint[0] =&nbsp; 199.274;<BR>&nbsp;&nbsp;trackerPoint[1] =&nbsp; -26.6466;<BR>&nbsp;&nbsp;trackerPoint[2] =&nbsp; -869.895;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;imagePoint[0] =&nbsp; 12.5937;<BR>&nbsp;&nbsp;imagePoint[1] =&nbsp;&nbsp; 9.9381;<BR>&nbsp;&nbsp;imagePoint[2] =&nbsp; 16;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;trackerPoint[0] =&nbsp; 218.485;<BR>&nbsp;&nbsp;trackerPoint[1] =&nbsp; -2.90349;<BR>&nbsp;&nbsp;trackerPoint[2] =&nbsp; -882.859;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;imagePoint[0] =&nbsp; 45.3473;<BR>&nbsp;&nbsp;imagePoint[1] =&nbsp;&nbsp; 7.78325;<BR>&nbsp;&nbsp;imagePoint[2] =&nbsp; 60;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;trackerPoint[0] =&nbsp; 304.046;<BR>&nbsp;&nbsp;trackerPoint[1] =&nbsp; -34.6625;<BR>&nbsp;&nbsp;trackerPoint[2] =&nbsp; -885.358;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestComputeTransform();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;landmarkRegister-&gt;RequestGetTransform();<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;transform = lrtcb-&gt;GetTransform();<BR>&nbsp;&nbsp;std::cout &lt;&lt; "Transform " &lt;&lt; transform &lt;&lt; std::cout;<BR>&nbsp;&nbsp;<BR>&nbsp;&nbsp;landmarkRegistrationError = landmarkRegister-&gt;ComputeRMSError();<BR>&nbsp;&nbsp;std::cout&lt;&lt;"RMS Error is "&lt;&lt;landmarkRegistrationError&lt;&lt;std::endl;<BR>&nbsp;}<BR>&nbsp;<BR>&nbsp;<BR>&nbsp;// reuse landmark registration<BR>&nbsp;landmarkRegister-&gt;RequestResetRegistration();</DIV>
<DIV>&nbsp;<BR>&nbsp;imagePoint[0] =&nbsp; 77.2389;<BR>&nbsp;imagePoint[1] =&nbsp; 15.9716;<BR>&nbsp;imagePoint[2] =&nbsp; 16;<BR>&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV>&nbsp;trackerPoint[0] =&nbsp; 230.525;<BR>&nbsp;trackerPoint[1] =&nbsp; -44.7263;<BR>&nbsp;trackerPoint[2] =&nbsp; -894.183;<BR>&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;<BR>&nbsp;// Add 2nd landmark<BR>&nbsp;imagePoint[0] =&nbsp; 14.1021;<BR>&nbsp;imagePoint[1] =&nbsp; 10.3691;<BR>&nbsp;imagePoint[2] =&nbsp; 16;<BR>&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV>&nbsp;trackerPoint[0] =&nbsp; 211.976;<BR>&nbsp;trackerPoint[1] =&nbsp; -41.8738;<BR>&nbsp;trackerPoint[2] =&nbsp; -875.216;<BR>&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;<BR>&nbsp;// Add 3d landmark<BR>&nbsp;imagePoint[0] =&nbsp; 45.9937;<BR>&nbsp;imagePoint[1] =&nbsp; 6.27483;<BR>&nbsp;imagePoint[2] =&nbsp; 68;<BR>&nbsp;landmarkRegister-&gt;RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV>&nbsp;trackerPoint[0] =&nbsp; 303.781;<BR>&nbsp;trackerPoint[1] =&nbsp; -35.4769;<BR>&nbsp;trackerPoint[2] =&nbsp; -887.587;<BR>&nbsp;landmarkRegister-&gt;RequestAddTrackerLandmarkPoint(trackerPoint);<BR>&nbsp;<BR>&nbsp;landmarkRegister-&gt;RequestComputeTransform();<BR>&nbsp;landmarkRegister-&gt;RequestGetTransform();<BR>&nbsp;<BR>&nbsp;transform = lrtcb-&gt;GetTransform();<BR>&nbsp;std::cout &lt;&lt; "Transform " &lt;&lt; transform &lt;&lt; std::cout;<BR>&nbsp;<BR>&nbsp;landmarkRegistrationError = landmarkRegister-&gt;ComputeRMSError();<BR>&nbsp;std::cout&lt;&lt;"RMS Error is "&lt;&lt;landmarkRegistrationError&lt;&lt;std::endl;<BR>&nbsp;<BR>&nbsp;return 0;<BR>}</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV>Thank you very much!</DIV>
<DIV>&nbsp;</DIV>
<DIV>Best,</DIV>
<DIV>Fucang</DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV ></DIV><br><!-- footer --><br><hr>
<a style="font-size:12px;line-height:15px; color:#000; text-decoration:none" href="http://www.126.com/" target="_blank">¶À¼Ò£¡ÍøÒ×3GÃâ·ÑÓÊ£¬»¹ÔùËÍ280Õ×ÍøÅÌ <span style="font-family:Tahoma; text-decoration:underline; color:blue">www.126.com</span> </a>