00001 #ifndef TRV_HOMOGRAPHYFINE_HPP
00002 #define TRV_HOMOGRAPHYFINE_HPP
00003
00004 #include "traversability/trv_util.hpp"
00005 #include "traversability/trv_homography.hpp"
00006 #include "traversability/trv_homographyGeom.hpp"
00007 #include "traversability/traversabilityException.hpp"
00008
00009 #include "kernel/jafarException.hpp"
00010 #include "jmath/jblas.hpp"
00011 #include "jmath/ublasExtra.hpp"
00012 #include "jmath/randomIntTmplt.hpp"
00013 #include "jmath/linearSolvers.hpp"
00014
00015 #include "../libsLourakis/homest-1.2/homest.h"
00016
00017
00018 namespace jafar {
00019 namespace traversability {
00020
00027 class HomographyFine : public Homography
00028 {
00029 private:
00030
00031 MatchesContainer* mMatches;
00032
00033
00034 jblas::vec mProjError;
00035 double mMeanProjError;
00036 double mStdProjError;
00037
00038 public:
00039 HomographyFine ( void );
00040 HomographyFine ( const HomographyGeom &Hgeom );
00041 ~HomographyFine ( void );
00042 void printInfo ( void ) const;
00043
00044 int setMatches ( MatchesContainer* matches ) {
00045 if (matches->nOfMatches()==0)
00046 {
00047 return 1;
00048 }
00049
00050
00051
00052 mMatches = new MatchesContainer(*matches);
00053
00054
00055 return 0;
00056 }
00057 MatchesContainer getMatches ( void ) { return *mMatches; }
00058
00059 void estimate ( void );
00060 void estimateR ( void );
00061 void estimateRANSAC ( void );
00062
00063
00064 void estimateWithGeom ( const jblas::mat33& H_C0C1_geom );
00065
00066 public:
00067
00068 double getMeanProjError ( void ) { return mMeanProjError; }
00069 double getStdProjError ( void ) { return mStdProjError; }
00070 void calcProjErrorStats ( const jblas::mat33 H01, double &mean, double &stdev );
00071 void sortOutMatches ( const jafar::image::Image &mask );
00072
00073 private:
00074 template <class Mat> void calcA_i ( const double x0u, const double x0v, const double x1u, const double x1v, Mat &A_i, const double weight = 1.0 );
00075 void calcH4p ( const MatchesContainer *mc, const jblas::veci4 &idxVec, jblas::mat33 &H_C0C1 );
00076 void pointSelectionCriteria ( const int idx, const MatchesContainer* matches, jblas::veci4 &idxVec, int &featCnt, const double minDistSq, const double minCrossP );
00077
00078 };
00079 }
00080 }
00081
00082 #endif
00083