Home || Visual Search || Applications || Architecture || Important Messages || OGL || Src

bool Impala::Core::Feature::InterestPointFeature::FindInterestPoints ( CmdOptions options,
Array::Array2dVec3UInt8 input,
Quid  quid,
String  outputFilename,
bool  borderAlreadyRemoved = false,
Util::IOBuffer loadRegionsFile = 0 
) [inline]

Definition at line 350 of file InterestPointFeature.h.

References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), Impala::Core::Feature::FeatureDefinition::AddParameter(), ApplyDetector(), Impala::Util::TimeStats::AsString(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CH(), ComputeDescriptors(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CPB(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CW(), Impala::Core::Feature::PointDescriptorTable::ExportToFile(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get6(), Impala::Core::Feature::PointDescriptorTable::GetDescriptorData(), Impala::Core::Feature::PointDescriptorTable::GetDescriptorLength(), Impala::Core::Feature::PointDescriptorTable::GetFeatureDefinition(), GetFeatureName(), Impala::CmdOptions::GetString(), Impala::Core::Feature::PointDescriptorTable::GetX(), Impala::Core::Feature::PointDescriptorTable::GetY(), ILOG_DEBUG, ILOG_INFO, ILOG_WARN, Impala::Core::Feature::PointDescriptorTable::ImportFromBuffer(), Impala::Core::Array::MakeRoi(), mClusterInput, mClusterInputData, mCodebook, Impala::Util::TimeStats::MeasureFirst(), Impala::Util::TimeStats::MeasureLast(), Impala::Util::TimeStats::MeasureNext(), mExtraBoxes, mKeepLimited, mOutputFormat, mStripBorder, mTimeStats, ProjectOntoCodebook(), ReducePointCount(), Impala::Core::Feature::PointDescriptorTable::SetDescriptorLength(), Impala::Core::Table::Table::Size(), and Impala::Timer::SplitTimeStr().

Referenced by Impala::Core::ImageSet::InterestPointProc::HandleNewFile(), and Impala::Core::VideoSet::InterestPointProc::HandleNewFrame().

00354     {
00355         ILOG_DEBUG("start FindInterestPoints");
00356         String saveRegionsFilename = options.GetString("saveRegions");
00357         String detectorMode = options.GetString("detector");
00358         String descriptorMode = options.GetString("descriptor");
00359         Timer timer;
00360         Array::Array2dVec3UInt8* inputNoBorder = input;
00361         if(!borderAlreadyRemoved)
00362         {
00363             // remove the border, if requested
00364             Geometry::Rectangle rect(mStripBorder, mStripBorder,
00365                                      input->CW() - mStripBorder - 1,
00366                                      input->CH() - mStripBorder - 1, true);
00367             inputNoBorder = MakeRoi(input, rect);
00368         }
00369 
00370         PointDescriptorTable* pointData = 0;
00371 
00372         /* Apply detector */
00373         ILOG_DEBUG("applying detector");
00374         mTimeStats.MeasureFirst();
00375         if(loadRegionsFile)
00376         {
00377             // load the points from file
00378             pointData = PointDescriptorTable::ImportFromBuffer(detectorMode, 
00379                                           loadRegionsFile, mStripBorder);
00380         }
00381         else
00382         {
00383             pointData = ApplyDetector(inputNoBorder, detectorMode);
00384         }
00385         if(descriptorMode.empty())
00386         {
00387             // dump the interest regions to the output stream if we are not
00388             // going to compute descriptors later
00389             pointData->ExportToFile(outputFilename, mStripBorder, 
00390                                     mOutputFormat);
00391         }
00392         if(!saveRegionsFilename.empty())
00393         {
00394             ILOG_INFO("Writing to: " << saveRegionsFilename);
00395             pointData->ExportToFile(saveRegionsFilename, mStripBorder,
00396                                     mOutputFormat);
00397         }
00398 
00399         ILOG_DEBUG("[Timing] Region loading / applying detector finished in "
00400                    << timer.SplitTimeStr());
00401 
00402         /* descriptor computation */
00403         ILOG_DEBUG("computing descriptor");
00404         mTimeStats.MeasureNext();
00405         if(descriptorMode.size() != 0)
00406         {
00407             ComputeDescriptors(pointData, inputNoBorder, descriptorMode);
00408 
00409             ILOG_DEBUG("[Timing] Descriptors finished at " << timer.SplitTimeStr());
00410             if(mCodebook)
00411             {
00412                 ILOG_DEBUG("preparing for codebook");
00413                 /* project it onto a codebook */
00414                 Timer timerProjection;
00415                 if(mExtraBoxes)
00416                 {
00417                     for(int j = 0; j < mExtraBoxes->CH(); j++)
00418                     {
00419                         if(*mExtraBoxes->CPB(0, j) == quid)
00420                         {
00421                             // it is a box for this image
00422                             Quid boxQuid = *mExtraBoxes->CPB(1, j);
00423                             UInt64 xlow = *mExtraBoxes->CPB(2, j);
00424                             UInt64 ylow = *mExtraBoxes->CPB(3, j);
00425                             UInt64 xhi = *mExtraBoxes->CPB(4, j);
00426                             UInt64 yhi = *mExtraBoxes->CPB(5, j);
00427                             UInt64 width = xhi - xlow;
00428                             UInt64 height = yhi - ylow;
00429                             // need to make a copy
00430                             PointDescriptorTable* table = new PointDescriptorTable(pointData->GetFeatureDefinition());
00431                             table->SetDescriptorLength(pointData->GetDescriptorLength());
00432                             for(int i = 0; i < pointData->Size(); i++)
00433                             {
00434                                 Real64 x = pointData->GetX(i) - xlow;
00435                                 Real64 y = pointData->GetY(i) - ylow;
00436                                 if((x < 0) || (y < 0) || (x > width) || (y > height))
00437                                 {
00438                                     continue;
00439                                 }
00440                                 table->Add(x, y, 0, 0, 0, pointData->Get6(i));
00441                             }
00442                             ILOG_DEBUG("extrabox:"<<xlow << " "<< ylow << " "<<xhi << " " << yhi << " " << table->Size() << " " << pointData->Size());
00443                             table = ProjectOntoCodebook(table,
00444                                             options.GetString("codebookMode"),
00445                                             width, height, boxQuid);
00446                             delete table;
00447                         }
00448                     }
00449                 }
00450                 else
00451                 {
00452                     mTimeStats.MeasureNext();
00453                     pointData = ProjectOntoCodebook(pointData,
00454                                        options.GetString("codebookMode"),
00455                                        inputNoBorder->CW(), inputNoBorder->CH(),
00456                                        quid);
00457                     mTimeStats.MeasureLast();
00458                     ILOG_INFO("Overall " << mTimeStats.AsString());
00459                     ILOG_DEBUG("Just codebook projection took: " <<
00460                                timerProjection.SplitTimeStr());
00461                     if(outputFilename.size() != 0)
00462                     {
00463                         pointData->ExportToFile(outputFilename, mStripBorder, 
00464                                                 mOutputFormat);
00465                     }
00466                 }
00467             }
00468             else
00469             {
00470                 // do reduction
00471                 if((mKeepLimited > 0) && (pointData->Size() > mKeepLimited))
00472                 {
00473                     ILOG_DEBUG("reducing point count");
00474                     // we might have to limit the number of points
00475                     pointData = ReducePointCount(pointData, mKeepLimited);
00476                 }
00477 
00478                 if(mClusterInput)
00479                 {
00480                     ILOG_DEBUG("doing cluster input");
00481                     int n = pointData->GetDescriptorLength();
00482                     for(int i = 0; i < pointData->Size(); i++)
00483                     {
00484                         Vector::VectorTem<Real64> descriptor(n, 
00485                             pointData->GetDescriptorData(i), true);
00486 
00487                         if(!mClusterInputData)
00488                         {
00489                             ILOG_DEBUG("initializing mClusterInputData");
00490                             // initialize the table
00491                             FeatureDefinition def = GetFeatureName();
00492                             def.AddParameter("clusterinput", "2");
00493                             mClusterInputData = new FeatureTable(def, 500, n);
00494                         }
00495 
00496                         // string representation of point:
00497                         //point->Serialize(borderOffset+1, borderOffset+1)
00498                         //mClusterInputData->Add(mClusterInputImage + " " +
00499                         //point->Serialize(), descriptor); TODO: create proper
00500                         //CLUSTERINPUT quid class
00501                         mClusterInputData->Add(mClusterInputData->Size() + 1,
00502                                                descriptor);
00503                     }
00504                     ILOG_DEBUG("done with cluster input");
00505                 }
00506                 else
00507                 {
00508                     ILOG_DEBUG("writing point list");
00509                     if(outputFilename.empty())
00510                     {
00511                         ILOG_WARN("Warning: no output file to write to. Did you forget to specify --output?");
00512                     }
00513                     else
00514                     {
00515                         pointData->ExportToFile(outputFilename, mStripBorder, 
00516                                                 mOutputFormat);
00517                     }
00518                 }
00519             }
00520             if(!borderAlreadyRemoved)
00521             {
00522                 delete inputNoBorder;
00523             }
00524         }
00525 
00526         ILOG_DEBUG("Completed " << GetFeatureName() << " in " <<
00527                    timer.SplitTimeStr());
00528         delete pointData;
00529 
00530         return true;
00531     }

Here is the call graph for this function:


Generated on Thu Jan 13 09:19:19 2011 for ImpalaSrc by  doxygen 1.5.1