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

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

Definition at line 46 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::GetDatabase(), Impala::Core::Database::RawDataSet::GetFileId(), Impala::Core::Database::RawDataSet::GetFilePathFrames(), 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, Impala::Core::VideoSet::MakeVideoSet(), and Impala::Core::Array::WritePng().

Referenced by mainUtil().

00047 {
00048     typedef Core::VideoSet::VideoSet VideoSet;
00049     typedef Core::VideoSet::Keyframes Keyframes;
00050     typedef Core::Array::Array2dVec3UInt8 Array2dVec3UInt8;
00051 
00052     ILOG_VAR(Impala.Application.Util.DoTrecTopicData);
00053     CmdOptions& options = CmdOptions::GetInstance();
00054     if (options.GetNrArg() < 4)
00055     {
00056         ILOG_ERROR("Need more parameters");
00057         return;
00058     }
00059     VideoSet* sVidSet = Core::VideoSet::MakeVideoSet(options.GetArg(1));
00060     Core::Trec::TrecTopic topic(options.GetArg(2));
00061     ILOG_DEBUG("Generating data sets");
00062     String dSetName = topic.GenerateDataSets(options.GetArg(3));
00063     bool doVideo = true;
00064     if (options.GetNrArg() > 4)
00065         if (options.GetArg(4) == "novideo")
00066             doVideo = false;
00067     VideoSet* dVidSet = Core::VideoSet::MakeVideoSet(dSetName);
00068     KeyframesLocator kLoc(dSetName, "keyframes", options);
00069     Keyframes* keyframes = KeyframesRepository().Get(kLoc, dVidSet);
00070     int curKey = -1;
00071     for (int i=0 ; i<topic.NrTopic() ; i++)
00072     //for (int i=0 ; i<1 ; i++)
00073     {
00074         for (int j=0 ; j<topic.GetNrExamples(i) ; j++)
00075         {
00076             curKey++;
00077             ILOG_INFO("nr " << curKey << " of " << keyframes->GetNrKeyframes());
00078             ILOG_DEBUG("topic = " << i << ", example = " << j);
00079             ILOG_DEBUG("topic = " << topic.GetTopicNum(i));
00080             String vidName = topic.GetVideoExampleSrcFile(i, j);
00081             ILOG_DEBUG("vidName = " << vidName);
00082             int vidId = sVidSet->GetFileId(vidName);
00083             if (vidId == -1)
00084             {
00085                 ILOG_ERROR("Unable to locate video " << vidName);
00086                 continue;
00087             }
00088             Core::Stream::RgbDataSrc* src = sVidSet->GetVideo(vidId);
00089             if (src == 0)
00090             {
00091                 ILOG_ERROR("Unable to locate video " << vidName);
00092                 continue;
00093             }
00094             int startFr = topic.GetVideoExampleStartFrame(i, j);
00095             int endFr = topic.GetVideoExampleEndFrame(i, j);
00096             src->GotoFrame((startFr + endFr) / 2);
00097             Array2dVec3UInt8* wrapper = Core::Array::ArrayCreate<Array2dVec3UInt8>
00098                 (src->FrameWidth(), src->FrameHeight(), 0, 0, src->DataPtr(),
00099                  true);
00100             int frameNr = keyframes->GetFrameNr(curKey);
00101 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00102             String fName = dVidSet->GetFilePathFrames(curKey, frameNr, ".png",
00103                                                       true, false);
00104             if (fName.empty())
00105             {
00106                 ILOG_ERROR("Cannot write keyframe");
00107             }
00108             else
00109             {
00110                 Core::Array::WritePng(wrapper, fName, dVidSet->GetDatabase());
00111             }
00112 #else // REPOSITORY_USED
00113             String container = dVidSet->GetContainerFile(curKey);
00114             Persistency::FrameLocator loc(dVidSet->GetLocator(), container,
00115                                           frameNr, ".png");
00116             Persistency::FrameRepository().Add(loc, wrapper);
00117 #endif // REPOSITORY_USED
00118             delete wrapper;
00119             delete src;
00120 
00121             if (!doVideo)
00122                 continue;
00123 
00124             // get video clip
00125             String exeName("mencoder -oac copy -ovc copy -of mpeg");
00126             Impala::Util::StringParser pStart(topic.GetVideoExampleStart(i, j));
00127             int startM = pStart.GetInt('m');
00128             pStart.AdvanceP();
00129             int startS = pStart.GetInt('.');
00130             pStart.AdvanceP();
00131             int startF = pStart.GetInt('s');
00132             String duration = topic.GetVideoExampleDuration(i, j);
00133             String vidFileName = sVidSet->GetResolvedVideoPath(vidId);
00134             char sysBuf[1024];
00135             sprintf(sysBuf, "%s %s -o %s -ss %d:%d.%d -endpos %s",
00136                     exeName.c_str(), vidFileName.c_str(),
00137                     topic.GetVideoExampleName(i, j, true).c_str(),
00138                     startM, startS, startF, duration.c_str());
00139 
00140             for (int c=0 ; c<1024 ; c++)
00141                 if (sysBuf[c] == '/')
00142                     sysBuf[c] = '\\';
00143                 
00144             ILOG_DEBUG("sysbuf = [" << sysBuf << "]");
00145             int sysRes = system(sysBuf);
00146             if (sysRes != 0)
00147             {
00148                 ILOG_ERROR("system ["  << sysBuf << "]");
00149                 return;
00150             }
00151         }
00152     }
00153     delete sVidSet;
00154     delete dVidSet;
00155 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:51:59 2010 for ImpalaSrc by  doxygen 1.5.1