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

void Impala::Application::Util::DoTrecTopicData (  ) 

Definition at line 111 of file mainUtil.cpp.

References Impala::Core::Stream::RgbDataSrc::DataPtr(), Impala::Core::Stream::RgbDataSrc::FrameHeight(), Impala::Core::Stream::RgbDataSrc::FrameWidth(), Impala::CmdOptions::GetArg(), Impala::Core::Database::RawDataSet::GetContainerFile(), Impala::Core::Database::RawDataSet::GetFileId(), Impala::Core::VideoSet::Keyframes::GetFrameNr(), Impala::CmdOptions::GetInstance(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::Keyframes::GetNrKeyframes(), Impala::Core::VideoSet::VideoSet::GetResolvedVideoPath(), Impala::Core::VideoSet::VideoSet::GetVideo(), Impala::Core::Stream::RgbDataSrc::GotoFrame(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_VAR, and Impala::Core::VideoSet::MakeVideoSet().

Referenced by mainUtil().

00112 {
00113     typedef Core::VideoSet::VideoSet VideoSet;
00114     typedef Core::VideoSet::Keyframes Keyframes;
00115     typedef Core::Array::Array2dVec3UInt8 Array2dVec3UInt8;
00116 
00117     ILOG_VAR(Impala.Application.Util.DoTrecTopicData);
00118     CmdOptions& options = CmdOptions::GetInstance();
00119     if (options.GetNrArg() < 4)
00120     {
00121         ILOG_ERROR("Need more parameters");
00122         return;
00123     }
00124     VideoSet* sVidSet = Core::VideoSet::MakeVideoSet(options.GetArg(1));
00125     Core::Trec::TrecTopic topic(options.GetArg(2));
00126     ILOG_DEBUG("Generating data sets");
00127     String dSetName = topic.GenerateDataSets(options.GetArg(3));
00128     bool doVideo = true;
00129     if (options.GetNrArg() > 4)
00130         if (options.GetArg(4) == "novideo")
00131             doVideo = false;
00132     VideoSet* dVidSet = Core::VideoSet::MakeVideoSet(dSetName);
00133     KeyframesLocator kLoc(dSetName, "keyframes", options);
00134     Keyframes* keyframes = KeyframesRepository().Get(kLoc, dVidSet);
00135     int curKey = -1;
00136     for (int i=0 ; i<topic.NrTopic() ; i++)
00137     //for (int i=0 ; i<1 ; i++)
00138     {
00139         for (int j=0 ; j<topic.GetNrExamples(i) ; j++)
00140         {
00141             curKey++;
00142             ILOG_INFO("nr " << curKey << " of " << keyframes->GetNrKeyframes());
00143             ILOG_DEBUG("topic = " << i << ", example = " << j);
00144             ILOG_DEBUG("topic = " << topic.GetTopicNum(i));
00145             String vidName = topic.GetVideoExampleSrcFile(i, j);
00146             ILOG_DEBUG("vidName = " << vidName);
00147             int vidId = sVidSet->GetFileId(vidName);
00148             if (vidId == -1)
00149             {
00150                 ILOG_ERROR("Unable to locate video " << vidName);
00151                 continue;
00152             }
00153             Core::Stream::RgbDataSrc* src = sVidSet->GetVideo(vidId);
00154             if (src == 0)
00155             {
00156                 ILOG_ERROR("Unable to locate video " << vidName);
00157                 continue;
00158             }
00159             int startFr = topic.GetVideoExampleStartFrame(i, j);
00160             int endFr = topic.GetVideoExampleEndFrame(i, j);
00161             src->GotoFrame((startFr + endFr) / 2);
00162             Array2dVec3UInt8* wrapper = Core::Array::ArrayCreate<Array2dVec3UInt8>
00163                 (src->FrameWidth(), src->FrameHeight(), 0, 0, src->DataPtr(),
00164                  true);
00165             int frameNr = keyframes->GetFrameNr(curKey);
00166             String container = dVidSet->GetContainerFile(curKey);
00167             Persistency::FrameLocator loc(dVidSet->GetLocator(), container,
00168                                           frameNr, ".png");
00169             Persistency::FrameRepository().Add(loc, wrapper);
00170             delete wrapper;
00171             delete src;
00172 
00173             if (!doVideo)
00174                 continue;
00175 
00176             // get video clip
00177             String exeName("mencoder -oac copy -ovc copy -of mpeg");
00178             Impala::Util::StringParser pStart(topic.GetVideoExampleStart(i, j));
00179             int startM = pStart.GetInt('m');
00180             pStart.AdvanceP();
00181             int startS = pStart.GetInt('.');
00182             pStart.AdvanceP();
00183             int startF = pStart.GetInt('s');
00184             String duration = topic.GetVideoExampleDuration(i, j);
00185             String vidFileName = sVidSet->GetResolvedVideoPath(vidId);
00186             char sysBuf[1024];
00187             sprintf(sysBuf, "%s %s -o %s -ss %d:%d.%d -endpos %s",
00188                     exeName.c_str(), vidFileName.c_str(),
00189                     topic.GetVideoExampleName(i, j, true).c_str(),
00190                     startM, startS, startF, duration.c_str());
00191 
00192             for (int c=0 ; c<1024 ; c++)
00193                 if (sysBuf[c] == '/')
00194                     sysBuf[c] = '\\';
00195                 
00196             ILOG_DEBUG("sysbuf = [" << sysBuf << "]");
00197             int sysRes = system(sysBuf);
00198             if (sysRes != 0)
00199             {
00200                 ILOG_ERROR("system ["  << sysBuf << "]");
00201                 return;
00202             }
00203         }
00204     }
00205     delete sVidSet;
00206     delete dVidSet;
00207 }

Here is the call graph for this function:


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