Definition at line 899 of file mainMonetTest.cpp. References Impala::FileNameBase(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetInstance(), Impala::Core::Table::AnnotationTableSet::GetLabel(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::VideoSet::GetQuidVideo(), Impala::Core::Database::RawDataSet::GetSetNameBase(), Impala::Core::Table::AnnotationTableSet::GetTable(), ILOG_ERROR, ILOG_INFO, ILOG_VAR, Impala::Core::Table::AnnotationTableSet::MakeFromFile(), Impala::MakeString(), Impala::Core::VideoSet::MakeVideoSet(), Impala::QUID_CLASS_FRAME, Impala::QuidId(), Impala::QuidObject(), Impala::Core::Table::AnnotationTableSet::Size(), Impala::Timer::SplitTime(), and Impala::StringToQuidClass(). Referenced by mainMonetTest(). 00900 { 00901 ILOG_VAR(Impala.Samples.MonetTest.DoInsertAnnotations); 00902 CmdOptions& options = CmdOptions::GetInstance(); 00903 if (options.GetNrArg() < 7) 00904 { 00905 ILOG_ERROR("Need more parameters"); 00906 return; 00907 } 00908 00909 String vidSetName = options.GetArg(4); 00910 VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName); 00911 String conceptSet = options.GetArg(5); 00912 int quidClass = StringToQuidClass(options.GetArg(6)); 00913 if (quidClass != QUID_CLASS_FRAME) 00914 { 00915 ILOG_ERROR("Can do frame annotations only."); 00916 return; 00917 } 00918 00919 AnnotationTableSet* tSet = 00920 Core::Table::AnnotationTableSet::MakeFromFile(vidSet, conceptSet, true, 00921 quidClass); 00922 if (tSet == 0) 00923 return; 00924 00925 conn->Query("select i_add_annotator('fabchannel', 'the boss', true);", 00926 false, false); 00927 00928 conn->Query("delete from i_bulk_annotation;", false, false); 00929 Timer timer; 00930 for (int t=0 ; t<tSet->Size() ; t++) 00931 { 00932 AnnotationTable* tab = tSet->GetTable(t); 00933 String keyword = tSet->GetLabel(t); 00934 ILOG_INFO("keyword " << keyword << " has " << tab->Size() << " annos"); 00935 String date("2007/08/22-11:00:00"); 00936 int nr = tab->Size(); 00937 String q = "copy " + MakeString(nr) + 00938 " records into i_bulk_annotation from stdin using delimiters ' ';\n"; 00939 for (int i=0 ; i<nr ; i++) 00940 { 00941 Quid frameQuid = tab->Get1(i); 00942 int vidId = QuidObject(frameQuid); 00943 Quid vidQuid = vidSet->GetQuidVideo(vidId, false); 00944 int frameNr = QuidId(frameQuid); 00945 Real64 relevance = 0.5; // skip, using Mpeg7 convention 00946 if (tab->IsPositive(i)) 00947 relevance = 1.0; 00948 else if (tab->IsNegative(i)) 00949 relevance = 0.0; 00950 Real64 confidence = 1.0; 00951 q += keyword + " " + MakeString(vidQuid) + " " + MakeString(frameNr) 00952 + " " + MakeString(relevance) + " " + MakeString(confidence) 00953 + " " + date + "\n"; 00954 } 00955 conn->Query(q, false, false); 00956 } 00957 ILOG_INFO("Did bulk in " << timer.SplitTime()); 00958 String vidSetBase = vidSet->GetSetNameBase(); 00959 conn->Query("insert into annotation (fragment_id, keyword_id, annotator_id, \ 00960 relevance, confidence, \ 00961 annotation_date, approved) \ 00962 select fr.fragment_id, k.keyword_id, a.annotator_id, \ 00963 ba.relevance, ba.confidence, ba.annotation_date, \ 00964 a.approved \ 00965 from i_bulk_annotation ba, media m, fragment fr, \ 00966 video_sets vss, \ 00967 keyword_sets kss, keyword_set ks, keyword k, annotator a \ 00968 where ba.quid = m.quid and \ 00969 m.media_id = fr.media_id and \ 00970 fr.fragment_start = ba.fragment_start and \ 00971 fr.fragment_length = 1 and \ 00972 fr.keyframe = false and \ 00973 vss.set_name = '" + vidSetBase + "' and \ 00974 kss.set_name = '" + FileNameBase(conceptSet) + "' and \ 00975 kss.video_sets_id = vss.video_sets_id and \ 00976 ks.keyword_sets_id = kss.keyword_sets_id and \ 00977 ks.keyword_id = k.keyword_id and \ 00978 k.keyword_name = ba.keyword_name and \ 00979 a.annotator_name = 'fabchannel' \ 00980 order by ba.quid, ba.fragment_start;", false, false); 00981 conn->Query("delete from i_bulk_annotation;", false, false); 00982 delete tSet; 00983 delete vidSet; 00984 }
Here is the call graph for this function:
|