Definition at line 517 of file mainUtil.cpp. References Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Add(), Impala::Core::VideoSet::Mpeg7Doc::AddAnnotation(), Impala::atol(), Impala::Util::DatabaseReadStrings(), Impala::FileNameBase(), Impala::Util::SimpleMapBase< IdxT, ElemT, DelT >::Get(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::Database::RawDataSet::GetFile(), Impala::Util::Database::GetFilePath(), 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(). 00518 { 00519 #ifndef REPOSITORY_TODO 00520 typedef Core::VideoSet::VideoSet VideoSet; 00521 typedef Core::VideoSet::Segmentation Segmentation; 00522 typedef Core::VideoSet::Keyframes Keyframes; 00523 typedef Core::VideoSet::Mpeg7Doc Mpeg7Doc; 00524 00525 ILOG_VAR(Impala.Application.Util.DoImportAnnotations); 00526 CmdOptions& options = CmdOptions::GetInstance(); 00527 if (options.GetNrArg() < 6) 00528 { 00529 ILOG_ERROR("Need more parameters"); 00530 return; 00531 } 00532 String videoSetName = options.GetArg(1); 00533 int fractions = Impala::atol(options.GetArg(2)); 00534 if ((fractions != 25) && (fractions != 30000)) 00535 ILOG_WARN("Never tried fractions = " << fractions); 00536 String conceptSet = options.GetArg(3); 00537 String mappingName = options.GetArg(4); 00538 String inputPath = options.GetArg(5); 00539 00540 VideoSet* vidSet = Core::VideoSet::MakeVideoSet(videoSetName); 00541 SegmentationLocator sLoc(videoSetName, "segmentation", options); 00542 Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet); 00543 KeyframesLocator kLoc(videoSetName, "keyframes", options); 00544 Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet); 00545 Impala::Util::Database* db = vidSet->GetDatabase(); 00546 00547 String fName = vidSet->GetFilePathAnnotation(conceptSet, false, false); 00548 if (fName.empty()) 00549 { 00550 ILOG_ERROR("unable to read conceptSet"); 00551 return; 00552 } 00553 std::vector<String> concepts; 00554 Impala::Util::DatabaseReadStrings(concepts, fName, db); 00555 00556 std::vector<String> lines; 00557 Impala::Util::SimpleMap<String, String> conceptMapping; 00558 Impala::Util::DatabaseReadStrings(lines, mappingName, db); 00559 for (int i=0 ; i<lines.size() ; i++) 00560 { 00561 Impala::Util::StringParser p(lines[i]); 00562 String topic = p.GetString(' '); 00563 String concept = p.GetString(' ', false); 00564 std::cout << topic << " = " << concept << std::endl; 00565 conceptMapping.Add(concept, topic); 00566 } 00567 for (int c=0 ; c<concepts.size() ; c++) 00568 { 00569 ILOG_INFO("doing concept " << concepts[c]); 00570 ILOG_NDC_PUSH(concepts[c]); 00571 00572 String topic; 00573 if (!conceptMapping.Get(concepts[c], topic)) 00574 { 00575 ILOG_ERROR("no topic for " << concepts[c]); 00576 ILOG_NDC_POP; 00577 continue; 00578 } 00579 00580 std::vector<String> posAnnos; 00581 fName = inputPath + "." + topic + ".1"; 00582 fName = db->GetFilePath(fName, false, true); 00583 if (!fName.empty()) 00584 Impala::Util::DatabaseReadStrings(posAnnos, fName, db); 00585 00586 std::vector<String> negAnnos; 00587 fName = inputPath + "." + topic + ".0"; 00588 fName = db->GetFilePath(fName, false, true); 00589 if (!fName.empty()) 00590 Impala::Util::DatabaseReadStrings(negAnnos, fName, db); 00591 if ((posAnnos.size() == 0) || (negAnnos.size() == 0)) 00592 { 00593 ILOG_ERROR("missing input for " << concepts[c]); 00594 ILOG_NDC_POP; 00595 continue; 00596 } 00597 00598 std::sort(posAnnos.begin(), posAnnos.end()); 00599 std::sort(negAnnos.begin(), negAnnos.end()); 00600 for (int v=0 ; v<vidSet->NrFiles() ; v++) 00601 { 00602 String vidFile = vidSet->GetFile(v); 00603 int nrFrames = segmentation->GetNrFramesVideo(v); 00604 Mpeg7Doc mp7(vidFile, vidFile, nrFrames, fractions, false, 00605 conceptSet, concepts[c]); 00606 00607 for (int s=0 ; s<segmentation->GetNrShotsVideo(v) ; s++) 00608 { 00609 int shotId = segmentation->GetFirstShotVideo(v) + s; 00610 String shotName = segmentation->GetName(shotId); 00611 double relevance = -1; 00612 if (find(posAnnos.begin(), posAnnos.end(), shotName) != 00613 posAnnos.end()) 00614 { 00615 relevance = 1; 00616 } 00617 else if (find(negAnnos.begin(), negAnnos.end(), shotName) != 00618 negAnnos.end()) 00619 { 00620 relevance = 0; 00621 } 00622 if (relevance < 0) 00623 continue; 00624 int key = keyframes->GetShotRKF(shotId); 00625 00626 String keyName = FileNameBase(keyframes->GetName(key)); 00627 int frameNr = keyframes->GetFrameNr(key); 00628 mp7.AddAnnotation(concepts[c], keyName, frameNr, frameNr, 00629 relevance, 1); 00630 } 00631 if (mp7.HasAnnotations()) 00632 Core::VideoSet::Mpeg7DocWrite(&mp7, vidSet, v); 00633 } 00634 ILOG_NDC_POP; 00635 } 00636 #endif 00637 }
Here is the call graph for this function:
|