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

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

Definition at line 361 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::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CH(), ComputeDescriptors(), Impala::Core::Array::Array2dTem< StorT, elemSize, ArithT >::CW(), Impala::Core::Vector::VectorTem< ElemT >::Elem(), Impala::Core::Geometry::InterestPointList::EraseAndDelete(), Impala::Core::Feature::PointDescriptorTable::ExportToFile(), GetFeatureName(), Impala::CmdOptions::GetString(), ILOG_DEBUG, ILOG_INFO, ILOG_WARN, Impala::Core::Feature::PointDescriptorTable::ImportFromFile(), Impala::Core::Array::MakeRoi(), mClusterInput, mClusterInputData, mCodebook, mKeepLimited, mLastCodebookVectors, mOutputFormat, mStripBorder, ProjectOntoCodebook(), ReducePointCount(), Impala::Core::Table::Table::Size(), Impala::Timer::SplitTimeStr(), and Impala::Core::Feature::PointDescriptorTable::ToPointList().

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

00365     {
00366         ILOG_DEBUG("start FindInterestPoints");
00367         if(loadRegionsFilename == "")
00368         {
00369             // try the command-line argument if it is not already specified
00370             loadRegionsFilename = options.GetString("loadRegions");
00371         }
00372         String saveRegionsFilename = options.GetString("saveRegions");
00373         String detectorMode = options.GetString("detector");
00374         String descriptorMode = options.GetString("descriptor");
00375         Timer timer;
00376         Array::Array2dVec3UInt8* inputNoBorder = input;
00377         if(!borderAlreadyRemoved)
00378         {
00379             // remove the border, if requested
00380             Geometry::Rectangle rect(mStripBorder, mStripBorder,
00381                                      input->CW() - mStripBorder - 1,
00382                                      input->CH() - mStripBorder - 1, true);
00383             inputNoBorder = MakeRoi(input, rect);
00384         }
00385 
00386         PointDescriptorTable* pointData = 0;
00387 
00388         /* Apply detector */
00389         ILOG_DEBUG("applying detector");
00390         if(!loadRegionsFilename.empty())
00391         {
00392             // load the points from file
00393             pointData = PointDescriptorTable::ImportFromFile(detectorMode, 
00394                                           loadRegionsFilename, mStripBorder);
00395         }
00396 
00397         if(loadRegionsFilename.empty())
00398         {
00399             pointData = ApplyDetector(inputNoBorder, detectorMode);
00400         }
00401         if(descriptorMode.empty())
00402         {
00403             // dump the interest regions to the output stream if we are not
00404             // going to compute descriptors later
00405             pointData->ExportToFile(outputFilename, mStripBorder, 
00406                                     mOutputFormat);
00407         }
00408         if(!saveRegionsFilename.empty())
00409         {
00410             ILOG_INFO("Writing to: " << saveRegionsFilename);
00411             pointData->ExportToFile(saveRegionsFilename, mStripBorder,
00412                                     mOutputFormat);
00413         }
00414 
00415         ILOG_DEBUG("[Timing] Region loading / applying detector finished in "
00416                    << timer.SplitTimeStr());
00417 
00418         /* descriptor computation */
00419         ILOG_DEBUG("computing descriptor");
00420         if(descriptorMode.size() != 0)
00421         {
00422             ComputeDescriptors(pointData, inputNoBorder, descriptorMode);
00423 
00424             ILOG_DEBUG("[Timing] Descriptors finished at " << timer.SplitTimeStr());
00425             if(mCodebook)
00426             {
00427                 ILOG_DEBUG("preparing for codebook");
00428                 // clean up previous codebook vectors (if any)
00429                 for(int i = 0; i < mLastCodebookVectors.size(); i++)
00430                 {
00431                     delete mLastCodebookVectors[i];
00432                 }
00433                 mLastCodebookVectors.clear();
00434                 /* project it onto a codebook */
00435                 Timer timerProjection;
00436                 pointData = ProjectOntoCodebook(pointData,
00437                                     options.GetString("codebookMode"),
00438                                     inputNoBorder->CW(), inputNoBorder->CH(),
00439                                     quid);
00440                 ILOG_DEBUG("Just codebook projection took: " <<
00441                            timerProjection.SplitTimeStr());
00442                 if(outputFilename.size() != 0)
00443                 {
00444                     pointData->ExportToFile(outputFilename, mStripBorder, 
00445                                             mOutputFormat);
00446                 }
00447             }
00448             else
00449             {
00450                 // do reduction
00451                 if((mKeepLimited > 0) && (pointData->Size() > mKeepLimited))
00452                 {
00453                     ILOG_DEBUG("reducing point count");
00454                     // we might have to limit the number of points
00455                     pointData = ReducePointCount(pointData, mKeepLimited);
00456                 }
00457 
00458                 if(mClusterInput)
00459                 {
00460                     ILOG_DEBUG("doing cluster input");
00461                     InterestPointList outputPointList;
00462                     pointData->ToPointList(outputPointList);
00463 
00464                     for(InterestPointList::iterator iter = outputPointList.begin();
00465                         iter != outputPointList.end(); iter++)
00466                     {
00467                         InterestPoint* point = *iter;
00468                         int n = point->mDescriptor.size();
00469                         Vector::VectorTem<Real64> descriptor(n);
00470                         for(int i = 0; i < n; i++)
00471                         {
00472                             descriptor.Elem(i) = point->mDescriptor[i];
00473                         }
00474 
00475                         if(!mClusterInputData)
00476                         {
00477                             ILOG_DEBUG("initializing mClusterInputData");
00478                             // initialize the table
00479                             FeatureDefinition def = GetFeatureName();
00480                             def.AddParameter("clusterinput", "2");
00481                             mClusterInputData = new FeatureTable(def, 500, n);
00482                         }
00483 
00484                         // string representation of point:
00485                         //point->Serialize(borderOffset+1, borderOffset+1)
00486                         //mClusterInputData->Add(mClusterInputImage + " " +
00487                         //point->Serialize(), descriptor); TODO: create proper
00488                         //CLUSTERINPUT quid class
00489                         mClusterInputData->Add(mClusterInputData->Size() + 1,
00490                                                descriptor);
00491                     }
00492                     ILOG_DEBUG("done with cluster input");
00493                     outputPointList.EraseAndDelete();
00494                 }
00495                 else
00496                 {
00497                     ILOG_DEBUG("writing point list");
00498                     if(outputFilename.empty())
00499                     {
00500                         ILOG_WARN("Warning: no output file to write to. Did you forget to specify --output?");
00501                     }
00502                     else
00503                     {
00504                         pointData->ExportToFile(outputFilename, mStripBorder, 
00505                                                 mOutputFormat);
00506                     }
00507                 }
00508             }
00509             if(!borderAlreadyRemoved)
00510             {
00511                 delete inputNoBorder;
00512             }
00513         }
00514 
00515         ILOG_DEBUG("Completed " << GetFeatureName() << " in " <<
00516                    timer.SplitTimeStr());
00517         delete pointData;
00518 
00519         return true;
00520     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:09:56 2010 for ImpalaSrc by  doxygen 1.5.1