<DIV > </DIV>
<DIV>Hi,</DIV>
<DIV> </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> </DIV>
<DIV>Here is an example, could anyone find anything wrong in the following code?</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>#if defined(_MSC_VER)<BR>#pragma warning( disable : 4786 )<BR>#endif</DIV>
<DIV>#include <iostream><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> </DIV>
<DIV>class Landmark3DRegistrationGetTransformCallback: public itk::Command<BR>{<BR>public:<BR> typedef Landmark3DRegistrationGetTransformCallback Self;<BR> typedef itk::SmartPointer<Self> Pointer;<BR> typedef itk::Command Superclass;<BR> itkNewMacro(Self);<BR> <BR> typedef igstk::TransformModifiedEvent TransformModifiedEventType;<BR> <BR> void Execute( const itk::Object *caller, const itk::EventObject & event )<BR> {<BR> }<BR> <BR> void Execute( itk::Object *caller, const itk::EventObject & event )<BR> {<BR> std::cout<< " TransformEvent is thrown" << std::endl;<BR> const TransformModifiedEventType * transformEvent =<BR> dynamic_cast < const TransformModifiedEventType* > ( &event );<BR> m_Transform = transformEvent->Get();<BR> m_EventReceived = true;<BR> } <BR> bool GetEventReceived()<BR> {<BR> return m_EventReceived;<BR> }<BR> igstk::Transform GetTransform()<BR> {<BR> return m_Transform;<BR> } <BR>protected:<BR> <BR> Landmark3DRegistrationGetTransformCallback() <BR> {<BR> m_EventReceived = true;<BR> }<BR> <BR>private:<BR> bool m_EventReceived;<BR> igstk::Transform m_Transform;<BR>};</DIV>
<DIV>int main( int argv, char * argc[] )<BR>{<BR> <BR> <BR> <BR> igstk::RealTimeClock::Initialize();<BR> <BR> <BR> typedef itk::Logger LoggerType;<BR> typedef itk::StdStreamLogOutput LogOutputType;<BR> <BR> typedef igstk::Landmark3DRegistration<BR> Landmark3DRegistrationType;<BR> typedef igstk::Landmark3DRegistration::LandmarkPointContainerType<BR> LandmarkPointContainerType;<BR> typedef igstk::Landmark3DRegistration::LandmarkImagePointType <BR> LandmarkImagePointType;<BR> typedef igstk::Landmark3DRegistration::LandmarkTrackerPointType<BR> LandmarkTrackerPointType;<BR> typedef Landmark3DRegistrationType::TransformType::OutputVectorType <BR> OutputVectorType;<BR> typedef igstk::Transform TransformType;<BR> <BR> <BR> <BR> Landmark3DRegistrationType::Pointer landmarkRegister = <BR> Landmark3DRegistrationType::New();</DIV>
<DIV> <BR> LandmarkImagePointType imagePoint;<BR> LandmarkTrackerPointType trackerPoint;<BR> </DIV>
<DIV> <BR> <BR> typedef itk::VersorRigid3DTransform<double> VersorRigid3DTransformType;<BR> typedef VersorRigid3DTransformType::ParametersType ParametersType;<BR> <BR> TransformType transform;<BR> ParametersType parameters(6);<BR> <BR> <BR> Landmark3DRegistrationGetTransformCallback::Pointer lrtcb =<BR> Landmark3DRegistrationGetTransformCallback::New();<BR> landmarkRegister->AddObserver( igstk::TransformModifiedEvent(), lrtcb );<BR> <BR> typedef igstk::Landmark3DRegistrationErrorEstimator ErrorEstimatorType;<BR> <BR> typedef ErrorEstimatorType::TargetPointType TargetPointType;<BR> typedef ErrorEstimatorType::ErrorType ErrorType;<BR> <BR> ErrorType landmarkRegistrationError;<BR> <BR> // test landmark registration reuse<BR> if(1)<BR> {<BR> imagePoint[0] = 78.3163;<BR> imagePoint[1] = 15.3252;<BR> imagePoint[2] = 16;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);<BR> <BR> trackerPoint[0] = 199.274;<BR> trackerPoint[1] = -26.6466;<BR> trackerPoint[2] = -869.895;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> imagePoint[0] = 12.5937;<BR> imagePoint[1] = 9.9381;<BR> imagePoint[2] = 16;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);<BR> <BR> trackerPoint[0] = 218.485;<BR> trackerPoint[1] = -2.90349;<BR> trackerPoint[2] = -882.859;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> <BR> imagePoint[0] = 45.3473;<BR> imagePoint[1] = 7.78325;<BR> imagePoint[2] = 60;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);<BR> <BR> trackerPoint[0] = 304.046;<BR> trackerPoint[1] = -34.6625;<BR> trackerPoint[2] = -885.358;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> landmarkRegister->RequestComputeTransform();<BR> <BR> landmarkRegister->RequestGetTransform();<BR> <BR> transform = lrtcb->GetTransform();<BR> std::cout << "Transform " << transform << std::cout;<BR> <BR> landmarkRegistrationError = landmarkRegister->ComputeRMSError();<BR> std::cout<<"RMS Error is "<<landmarkRegistrationError<<std::endl;<BR> }<BR> <BR> <BR> // reuse landmark registration<BR> landmarkRegister->RequestResetRegistration();</DIV>
<DIV> <BR> imagePoint[0] = 77.2389;<BR> imagePoint[1] = 15.9716;<BR> imagePoint[2] = 16;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV> trackerPoint[0] = 230.525;<BR> trackerPoint[1] = -44.7263;<BR> trackerPoint[2] = -894.183;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> // Add 2nd landmark<BR> imagePoint[0] = 14.1021;<BR> imagePoint[1] = 10.3691;<BR> imagePoint[2] = 16;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV> trackerPoint[0] = 211.976;<BR> trackerPoint[1] = -41.8738;<BR> trackerPoint[2] = -875.216;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> // Add 3d landmark<BR> imagePoint[0] = 45.9937;<BR> imagePoint[1] = 6.27483;<BR> imagePoint[2] = 68;<BR> landmarkRegister->RequestAddImageLandmarkPoint(imagePoint);</DIV>
<DIV> trackerPoint[0] = 303.781;<BR> trackerPoint[1] = -35.4769;<BR> trackerPoint[2] = -887.587;<BR> landmarkRegister->RequestAddTrackerLandmarkPoint(trackerPoint);<BR> <BR> landmarkRegister->RequestComputeTransform();<BR> landmarkRegister->RequestGetTransform();<BR> <BR> transform = lrtcb->GetTransform();<BR> std::cout << "Transform " << transform << std::cout;<BR> <BR> landmarkRegistrationError = landmarkRegister->ComputeRMSError();<BR> std::cout<<"RMS Error is "<<landmarkRegistrationError<<std::endl;<BR> <BR> return 0;<BR>}</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>Thank you very much!</DIV>
<DIV> </DIV>
<DIV>Best,</DIV>
<DIV>Fucang</DIV>
<DIV> </DIV>
<DIV> </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>