Definition at line 17 of file ReadCodebook.h. References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), ILOG_VAR, ILOG_WARN, Impala::MakeQuidCodebook(), Impala::Core::Matrix::MatE(), Impala::Core::Matrix::MatNrCol(), Impala::Core::Matrix::MatNrRow(), Read(), Impala::Util::IOBuffer::Read(), ReadBINDESC1FromBuffer(), and Impala::Util::IOBuffer::Seek(). Referenced by Impala::Core::Feature::InterestPointFeature::SetCodebook(). 00018 { 00019 ILOG_VAR(Impala.Core.Feature.ReadCodebookFromBuffer); 00020 00021 using namespace Matrix; 00022 00023 FeatureTable* result = 0; 00024 buf->Seek(0, SEEK_SET); 00025 char buf2[2049]; 00026 buf2[2048] = '\0'; 00027 buf->Read(buf2, 2048); 00028 buf->Seek(0, SEEK_SET); 00029 String recognizer(buf2); 00030 if(recognizer.find("nr strings") != String::npos) 00031 { // nr strings : then FeatureTableOld 00032 typedef Table::TableTem<Column::ColumnTem<String>, 00033 Vector::VectorSet<Array::Array2dScalarReal64> > 00034 FeatureTableOldType; 00035 FeatureTableOldType* oldCodebook = new FeatureTableOldType( 00036 Column::ColumnTem<String>(0), 00037 Vector::VectorSet<Array::Array2dScalarReal64>(true, 1, 0)); 00038 Read(oldCodebook, buf); 00039 00040 int d = oldCodebook->GetColumn2()->GetVectorLength(0); 00041 // need to copy oldCodebook into result 00042 result = new FeatureTable(FeatureDefinition(""), 00043 oldCodebook->Size(), 00044 d); 00045 Mat* matrixCodebook = oldCodebook->GetColumn2()->GetStorage(); 00046 for(int i = 0; i < oldCodebook->Size(); i++) 00047 { 00048 Quid q = MakeQuidCodebook(0, 0, i); 00049 Core::Vector::VectorTem<Real64> 00050 v(d); 00051 for(int j = 0; j < d; j++) 00052 { 00053 v[j] = *MatE(matrixCodebook, i, j); 00054 } 00055 result->Add(q, v); 00056 } 00057 ILOG_WARN("Codebook is in an old format. Future versions might not work."); 00058 } 00059 else if(recognizer.substr(0,5) == String("KOEN1") || 00060 recognizer.substr(0,8) == String("BINDESC1")) 00061 { 00062 // other format 00063 buf->Seek(0, SEEK_SET); 00064 Mat* ignored = 0; 00065 Mat* descriptors = 0; 00066 ReadBINDESC1FromBuffer(ignored, descriptors, buf, false, true); 00067 result = new FeatureTable(FeatureDefinition(""), 00068 MatNrRow(descriptors), 00069 MatNrCol(descriptors)); 00070 for(int i = 0; i < MatNrRow(descriptors); i++) 00071 { 00072 Vector::VectorTem<Real64> v(MatNrCol(descriptors), 00073 MatE(descriptors, i, 0), 00074 true); 00075 result->Add(i, v); 00076 } 00077 delete descriptors; 00078 } 00079 else 00080 { 00081 result = new FeatureTable(FeatureDefinition("")); 00082 Read(result, buf); 00083 } 00084 return result; 00085 }
Here is the call graph for this function:
|