Definition at line 493 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::Keyframes::GetFirstKeyframeShot(), Impala::Core::VideoSet::Keyframes::GetFirstKeyframeVideo(), Impala::Core::VideoSet::Segmentation::GetFirstShotVideo(), Impala::Core::VideoSet::Keyframes::GetFrameNr(), Impala::CmdOptions::GetInstance(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::Core::VideoSet::Segmentation::GetName(), Impala::Core::VideoSet::Keyframes::GetName(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetNrFramesVideo(), Impala::Core::VideoSet::Keyframes::GetNrKeyframesShot(), Impala::Core::VideoSet::Keyframes::GetNrKeyframesVideo(), Impala::Core::VideoSet::Segmentation::GetNrShotsVideo(), Impala::Core::VideoSet::VideoSet::GetVideo(), ILOG_ERROR, ILOG_INFO, ILOG_NDC_POP, ILOG_NDC_PUSH, ILOG_VAR, ILOG_WARN, Impala::Core::VideoSet::Keyframes::IsRKF(), Impala::Core::VideoSet::MakeVideoSet(), Impala::Core::VideoSet::Mpeg7DocWrite(), Impala::Core::Database::RawDataSet::NrFiles(), and Impala::Persistency::RepositoryGetFile(). Referenced by mainUtil(). 00494 { 00495 typedef Core::VideoSet::VideoSet VideoSet; 00496 typedef Core::VideoSet::Segmentation Segmentation; 00497 typedef Core::VideoSet::Keyframes Keyframes; 00498 typedef Core::VideoSet::Mpeg7Doc Mpeg7Doc; 00499 00500 ILOG_VAR(Impala.Application.Util.DoExportAnnoMpeg7); 00501 CmdOptions& options = CmdOptions::GetInstance(); 00502 if (options.GetNrArg() < 5) 00503 { 00504 ILOG_ERROR("Need more parameters"); 00505 return; 00506 } 00507 String videoSetName = options.GetArg(1); 00508 int fractions = Impala::atol(options.GetArg(2)); 00509 if ((fractions != 25) && (fractions != 30000)) 00510 ILOG_WARN("Never tried fractions = " << fractions); 00511 String conceptSet = options.GetArg(3); 00512 String anno = options.GetArg(4); 00513 bool hasKeyframes = false; 00514 if (anno == "hasKeyframes") 00515 { 00516 hasKeyframes = true; 00517 } 00518 else if (anno != "hasShots") 00519 { 00520 ILOG_ERROR("Argument should be hasShots or hasKeyframes"); 00521 return; 00522 } 00523 00524 VideoSet* vidSet = Core::VideoSet::MakeVideoSet(videoSetName); 00525 SegmentationLocator sLoc(videoSetName, "segmentation", options); 00526 Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet); 00527 KeyframesLocator kLoc(videoSetName, "keyframes", options); 00528 Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet); 00529 Persistency::KeywordListLocator loc(vidSet->GetLocator(), conceptSet); 00530 Core::Table::KeywordList concepts = 00531 *(Persistency::KeywordListRepository().Get(loc)); 00532 for (int c=0 ; c<concepts.size() ; c++) 00533 { 00534 ILOG_INFO("doing concept " << concepts[c]); 00535 ILOG_NDC_PUSH(concepts[c]); 00536 String fName = "Annotations/groundtruth/" + concepts[c] + ".truth"; 00537 Persistency::FileLocator fLoc(vidSet->GetLocator(), fName); 00538 Persistency::File file = RepositoryGetFile(fLoc, false, false); 00539 std::vector<String> annos; 00540 file.ReadStrings(annos); 00541 std::sort(annos.begin(), annos.end()); 00542 for (int v=0 ; v<vidSet->NrFiles() ; v++) 00543 { 00544 String vidFile = vidSet->GetFile(v); 00545 int nrFrames = segmentation->GetNrFramesVideo(v); 00546 int frameRateNum = 0; 00547 int frameRateDen = 0; 00548 if (fractions == 0) 00549 { 00550 Core::Stream::RgbDataSrc* rgbSrc = vidSet->GetVideo(v); 00551 if ((!rgbSrc) || (rgbSrc->FrameRateNum() < 0) 00552 || (rgbSrc->FrameRateDen() < 0)) 00553 { 00554 ILOG_ERROR("Need src with known frame rate"); 00555 continue; 00556 } 00557 frameRateNum = rgbSrc->FrameRateNum(); 00558 frameRateDen = rgbSrc->FrameRateDen(); 00559 if (rgbSrc) 00560 delete rgbSrc; 00561 } 00562 Mpeg7Doc mp7(vidFile, vidFile, nrFrames, fractions, false, 00563 conceptSet, concepts[c], frameRateNum, frameRateDen); 00564 if (hasKeyframes) 00565 { 00566 for (int k=0 ; k<keyframes->GetNrKeyframesVideo(v) ; k++) 00567 { 00568 int keyId = keyframes->GetFirstKeyframeVideo(v) + k; 00569 String keyName = FileNameBase(keyframes->GetName(keyId)); 00570 int frameNr = keyframes->GetFrameNr(keyId); 00571 double relevance = 0; 00572 if (find(annos.begin(),annos.end(),keyName) != annos.end()) 00573 relevance = 1; 00574 mp7.AddAnnotation(concepts[c], keyName, frameNr, frameNr, 00575 relevance, 1); 00576 } 00577 } 00578 else 00579 { 00580 for (int s=0 ; s<segmentation->GetNrShotsVideo(v) ; s++) 00581 { 00582 int shotId = segmentation->GetFirstShotVideo(v) + s; 00583 String shotName = segmentation->GetName(shotId); 00584 double relevance = 0; 00585 if (find(annos.begin(),annos.end(),shotName) != annos.end()) 00586 relevance = 1; 00587 int firstKey = keyframes->GetFirstKeyframeShot(shotId); 00588 int nrKey = keyframes->GetNrKeyframesShot(shotId); 00589 for (int k=firstKey ; k<firstKey+nrKey ; k++) 00590 { 00591 if (!keyframes->IsRKF(k)) 00592 continue; 00593 String keyName = FileNameBase(keyframes->GetName(k)); 00594 int frameNr = keyframes->GetFrameNr(k); 00595 mp7.AddAnnotation(concepts[c], keyName, frameNr, 00596 frameNr, relevance, 1); 00597 } 00598 } 00599 } 00600 Core::VideoSet::Mpeg7DocWrite(&mp7, vidSet, v); 00601 } 00602 ILOG_NDC_POP; 00603 } 00604 }
Here is the call graph for this function: ![]()
|