Definition at line 269 of file InterestPointFeature.h. References Impala::Core::Feature::FeatureDefinition::AddParameter(), Impala::FileNameBase(), Impala::Core::Feature::FeatureTable::GetFeatureVectorLength(), Impala::Util::Database::GetFilePath(), Impala::CmdOptions::GetInstance(), Impala::Util::Database::GetIOBuffer(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, Impala::MakeString(), Impala::Core::Matrix::MatNrCol(), mCodebook, mDatabase, mDescriptorReduce, mDescriptorReduceFilename, mFeatureDefinition, Impala::Core::Feature::Read(), Impala::Util::IOBuffer::Read(), Impala::Core::Array::ReadRaw(), Impala::Util::IOBuffer::Seek(), and Impala::Core::Table::Table::Size(). Referenced by Impala::Core::VideoSet::InterestPointProc::HandleNewWalk(), and Impala::Core::ImageSet::InterestPointProc::HandleNewWalk(). 00270 { 00271 String codebook; 00272 Util::IOBuffer* buf = 0; 00273 if(db) 00274 { 00275 /* translate this name into a complete path */ 00276 codebook = db->GetFilePath(filename, false, false); 00277 ILOG_DEBUG("SetCodebook using DB; " << filename << "; serverName=" 00278 << codebook); 00279 /* read it */ 00280 if(codebook.empty()) 00281 { 00282 ILOG_ERROR("Cannot open codebook: " << filename); 00283 exit(1); 00284 } 00285 buf = db->GetIOBuffer(codebook, true, false, "", 0, true); 00286 mDatabase = db; 00287 if(!mDescriptorReduceFilename.empty()) 00288 { 00289 ReadRaw(mDescriptorReduce, db->GetFilePath(mDescriptorReduceFilename, false, false), db); 00290 mFeatureDefinition.AddParameter("red", MakeString(Matrix::MatNrCol(mDescriptorReduce))); 00291 } 00292 } 00293 else 00294 { 00295 ILOG_DEBUG("Command-line (colorDescriptor binary)"); 00296 codebook = filename; 00297 buf = new Util::IOBufferFile(filename, true, true); 00298 if(!mDescriptorReduceFilename.empty()) 00299 { 00300 Util::IOBuffer* buf2 = new Util::IOBufferFile(mDescriptorReduceFilename, true, true); 00301 ReadRaw(mDescriptorReduce, buf2); 00302 mFeatureDefinition.AddParameter("red", MakeString(Matrix::MatNrCol(mDescriptorReduce))); 00303 delete buf2; 00304 } 00305 } 00306 00307 ILOG_DEBUG("SetCodebook after IOBuffer " << buf); 00308 if (buf) 00309 { 00310 buf->Seek(0, SEEK_SET); 00311 char buf2[2049]; 00312 buf2[2048] = '\0'; 00313 buf->Read(buf2, 2048); 00314 buf->Seek(0, SEEK_SET); 00315 String recognizer(buf2); 00316 if(recognizer.find("nr strings") != String::npos) 00317 { // nr strings : then FeatureTableOld 00318 ILOG_ERROR("Your codebook is in FeatureTableOld format!"); 00319 } 00320 else 00321 { 00322 mCodebook = new FeatureTable(filename); 00323 Read(mCodebook, buf); 00324 ILOG_DEBUG("FeatureTable style: " << filename); 00325 } 00326 delete buf; 00327 } 00328 else 00329 { 00330 ILOG_ERROR("SetCodebook: IOBuffer is 0"); 00331 return; 00332 } 00333 00334 ILOG_INFO("Reading codebook: " << codebook << 00335 "; dimensionCount = " << mCodebook->GetFeatureVectorLength() 00336 << "; size = " << mCodebook->Size()); 00337 00338 CmdOptions& options = CmdOptions::GetInstance(); 00339 if(options.GetString("codebookMode") != "hard") 00340 { 00341 if(options.GetString("codebookMode") == "hardindex") 00342 { 00343 mFeatureDefinition.AddParameter 00344 ("cm", options.GetString("codebookMode") + "-" + 00345 FileNameBase(codebook)); 00346 } 00347 else 00348 { 00349 mFeatureDefinition.AddParameter 00350 ("cm", options.GetString("codebookMode")); 00351 } 00352 } 00353 if(options.GetString("codebookSigma") != "") 00354 { 00355 mFeatureDefinition.AddParameter 00356 ("cs", options.GetString("codebookSigma")); 00357 } 00358 }
Here is the call graph for this function:
|