00001 /* 00002 Copyright (C) 2010 - 2016 Christoph Haenisch 00003 00004 Chair of Medical Engineering (mediTEC) 00005 RWTH Aachen University 00006 Pauwelsstr. 20 00007 52074 Aachen 00008 Germany 00009 00010 See license.txt for more information. 00011 00012 Version 0.1.0 (2016-07-25) 00013 */ 00014 00019 #ifndef RANSAC_PIVOT_CALIBRATION_HPP_2432433439 00020 #define RANSAC_PIVOT_CALIBRATION_HPP_2432433439 00021 00022 00023 #include <list> 00024 #include <utility> 00025 00026 #include <Eigen/Core> 00027 00028 #include "PivotCalibration.hpp" 00029 #include "Ransac.hpp" 00030 00031 00032 namespace TRTK 00033 { 00034 00035 00262 template <class T> 00263 class RansacPivotCalibrationModel : public Ransac<T, typename PivotCalibration<T>::DataType>::Model 00264 { 00265 public: 00266 00267 typedef T value_type; 00268 typedef typename PivotCalibration<T>::Vector3T Vector3T; 00269 typedef typename PivotCalibration<T>::Matrix3T Matrix3T; 00270 typedef typename PivotCalibration<T>::DataType DataType; 00271 00272 RansacPivotCalibrationModel(PivotCalibration<T> & estimator); 00273 virtual ~RansacPivotCalibrationModel(); 00274 00275 void compute(); 00276 T getDeviation(const DataType & datum) const; 00277 unsigned getMinimumNumberOfItems() const; 00278 T getRMSE() const; 00279 void setData(const std::vector<DataType> & data); 00280 void setEstimator(PivotCalibration<T> & estimator); 00281 00282 private: 00283 00284 PivotCalibration<T> * estimator; 00285 }; 00286 00287 00293 template<class T> 00294 RansacPivotCalibrationModel<T>::RansacPivotCalibrationModel(PivotCalibration<T> & estimator) : 00295 estimator(&estimator) 00296 { 00297 } 00298 00299 00300 template<class T> 00301 RansacPivotCalibrationModel<T>::~RansacPivotCalibrationModel() 00302 { 00303 } 00304 00305 00306 template<class T> 00307 void RansacPivotCalibrationModel<T>::compute() 00308 { 00309 estimator->compute(); 00310 } 00311 00312 00313 template<class T> 00314 T RansacPivotCalibrationModel<T>::getDeviation(const DataType & datum) const 00315 { 00316 Vector3T location = datum.first; 00317 Matrix3T rotation = datum.second; 00318 Vector3T noisy_pivot_point = rotation * estimator->getLocalPivotPoint() + location; 00319 return (estimator->getPivotPoint() - noisy_pivot_point).norm(); 00320 } 00321 00322 00323 template<class T> 00324 unsigned RansacPivotCalibrationModel<T>::getMinimumNumberOfItems() const 00325 { 00326 return estimator->getNumberItemsRequired(); 00327 } 00328 00329 00330 template<class T> 00331 T RansacPivotCalibrationModel<T>::getRMSE() const 00332 { 00333 return estimator->getRMSE(); 00334 } 00335 00336 00337 template<class T> 00338 void RansacPivotCalibrationModel<T>::setData(const std::vector<DataType> & data) 00339 { 00340 std::list<typename DataType::first_type> locations; 00341 std::list<typename DataType::second_type> rotations; 00342 00343 for (size_t i = 0; i < data.size(); ++i) 00344 { 00345 locations.push_back(data[i].first); 00346 rotations.push_back(data[i].second); 00347 } 00348 00349 estimator->setLocations(make_range(locations)); 00350 estimator->setRotations(make_range(rotations)); 00351 } 00352 00353 00354 template<class T> 00355 void RansacPivotCalibrationModel<T>::setEstimator(PivotCalibration<T> & estimator) 00356 { 00357 this->estimator = &estimator; 00358 } 00359 00360 00361 } // namespace TRTK 00362 00363 00364 #endif // RANSAC_PIVOT_CALIBRATION_HPP_2432433439
Documentation generated by Doxygen