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

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

Definition at line 1023 of file mainUtil.cpp.

References Impala::Core::VideoSet::Mpeg7Doc::AddAnnotation(), Impala::atol(), Impala::FileNameBase(), Impala::Core::Stream::RgbDataSrc::FrameRateDen(), Impala::Core::Stream::RgbDataSrc::FrameRateNum(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetFile(), Impala::Core::VideoSet::Segmentation::GetFirstShotVideo(), Impala::Core::VideoSet::Keyframes::GetFrameNr(), Impala::CmdOptions::GetInstance(), Impala::Core::Database::RawDataSet::GetLocator(), 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::VideoSet::GetVideo(), 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().

01024 {
01025     typedef Core::VideoSet::VideoSet VideoSet;
01026     typedef Core::VideoSet::Segmentation Segmentation;
01027     typedef Core::VideoSet::Keyframes Keyframes;
01028     typedef Core::VideoSet::Mpeg7Doc Mpeg7Doc;
01029 
01030     ILOG_VAR(Impala.Application.Util.DoImportAnnotationsActive);
01031     CmdOptions& options = CmdOptions::GetInstance();
01032     if (options.GetNrArg() < 4)
01033     {
01034         ILOG_ERROR("Need more parameters");
01035         return;
01036     }
01037     String videoSetName = options.GetArg(1);
01038     int fractions = Impala::atol(options.GetArg(2));
01039     if ((fractions != 25) && (fractions != 30000))
01040         ILOG_WARN("Never tried fractions = " << fractions);
01041     String conceptSet = options.GetArg(3);
01042 
01043     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(videoSetName);
01044     SegmentationLocator sLoc(videoSetName, "segmentation", options);
01045     Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet);
01046     KeyframesLocator kLoc(videoSetName, "keyframes", options);
01047     Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet);
01048 
01049     KeywordListLocator loc(vidSet->GetLocator(), conceptSet);
01050     Core::Table::KeywordList concepts =
01051         *(Persistency::KeywordListRepository().Get(loc));
01052     for (int c=0 ; c<concepts.size() ; c++)
01053     {
01054         ILOG_INFO("doing concept " << concepts[c]);
01055         ILOG_NDC_PUSH(concepts[c]);
01056 
01057         std::vector<String> posAnnos;
01058         String fName = "from_active/" + concepts[c] + "/shots_bookmarked.txt";
01059         KeywordListLocator posLoc(vidSet->GetLocator(), fName);
01060         if (KeywordListRepository().Exists(posLoc))
01061             posAnnos = *(KeywordListRepository().Get(posLoc));
01062 
01063         std::vector<String> negAnnos;
01064         fName = "from_active/" + concepts[c] + "/shots_bookmarked_negative.txt";
01065         KeywordListLocator negLoc(vidSet->GetLocator(), fName);
01066         if (KeywordListRepository().Exists(negLoc))
01067             posAnnos = *(KeywordListRepository().Get(negLoc));
01068 
01069         if ((posAnnos.size() == 0) || (negAnnos.size() == 0))
01070         {
01071             ILOG_ERROR("missing input for " << concepts[c]);
01072             ILOG_NDC_POP;
01073             continue;
01074         }
01075 
01076         std::sort(posAnnos.begin(), posAnnos.end());
01077         std::sort(negAnnos.begin(), negAnnos.end());
01078         for (int v=0 ; v<vidSet->NrFiles() ; v++)
01079         {
01080             String vidFile = vidSet->GetFile(v);
01081             int nrFrames = segmentation->GetNrFramesVideo(v);
01082             int frameRateNum = 0;
01083             int frameRateDen = 0;
01084             if (fractions == 0)
01085             {
01086                 Core::Stream::RgbDataSrc* rgbSrc = vidSet->GetVideo(v);
01087                 if ((!rgbSrc) || (rgbSrc->FrameRateNum() < 0)
01088                     || (rgbSrc->FrameRateDen() < 0))
01089                 {
01090                     ILOG_ERROR("Need src with known frame rate");
01091                     continue;
01092                 }
01093                 frameRateNum = rgbSrc->FrameRateNum();
01094                 frameRateDen = rgbSrc->FrameRateDen();
01095                 if (rgbSrc)
01096                     delete rgbSrc;
01097             }
01098             Mpeg7Doc mp7(vidFile, vidFile, nrFrames, fractions, false,
01099                          conceptSet, concepts[c], frameRateNum, frameRateDen);
01100 
01101             for (int s=0 ; s<segmentation->GetNrShotsVideo(v) ; s++)
01102             {
01103                 int shotId = segmentation->GetFirstShotVideo(v) + s;
01104                 String shotName = segmentation->GetName(shotId);
01105                 double relevance = -1;
01106                 if (find(posAnnos.begin(), posAnnos.end(), shotName) !=
01107                     posAnnos.end())
01108                 {
01109                     relevance = 1;
01110                 }
01111                 else if (find(negAnnos.begin(), negAnnos.end(), shotName) !=
01112                          negAnnos.end())
01113                 {
01114                     relevance = 0;
01115                 }
01116                 if (relevance < 0)
01117                     continue;
01118                 int key = keyframes->GetShotRKF(shotId);
01119 
01120                 String keyName = FileNameBase(keyframes->GetName(key));
01121                 int frameNr = keyframes->GetFrameNr(key);
01122                 mp7.AddAnnotation(concepts[c], keyName, frameNr, frameNr,
01123                                   relevance, 1);
01124             }
01125             if (mp7.HasAnnotations())
01126                 Core::VideoSet::Mpeg7DocWrite(&mp7, vidSet, v);
01127         }
01128         ILOG_NDC_POP;
01129     }
01130 }

Here is the call graph for this function:


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