Definition at line 425 of file mainUtil.cpp. References Impala::Core::VideoSet::Mpeg7Doc::AddAnnotation(), Impala::atol(), Impala::Util::DatabaseReadStrings(), Impala::FileNameBase(), Impala::FileNamePath(), Impala::FileNameTail(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::Database::RawDataSet::GetFile(), Impala::Core::VideoSet::Keyframes::GetFrameId(), Impala::Core::VideoSet::Keyframes::GetFrameNr(), Impala::CmdOptions::GetInstance(), Impala::Core::VideoSet::Keyframes::GetName(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Segmentation::GetNrFramesVideo(), Impala::Core::VideoSet::Keyframes::GetVideoId(), ILOG_ERROR, ILOG_INFO, ILOG_NDC_POP, ILOG_NDC_PUSH, ILOG_VAR, ILOG_WARN, Impala::Core::VideoSet::MakeVideoSet(), and Impala::Core::VideoSet::Mpeg7DocWrite(). Referenced by mainUtil(). 00426 { 00427 #ifndef REPOSITORY_TODO 00428 typedef Core::VideoSet::VideoSet VideoSet; 00429 typedef Core::VideoSet::Segmentation Segmentation; 00430 typedef Core::VideoSet::Keyframes Keyframes; 00431 typedef Core::VideoSet::Mpeg7Doc Mpeg7Doc; 00432 00433 ILOG_VAR(Impala.Application.Util.DoImportAnnotations); 00434 CmdOptions& options = CmdOptions::GetInstance(); 00435 if (options.GetNrArg() < 4) 00436 { 00437 ILOG_ERROR("Need more parameters"); 00438 return; 00439 } 00440 String videoSetName = options.GetArg(1); 00441 int fractions = Impala::atol(options.GetArg(2)); 00442 if ((fractions != 25) && (fractions != 30000)) 00443 ILOG_WARN("Never tried fractions = " << fractions); 00444 String conceptSet = options.GetArg(3); 00445 00446 VideoSet* vidSet = Core::VideoSet::MakeVideoSet(videoSetName); 00447 SegmentationLocator sLoc(videoSetName, "segmentation", options); 00448 Segmentation* segmentation = SegmentationRepository().Get(sLoc, vidSet); 00449 KeyframesLocator kLoc(videoSetName, "keyframes", options); 00450 Keyframes* keyframes = KeyframesRepository().Get(kLoc, vidSet); 00451 std::vector<String> concepts; 00452 Impala::Util::Database* db = vidSet->GetDatabase(); 00453 Impala::Util::DatabaseReadStrings(concepts, conceptSet, db); 00454 String path = FileNamePath(conceptSet) + "/"; 00455 conceptSet = FileNameTail(conceptSet); 00456 for (int c=0 ; c<concepts.size() ; c++) 00457 { 00458 ILOG_INFO("doing concept " << concepts[c]); 00459 ILOG_NDC_PUSH(concepts[c]); 00460 String fName = path + concepts[c] + ".ann"; 00461 std::vector<String> lines; 00462 Impala::Util::DatabaseReadStrings(lines, fName, db); 00463 int curVidId = -1; 00464 Mpeg7Doc* curDoc = 0; 00465 for (int l=0 ; l<lines.size() ; l++) 00466 { 00467 Impala::Util::StringParser p(lines[l]); 00468 String s = p.GetString(' '); // Person 00469 s = p.GetString(' '); // Organizer 00470 s = p.GetString(' '); // Concept 00471 s = p.GetString(' '); // Videoname 00472 s = Impala::FileNameTail(p.GetString(' ')); // Keyframename 00473 int key = keyframes->GetFrameId(s + ".jpg"); 00474 if (key == -1) 00475 { 00476 ILOG_ERROR("Unable to find keyframe " << s); 00477 continue; 00478 } 00479 double relevance = (p.GetString(' ', false) == "P") ? 1.0 : 0.0; 00480 double confidence = 1.0; 00481 if (!p.TheEnd() && (p.GetString(' ', false) == "S")) 00482 relevance = 0.5; // open for debate :-) 00483 00484 if (keyframes->GetVideoId(key) != curVidId) 00485 { // new video 00486 if (curDoc) 00487 { 00488 Core::VideoSet::Mpeg7DocWrite(curDoc, vidSet, curVidId); 00489 delete curDoc; 00490 curDoc = 0; 00491 } 00492 curVidId = keyframes->GetVideoId(key); 00493 String vidFile = vidSet->GetFile(curVidId); 00494 int nrFrames = segmentation->GetNrFramesVideo(curVidId); 00495 curDoc = new Mpeg7Doc(vidFile, vidFile, nrFrames, fractions, 00496 false, conceptSet, concepts[c]); 00497 } 00498 String name = FileNameBase(keyframes->GetName(key)); 00499 int frameNr = keyframes->GetFrameNr(key); 00500 curDoc->AddAnnotation(concepts[c], name, frameNr, frameNr, 00501 relevance, confidence); 00502 } 00503 if (curDoc) 00504 { 00505 Core::VideoSet::Mpeg7DocWrite(curDoc, vidSet, curVidId); 00506 delete curDoc; 00507 } 00508 ILOG_NDC_POP; 00509 } 00510 #endif 00511 }
Here is the call graph for this function:
|