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

int Impala::Application::VidSet::mainVidSet ( int  argc,
char *  argv[] 
)

Definition at line 224 of file mainVidSet.cpp.

References Impala::Core::VideoSet::InterestPointProc::AddCmdOptions(), Impala::Core::VideoSet::Walker::AddKeyframeMaskAnnoFile(), Impala::Core::VideoSet::Walker::AddKeyframeMaskFile(), Impala::Core::VideoSet::Walker::AddListener(), Impala::CmdOptions::AddOption(), Impala::Core::VideoSet::Walker::AddRkfMask(), Impala::Core::VideoSet::Walker::DoWalk(), Impala::Core::VideoSet::Walker::DoWalkBookmarks(), Impala::Core::VideoSet::Walker::DoWalkKeyframes(), Impala::Core::VideoSet::Walker::DoWalkQuids(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Dump(), Impala::FileNameExt(), Impala::CmdOptions::GetArg(), Impala::CmdOptions::GetBool(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::Database::RawDataSet::GetFilePath(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetInt(), Impala::Core::Database::RawDataSet::GetLocator(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::TaskTable::GetNumberFiles(), Impala::Core::VideoSet::TaskTable::GetStartFile(), Impala::Core::VideoSet::TaskTable::GetStartFrame(), Impala::CmdOptions::GetString(), GetVideoTask(), ILOG_DEBUG, ILOG_ERROR, ILOG_ERROR_COUNT, ILOG_INFO, ILOG_VAR, Impala::CmdOptions::Initialise(), Impala::Core::VideoSet::WalkerConfig::InitOptions(), Impala::Core::VideoSet::Walker::LoadBookmarks(), Impala::Core::VideoSet::Walker::LoadKeyframes(), Impala::Core::VideoSet::Walker::LoadQuids(), Impala::Core::VideoSet::Walker::LoadSegmentation(), Impala::Application::MakeVideoSet(), MakeVideoTaskTable(), Impala::Core::VideoSet::Walker::NrListeners(), Impala::CmdOptions::ParseArgs(), Impala::Core::VideoSet::WalkerConfig::RetrieveOptions(), Impala::Core::VideoSet::TaskTable::Save(), and Impala::Core::VideoSet::Walker::TotalNrFramesInBookmarks().

Referenced by main().

00225 {
00226     Link::Mpi::Init(&argc, &argv);
00227 
00228     CmdOptions& options = CmdOptions::GetInstance();
00229     options.Initialise(true, false, true);
00230     options.AddOption(0, "report", "perNr", "0");
00231     options.AddOption(0, "startFile", "idx", "0");
00232     options.AddOption(0, "numberFiles", "nr", "-1");
00233     options.AddOption(0, "segmentation", "", "0");
00234     options.AddOption(0, "keyframes", "", "0");
00235     options.AddOption(0, "rkfMask", "", "0");
00236     options.AddOption(0, "keyframeMask", "file", "");
00237     options.AddOption(0, "keyframeMaskAnno", "file", "");
00238     options.AddOption(0, "quidWalk", "file", "");
00239     options.AddOption(0, "startTask", "idx", "-1");
00240     options.AddOption(0, "nrTaskWalk", "nr", "1"); // quick hack for process mgt
00241     options.AddOption(0, "taskByVideoSize", "", "0");
00242     options.AddOption(0, "maskFile", "file", "");
00243     options.AddOption(0, "precomputed", "[only works for applyconcepts] boolean: if 1 modelfiles must be for precomputed kernel", "0");
00244     options.AddOption(0, "storeKernelData", "[only works for applyconcepts] boolean: if 1 kernel data will be written to disk", "0");
00245     options.AddOption(0, "noFeatureCache", "", "0");
00246     options.AddOption(0, "msf-feature", "bool [for lbpeval]", "0");
00247 
00248     WalkerConfig walkerConfig;
00249     walkerConfig.InitOptions(options);
00250 
00251     // initialization of options
00252 #ifndef REPOSITORY_TODO
00253     Impala::Core::VideoSet::InterestPointProc::AddCmdOptions();
00254 #endif
00255 
00256     //Below are SS specific options   
00257     options.AddOption(0, "SSGUI", "", "0");
00258     options.AddOption(0, "SSProbThresh", "value", "0.5");
00259 
00260     if (! options.ParseArgs(argc, argv, "cmd videoSet|vxs|dbsection/file", 2))
00261     {
00262         Link::Mpi::Finalize();
00263         return 1;
00264     }
00265 
00266     ILOG_VAR(Impala.Application.VidSet.mainVidSet);
00267 
00268     ILOG_INFO("Disk images are " <<
00269               (Link::DiskImage::DiskImageUsed() ? "" : "not ") << "supported");
00270 
00271     String cmd = options.GetArg(0);
00272     String fileName = options.GetArg(1);
00273 
00274     VideoSet* videoSet = MakeVideoSet(fileName);
00275 
00276     walkerConfig.RetrieveOptions(options);
00277     Walker walker(videoSet, walkerConfig);
00278     Reporter* reporter = new Reporter(0);
00279     walker.AddListener(reporter);
00280 
00281     ILOG_INFO("vidset command : " << cmd);
00282 
00283 #ifndef REPOSITORY_TODO
00284     if (cmd == "computekerneldata")
00285         walker.AddListener(new ComputeKernelData(reporter, options));
00286     if (cmd == "testvideo")
00287         walker.AddListener(new TestVideo(reporter, options));
00288     if (cmd == "validatevideoindex")
00289         walker.AddListener(new VideoIndexValidator(reporter, options));
00290     if (cmd == "checknrframes")
00291         walker.AddListener(new CheckNrFrames(reporter, options));
00292     if (cmd == "readblocksfile")
00293         walker.AddListener(new ReadBlocksFile(reporter, options));
00294 #endif
00295     if (cmd == "shotsegmenter")
00296         walker.AddListener(new ShotSegmenter(reporter, options));
00297     if (cmd == "selectframes")
00298         walker.AddListener(new SelectFrames(reporter, options));
00299     if (cmd == "indexsegmentation")
00300         walker.AddListener(new IndexSegmentation(reporter, options));
00301 #ifndef REPOSITORY_TODO
00302     if (cmd == "testblocksfile")
00303         walker.AddListener(new TestBlocksFile(reporter));
00304 #endif
00305     if (cmd == "indexannotation")
00306         walker.AddListener(new IndexAnnotation(reporter, options));
00307 #ifndef REPOSITORY_TODO
00308     if (cmd == "applyconcepts")
00309         walker.AddListener(new ApplyConcepts(reporter, options, videoSet));
00310     if (cmd == "combineconcepts")
00311         walker.AddListener(new CombineConcepts(reporter, options));
00312     if (cmd == "indexconcepts")
00313         walker.AddListener(new IndexConcepts(reporter, options));
00314     if (cmd == "exportconcepts")
00315         walker.AddListener(new ExportConcepts(reporter, options));
00316     if (cmd == "importconcepts")
00317         walker.AddListener(new ImportConcepts(reporter, options));
00318     if (cmd == "importaudioconcepts")
00319         walker.AddListener(new ImportAudioConcepts(reporter, options));
00320 #endif
00321 
00322     if (cmd == "exportframes")
00323         walker.AddListener(new ExportFrames(reporter, options));
00324     if (cmd == "exportkeyframes")
00325         walker.AddListener(new ExportKeyframes(reporter, options, videoSet));
00326     if (cmd == "exportstills")
00327         walker.AddListener(new ExportStills(reporter, options));
00328 
00329     if (cmd == "vistrain")
00330         walker.AddListener(new VisSemTrain(reporter, "vissem", options));
00331     if (cmd == "visgabortrain")
00332         walker.AddListener(new VisSemTrain(reporter, "vissemgabor", options));
00333 
00334     if (cmd == "viseval")
00335     {
00336         Computor* c = new VisSem("vissem", options);
00337         walker.AddListener(new ProtoSimilarityEval(c, reporter, options));
00338     }
00339     if (cmd == "visgaboreval")
00340     {
00341         Computor* c = new VisSem("vissemgabor", options);
00342         walker.AddListener(new ProtoSimilarityEval(c, reporter, options));
00343     }
00344 #ifndef REPOSITORY_TODO
00345     if (cmd == "lbpeval")
00346         walker.AddListener(new LbpEval(reporter, options));
00347 
00348     if (cmd == "visgaborstat")
00349         walker.AddListener(new VisSemGaborStat(reporter, options));
00350 #endif
00351 
00352     if (cmd == "clusterfeatures")
00353     {
00354         if (options.GetNrArg() < 4)
00355             ILOG_ERROR("cluster: missing argument");
00356         String feature = options.GetArg(2);
00357         Computor* c = 0;
00358         if (feature == "weibull")
00359             c = new VisSem("vissem", options);
00360         if (feature == "gabor")
00361             c = new Core::Feature::VisSem("vissemgabor", options);
00362         String clusteror = options.GetArg(3);
00363         walker.AddListener(new ClusterFeatures(c, clusteror, reporter, options));
00364     }
00365 
00366 #ifndef REPOSITORY_TODO
00367     if (cmd == "extractlab")
00368         walker.AddListener(new LabHistExtractor(reporter, options));
00369     if (cmd == "extractlab3d")
00370         walker.AddListener(new LabHist3dExtractor(reporter, options));
00371     if (cmd == "extractrgb")
00372         walker.AddListener(new RgbHistExtractor(reporter, options));
00373 #endif
00374 
00375     if (cmd == "indexfeatures")
00376         walker.AddListener(new IndexFeatures(reporter, options));
00377     if (cmd == "concatfeatures")
00378         walker.AddListener(new ConcatFeatures(reporter, options));
00379     if (cmd == "exportfeatures")
00380         walker.AddListener(new ExportFeatures(reporter, options));
00381 #ifndef REPOSITORY_TODO
00382     if (cmd == "interestpointproc")
00383         walker.AddListener(new InterestPointProc(reporter, options));
00384     if (cmd == "blackframeproc")
00385         walker.AddListener(new BlackFrameProc(reporter, options));
00386     if (cmd == "makequidlookup")
00387         walker.AddListener(new MakeQuidLookup(reporter, options));
00388     if (cmd == "blackframedetect")
00389         walker.AddListener(new BlackFrameDetect(reporter, options));
00390     if (cmd == "extractkfrmotion")
00391         walker.AddListener(new KfrMotionExtractor(reporter, options));
00392 #endif
00393 
00394     if ((walker.NrListeners() == 1) && !((cmd == "nop") || (cmd == "tasktable")))
00395     {
00396         ILOG_ERROR("Unknow command : " << cmd);
00397         Link::Mpi::Finalize();
00398         return 1;
00399     }
00400 
00401     walker.AddListener(new Reporter(reporter));
00402     int rc = 0;
00403     if (FileNameExt(fileName) == "vxs")
00404     {
00405         walker.LoadBookmarks(fileName);
00406         reporter->SetTotalNrFramesInBookmarks(walker.TotalNrFramesInBookmarks());
00407         walker.DoWalkBookmarks();
00408     }
00409     else
00410     {
00411         if (options.GetBool("segmentation"))
00412             walker.LoadSegmentation("segmentation");
00413         String quidFile = options.GetString("quidWalk");
00414         if (!quidFile.empty())
00415         {
00416 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00417             quidFile = videoSet->GetFilePath("", quidFile, false, false);
00418 #endif // REPOSITORY_USED
00419             if (!quidFile.empty())
00420                 walker.LoadQuids(quidFile);
00421         }
00422 
00423         TaskTable* taskTable = MakeVideoTaskTable(videoSet, &walker, cmd,
00424                                                   quidFile);
00425         if ((Link::Mpi::MyId() == 0) && (cmd == "tasktable"))
00426         {
00427             taskTable->Dump();
00428 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00429             taskTable->Save("tasktable.tab", videoSet->GetDatabase(), false);
00430 #else // REPOSITORY_USED
00431             Persistency::TaskTableLocator loc(videoSet->GetLocator(),
00432                                               "tasktable.tab");
00433             Persistency::TaskTableRepository().Add(loc, taskTable);
00434 #endif // REPOSITORY_USED
00435         }
00436         int taskIdx = GetVideoTask();
00437         int startFile = taskTable->GetStartFile(taskIdx);
00438         int numberFiles = taskTable->GetNumberFiles(taskIdx);
00439         int startFrame = taskTable->GetStartFrame(taskIdx);
00440         ILOG_INFO("Process " << Link::Mpi::MyId() << " of " <<
00441                   Link::Mpi::NrProcs() << " is doing file " << startFile
00442                   << " till " << startFile + numberFiles << " from frame "
00443                   << startFrame);
00444         if (!quidFile.empty())
00445         {
00446             // quick hack for process management
00447             int nrTaskWalk = options.GetInt("nrTaskWalk");
00448             int numProcs = Link::Mpi::NrProcs();
00449             for (int walk=0 ; walk<nrTaskWalk ; walk++)
00450             {
00451                 int t = taskIdx + walk*numProcs;
00452                 startFile = taskTable->GetStartFile(t);
00453                 numberFiles = taskTable->GetNumberFiles(t);
00454                 walker.DoWalkQuids(startFile, numberFiles);
00455             }
00456         }
00457         else if (options.GetBool("keyframes"))
00458         {
00459             walker.LoadKeyframes("keyframes");
00460             if (options.GetBool("rkfMask"))
00461                 walker.AddRkfMask();
00462 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00463             if (options.GetString("keyframeMask") != "")
00464                 walker.AddKeyframeMaskFile(options.GetString("keyframeMask"));
00465 #endif // REPOSITORY_USED
00466             if (options.GetString("keyframeMaskAnno") != "")
00467                 walker.AddKeyframeMaskAnnoFile(options.GetString("keyframeMaskAnno"));
00468             walker.DoWalkKeyframes(startFile, numberFiles);
00469         }
00470         else
00471         {
00472             // quick hack for process management
00473             int nrTaskWalk = options.GetInt("nrTaskWalk");
00474             int numProcs = Link::Mpi::NrProcs();
00475             for (int walk=0 ; walk<nrTaskWalk ; walk++)
00476             {
00477                 int t = taskIdx + walk*numProcs;
00478                 startFile = taskTable->GetStartFile(t);
00479                 numberFiles = taskTable->GetNumberFiles(t);
00480                 startFrame = taskTable->GetStartFrame(t);
00481                 rc += walker.DoWalk(startFile, numberFiles, startFrame);
00482             }
00483         }
00484         delete taskTable;
00485     }
00486 
00487     reporter->FinalReport();
00488 
00489     int nrOfErrors = ILOG_ERROR_COUNT;
00490     ILOG_DEBUG("nr of errors collected = " << nrOfErrors);
00491 
00492     nrOfErrors = Link::Mpi::ReduceSum(nrOfErrors);
00493     ILOG_INFO_ONCE("Root: total nr error = " << nrOfErrors);
00494     Link::Mpi::Finalize();
00495 
00496     return nrOfErrors;
00497 }

Here is the call graph for this function:


Generated on Fri Mar 19 10:55:39 2010 for ImpalaSrc by  doxygen 1.5.1