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 00019 #include <flann/flann.h> 00020 00021 #include "Workers/Math/Math.h" 00022 #include "Workers/Math/Box2D.h" 00023 00024 #include "Workers/KeyPointExtraction/KeyPoint.h" 00025 #include "Workers/KeyPointExtraction/KeyPointMatch.h" 00026 00032 class FLANNMatcher 00033 { 00034 public: 00035 00040 FLANNMatcher(); 00041 00044 FLANNMatcher( const FLANNMatcher& other ); 00045 FLANNMatcher& operator=( const FLANNMatcher& other ); 00046 00047 00049 ~FLANNMatcher(); 00050 00055 void createIndex( std::vector< KeyPoint >* keyPoints ); 00056 00063 void match( std::vector< KeyPoint >* keyPoints, float maxDistRatio=0.7 ); 00064 00065 std::list< KeyPointMatch > getMatches() { return m_Matches; } 00066 00067 bool hasIndex(){return m_hasIndex;} 00068 00070 int getNumMatches() { return m_Matches.size(); } 00071 00072 // int getNumIndexedKeypoints(){return m_Matches.size();} 00073 00074 FLANNParameters& getFlannParameters(){ 00075 return m_flannParams; 00076 } 00077 00078 std::string getLog(); 00079 00080 private: 00081 00083 void eliminateMultipleMatches( ); 00084 void clearFLANNMembers(); 00085 void fillFlannDataWithDescriptors(const std::vector<KeyPoint>* features, float* flannDataPtr); 00086 00087 //stores a list of matches 00088 typedef std::list< KeyPointMatch > MatchList; 00089 00090 //iterator for accessing and deleting elements of the match list 00091 typedef std::list<KeyPointMatch>::iterator MatchElem; 00092 00093 MatchList m_Matches; 00094 00095 std::ostringstream m_Log; 00096 00097 FLANN_INDEX m_flannIndex; 00098 FLANNParameters m_flannParams; 00099 bool m_hasIndex; 00100 unsigned int m_descriptorLength; 00101 00102 float* m_FlannModelData; 00103 00104 }; 00105 00106 #endif