emat_estimation.h
Go to the documentation of this file.
00001 //part of the source code of master thesis, source code produced by Jiri Divis
00002 /*------------------------------------------------------------------------------------------------*/
00019 #ifndef VSLAM_EMAT_ESTIMATION_H_INCLUDED
00020 #define VSLAM_EMAT_ESTIMATION_H_INCLUDED
00021 
00022 #include "utils.h"
00023 #include "model_estimation.h"
00024 
00025 
00027 template<class ErrorAccumClassT> class EightPointModelBuilder : 
00028         public GeneralizedModelBuilder<ErrorAccumClassT> {
00029     protected:
00030         double error_treshold;
00031     public:
00032         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00033 
00034         EightPointModelBuilder(const ErrorAccumClassT& _error_accum) :
00035                 GeneralizedModelBuilder<ErrorAccumClassT>(_error_accum) { }
00036 
00037         shared_ptr<EMatrixModel> operator()(const ImageMatchVec& selected){
00038             return shared_ptr<EMatrixModel>(new SingleSolutionModel<ErrorAccumClassT >(
00039                         8, selected, computeE(selected), this->error_accum));
00040         }
00041 
00042         virtual unsigned int getSize() const{
00043             return 8;
00044         }
00045 };
00046 
00047 
00048 
00060 template<class ErrorAccumClassT> 
00061 class LiHartley5ptFrom6ptsBuilder : public GeneralizedModelBuilder<ErrorAccumClassT>{
00062     public:
00063         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00064         LiHartley5ptFrom6ptsBuilder(const ErrorAccumClassT& _error_accum) :
00065                 GeneralizedModelBuilder<ErrorAccumClassT>(_error_accum) { }
00066 
00067         //uses 5-point algorithm and 6th point to filter uniqe solution. 
00068         virtual shared_ptr<EMatrixModel> operator()(const ImageMatchVec & selected){
00069             ImageMatchVec selected5 = selected;
00070             selected5.pop_back();
00071             ALIGNED<Matrix3d>::vector Ematrixes = li_hartley_5pt(selected5, false);
00072             shared_ptr<EMatrixModel> model;
00073             BOOST_FOREACH(Matrix3d E, Ematrixes){
00074                 shared_ptr<SingleSolutionModel<ErrorAccumClassT> > m(new SingleSolutionModel<
00075                         ErrorAccumClassT>(getSize(), selected, E, this->error_accum));
00076                 SE3 estimate;
00077                 if(extractTransformFromE(selected, m->getModel(), estimate)){
00078                     model = m;
00079                 }
00080             }
00081             return model;
00082         }
00083 
00084         virtual unsigned int getSize() const{
00085             return 6;
00086         }
00087 };
00088 
00089 
00090 
00091 
00092 
00105 template<class ErrorAccumT> class LiHartleyMulti5ptBuilder : 
00106         public GeneralizedModelBuilder<ErrorAccumT>{
00107     protected:
00108         ErrorAccumT error_accum;
00109     public:
00110         LiHartleyMulti5ptBuilder(const ErrorAccumT& _error_accum) :
00111                 GeneralizedModelBuilder<ErrorAccumT>(_error_accum){}
00112 
00113         virtual shared_ptr<EMatrixModel> operator()(const ImageMatchVec & selected){
00114             ALIGNED<Matrix3d>::vector Ematrixes;
00115             Ematrixes = li_hartley_5pt(selected, false);
00116 
00117             return shared_ptr<EMatrixModel>(
00118                     new MultiSolutionModel<ErrorAccumT, Eigen::aligned_allocator>(
00119                             (int)getSize(),
00120                             selected,
00121                             Ematrixes, 
00122                             error_accum)); 
00123         }
00124 
00125         virtual unsigned int getSize() const{
00126             return 5;
00127         }
00128 };
00129 
00130 
00141 template<class ErrorAccumT> class DummyModelBuilder : public GeneralizedModelBuilder<ErrorAccumT>{
00142     protected:
00143         ALIGNED<Matrix3d>::vector Ematrixes;
00144         int i;
00145     public:
00146         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00147 
00148         DummyModelBuilder(
00149                 const ErrorAccumT& _error_accum, 
00150                 const ALIGNED<Matrix3d>::vector &_Ematrixes) :
00151                 GeneralizedModelBuilder<ErrorAccumT>(_error_accum), Ematrixes(_Ematrixes), i(-1) {}
00152         
00154         shared_ptr<EMatrixModel> operator()(const ImageMatchVec & selected){
00155             i++;
00156             assert(i<(int)Ematrixes.size());
00157             return shared_ptr<EMatrixModel>(new SingleSolutionModel<ErrorAccumT>(
00158                         1,  selected, Ematrixes[i], this->error_accum));
00159         }
00160 
00161         virtual unsigned int getSize() const{
00162             return 1;
00163         }
00164 };
00165 
00166 
00167 
00168 
00169 
00170 
00171 class DummyModelBuilderStd : public DummyModelBuilder<
00172         RealErrorMaxErrorAccumulator<AngleError> >{
00173     private:
00174         typedef RealErrorMaxErrorAccumulator<AngleError> ErrorAccumT;
00175     public:
00176 
00177         DummyModelBuilderStd(
00178                 const ALIGNED<Matrix3d>::vector &_Ematrixes, 
00179                 double _error_treshold = M_PI / 45.0) :
00180                 DummyModelBuilder<ErrorAccumT>(
00181                 ErrorAccumT(AngleError(), _error_treshold), _Ematrixes) {}
00182 };
00183 
00184 class EightPointModelBuilderStd : public EightPointModelBuilder<
00185         RealErrorMaxErrorAccumulator<DummyErrorFunc<Matrix3d, ImageMatch> > >{
00186     private:
00187         typedef DummyErrorFunc<Matrix3d, ImageMatch> ErrorFuncT;
00188         typedef RealErrorMaxErrorAccumulator<DummyErrorFunc<Matrix3d, ImageMatch> > ErrorAccumT;
00189     public:
00190 
00191         EightPointModelBuilderStd() :
00192                 EightPointModelBuilder<ErrorAccumT>(ErrorAccumT( ErrorFuncT(), error_treshold)) {}
00193 };
00194 
00195 class LiHartley5ptFrom6ptsBuilderStd : public LiHartley5ptFrom6ptsBuilder<
00196         RealErrorMaxErrorAccumulator<AngleError> >{
00197     private:
00198         typedef RealErrorMaxErrorAccumulator<AngleError> ErrorAccumT;
00199     public:
00200         EIGEN_MAKE_ALIGNED_OPERATOR_NEW
00201 
00203         LiHartley5ptFrom6ptsBuilderStd( double _error_treshold = M_PI / 45.0) :
00204             LiHartley5ptFrom6ptsBuilder<ErrorAccumT>(ErrorAccumT(AngleError(), _error_treshold)) {}
00205 };
00206 
00208 
00210 
00212 
00213 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines


pose_estimation
Author(s): Jiri Divis/jiridivis@gmail.com
autogenerated on Wed Mar 27 2013 21:00:12