00001 /******************************************************************************* 00002 * FLANNMatcher.h 00003 * 00004 * (C) 2007 AG Aktives Sehen <agas@uni-koblenz.de> 00005 * Universitaet Koblenz-Landau 00006 * 00007 * Additional information: 00008 * $Id: $ 00009 *******************************************************************************/ 00010 00011 #ifndef FLANNMatcher_H 00012 #define FLANNMatcher_H 00013 00014 #include <vector> 00015 #include <deque> 00016 #include <sstream> 00017 #include <list> 00018 #include <flann/flann.h> 00019 00020 #include <ros/ros.h> 00021 00022 #include "Workers/Math/Math.h" 00023 #include "Workers/Math/Box2D.h" 00024 00025 #include "../KeyPointExtraction/KeyPoint.h" 00026 #include "../KeyPointExtraction/KeyPointMatch.h" 00027 00033 class FLANNMatcher 00034 { 00035 public: 00036 00041 FLANNMatcher(); 00042 00045 FLANNMatcher( const FLANNMatcher& other ); 00046 FLANNMatcher& operator=( const FLANNMatcher& other ); 00047 00048 00050 ~FLANNMatcher(); 00051 00056 void createIndex( std::vector< KeyPoint >* keyPoints ); 00057 00064 void match( std::vector< KeyPoint >* keyPoints, float maxDistRatio=0.7 ); 00065 00066 std::list< KeyPointMatch > getMatches() { return m_Matches; } 00067 00068 bool hasIndex(){return m_hasIndex;} 00069 00071 int getNumMatches() { return m_Matches.size(); } 00072 00073 // int getNumIndexedKeypoints(){return m_Matches.size();} 00074 00075 FLANNParameters& getFlannParameters(){ 00076 return m_flannParams; 00077 } 00078 00079 std::string getLog(); 00080 00081 private: 00082 00084 void eliminateMultipleMatches( ); 00085 void clearFLANNMembers(); 00086 void fillFlannDataWithDescriptors(const std::vector<KeyPoint>* features, float* flannDataPtr); 00087 00088 //stores a list of matches 00089 typedef std::list< KeyPointMatch > MatchList; 00090 00091 //iterator for accessing and deleting elements of the match list 00092 typedef std::list<KeyPointMatch>::iterator MatchElem; 00093 00094 MatchList m_Matches; 00095 00096 std::ostringstream m_Log; 00097 00098 FLANN_INDEX m_flannIndex; 00099 FLANNParameters m_flannParams; 00100 bool m_hasIndex; 00101 unsigned int m_descriptorLength; 00102 00103 float* m_FlannModelData; 00104 00105 }; 00106 00107 #endif