00001 #ifndef Impala_Core_Feature_RandomForest_h 00002 #define Impala_Core_Feature_RandomForest_h 00003 00004 #include "Core/Feature/RandomTree.h" 00005 00006 namespace Impala 00007 { 00008 namespace Core 00009 { 00010 namespace Feature 00011 { 00012 00013 typedef std::vector<RandomTree*> RandomForest; 00014 00015 RandomForest 00016 ReadRandomForest(RandomTreeTable* table) 00017 { 00018 std::vector<RandomTree*> forest; 00019 int index=0; 00020 while(index < table->Size()) 00021 forest.push_back(Read(table, index)); 00022 return forest; 00023 } 00024 00025 RandomForest 00026 ReadRandomForest(FeatureTable* table) 00027 { 00028 RandomTreeTable* tt = MakeRandomTreeTable(table); 00029 std::vector<RandomTree*> forest = ReadRandomForest(tt); 00030 delete tt; 00031 return forest; 00032 } 00033 00034 int 00035 GetCodebookLength(FeatureTable* table) 00036 { 00037 //find the last codeword and add 1 00038 return static_cast<int>(table->Get1(table->Size() - 1)) + 1; 00039 } 00042 void 00043 DeleteForest(RandomForest forest) 00044 { 00045 for(int i=0 ; i<forest.size() ; ++i) 00046 delete forest[i]; 00047 forest.clear(); 00048 } 00049 00050 } // namespace 00051 } // namespace 00052 } // namespace 00053 00054 #endif