Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLGeom/src/ICLGeom/PoseEstimator.h ** 00010 ** Module : ICLGeom ** 00011 ** Authors: Christof Elbrechter, Robert Haschke ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.GPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLGeom/GeomDefs.h> 00034 00035 namespace icl{ 00036 namespace geom{ 00037 00038 00040 00054 class PoseEstimator{ 00055 00057 PoseEstimator(){} 00058 00059 public: 00061 enum MapMode { 00062 Translation, 00063 RigidBody, 00064 Similarity, 00065 Affine 00066 }; 00067 00069 00074 template<class T> 00075 static math::FixedMatrix<T,4,4> map(const math::DynMatrix<T> &Xs, const math::DynMatrix<T> &Ys, MapMode mode=RigidBody) 00076 throw (math::IncompatibleMatrixDimensionException,math::SingularMatrixException); 00077 00079 00080 template<class T, unsigned int NUM_POINTS> 00081 static math::FixedMatrix<T,4,4> map(const math::FixedMatrix<T,NUM_POINTS,3> &Xs, 00082 const math::FixedMatrix<T,NUM_POINTS,3> &Ys, MapMode mode=RigidBody) 00083 throw (math::IncompatibleMatrixDimensionException,math::SingularMatrixException){ 00084 return map(Xs.dyn(),Ys.dyn(), mode); 00085 } 00086 00088 00089 template<class T, unsigned int NUM_POINTS> 00090 static math::FixedMatrix<T,4,4> map(const math::FixedMatrix<T,NUM_POINTS,4> &Xs, 00091 const math::FixedMatrix<T,NUM_POINTS,4> &Ys, MapMode mode=RigidBody) 00092 throw (math::IncompatibleMatrixDimensionException,math::SingularMatrixException){ 00093 return map(Xs.dyn(),Ys.dyn(), mode); 00094 } 00095 00097 static Mat map(const std::vector<Vec> &Xs, const std::vector<Vec> &Ys, MapMode mode=RigidBody) 00098 throw (utils::ICLException,math::SingularMatrixException,math::IncompatibleMatrixDimensionException){ 00099 ICLASSERT_THROW(Xs.size() == Ys.size(), utils::ICLException("PoseEstimator::map: need same number of input- and output-points")); 00100 math::DynMatrix<float> XsD(Xs.size(),3),YsD(Ys.size(),3); 00101 for(unsigned int i=0;i<Xs.size();++i){ 00102 std::copy(Xs[i].begin(),Xs[i].begin()+3, XsD.col_begin(i)); 00103 std::copy(Ys[i].begin(),Ys[i].begin()+3, YsD.col_begin(i)); 00104 } 00105 return map(XsD,YsD,mode); 00106 } 00107 00109 template<class T> 00110 static math::FixedMatrix<T,3,3> quaternion_to_rotation_matrix(T w, T x, T y, T z); 00111 }; 00112 00113 } // namespace geom 00114 }