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

void Impala::Application::Util::DoImportAnnotationsActive (  ) 

Definition at line 645 of file mainUtil.cpp.

References Impala::Core::VideoSet::Mpeg7Doc::AddAnnotation(), Impala::atol(), Impala::Util::DatabaseReadStrings(), Impala::FileNameBase(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::Database::RawDataSet::GetFile(), Impala::Core::Database::RawDataSet::GetFilePathAnnotation(), Impala::Core::VideoSet::Segmentation::GetFirstShotVideo(), Impala::Core::VideoSet::Keyframes::GetFrameNr(), Impala::CmdOptions::GetInstance(), Impala::Core::VideoSet::Keyframes::GetName(), Impala::Core::VideoSet::Segmentation::GetName(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetNrFramesVideo(), Impala::Core::VideoSet::Segmentation::GetNrShotsVideo(), Impala::Core::VideoSet::Keyframes::GetShotRKF(), Impala::Core::VideoSet::Mpeg7Doc::HasAnnotations(), ILOG_ERROR, ILOG_INFO, ILOG_NDC_POP, ILOG_NDC_PUSH, ILOG_VAR, ILOG_WARN, Impala::Core::VideoSet::MakeVideoSet(), Impala::Core::VideoSet::Mpeg7DocWrite(), and Impala::Core::Database::RawDataSet::NrFiles().

Referenced by mainUtil().

00646 {
00647 #ifndef REPOSITORY_TODO
00648     typedef Core::VideoSet::VideoSet VideoSet;
00649     typedef Core::VideoSet::Segmentation Segmentation;
00650     typedef Core::VideoSet::Keyframes Keyframes;
00651     typedef Core::VideoSet::Mpeg7Doc Mpeg7Doc;
00652 
00653     ILOG_VAR(Impala.Application.Util.DoImportAnnotationsActive);
00654     CmdOptions& options = CmdOptions::GetInstance();
00655     if (options.GetNrArg() < 4)
00656     {
00657         ILOG_ERROR("Need more parameters");
00658         return;
00659     }
00660     String videoSetName = options.GetArg(1);
00661     int fractions = Impala::atol(options.GetArg(2));
00662     if ((fractions != 25) && (fractions != 30000))
00663         ILOG_WARN("Never tried fractions = " << fractions);
00664     String conceptSet = options.GetArg(3);
00665 
00666     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(videoSetName);
00667     SegmentationLocator sLoc(videoSetName, "segmentation", options);
00668     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
00669     KeyframesLocator kLoc(videoSetName, "keyframes", options);
00670     Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet);
00671     Impala::Util::Database* db = vidSet->GetDatabase();
00672 
00673     String fName = vidSet->GetFilePathAnnotation(conceptSet, false, false);
00674     if (fName.empty())
00675     {
00676         ILOG_ERROR("unable to read conceptSet");
00677         return;
00678     }
00679     std::vector<String> concepts;
00680     Impala::Util::DatabaseReadStrings(concepts, fName, db);
00681     for (int c=0 ; c<concepts.size() ; c++)
00682     {
00683         ILOG_INFO("doing concept " << concepts[c]);
00684         ILOG_NDC_PUSH(concepts[c]);
00685 
00686         std::vector<String> posAnnos;
00687         fName = "from_active/" + concepts[c] + "/shots_bookmarked.txt";
00688         fName = vidSet->GetFilePathAnnotation(fName, false, true);
00689         if (!fName.empty())
00690             Impala::Util::DatabaseReadStrings(posAnnos, fName, db);
00691 
00692         std::vector<String> negAnnos;
00693         fName = "from_active/" + concepts[c] + "/shots_bookmarked_negative.txt";
00694         fName = vidSet->GetFilePathAnnotation(fName, false, true);
00695         if (!fName.empty())
00696             Impala::Util::DatabaseReadStrings(negAnnos, fName, db);
00697         if ((posAnnos.size() == 0) || (negAnnos.size() == 0))
00698         {
00699             ILOG_ERROR("missing input for " << concepts[c]);
00700             ILOG_NDC_POP;
00701             continue;
00702         }
00703 
00704         std::sort(posAnnos.begin(), posAnnos.end());
00705         std::sort(negAnnos.begin(), negAnnos.end());
00706         for (int v=0 ; v<vidSet->NrFiles() ; v++)
00707         {
00708             String vidFile = vidSet->GetFile(v);
00709             int nrFrames = segmentation->GetNrFramesVideo(v);
00710             Mpeg7Doc mp7(vidFile, vidFile, nrFrames, fractions, false,
00711                          conceptSet, concepts[c]);
00712 
00713             for (int s=0 ; s<segmentation->GetNrShotsVideo(v) ; s++)
00714             {
00715                 int shotId = segmentation->GetFirstShotVideo(v) + s;
00716                 String shotName = segmentation->GetName(shotId);
00717                 double relevance = -1;
00718                 if (find(posAnnos.begin(), posAnnos.end(), shotName) !=
00719                     posAnnos.end())
00720                 {
00721                     relevance = 1;
00722                 }
00723                 else if (find(negAnnos.begin(), negAnnos.end(), shotName) !=
00724                          negAnnos.end())
00725                 {
00726                     relevance = 0;
00727                 }
00728                 if (relevance < 0)
00729                     continue;
00730                 int key = keyframes->GetShotRKF(shotId);
00731 
00732                 String keyName = FileNameBase(keyframes->GetName(key));
00733                 int frameNr = keyframes->GetFrameNr(key);
00734                 mp7.AddAnnotation(concepts[c], keyName, frameNr, frameNr,
00735                                   relevance, 1);
00736             }
00737             if (mp7.HasAnnotations())
00738                 Core::VideoSet::Mpeg7DocWrite(&mp7, vidSet, v);
00739         }
00740         ILOG_NDC_POP;
00741     }
00742 #endif
00743 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:52:07 2010 for ImpalaSrc by  doxygen 1.5.1