00001
00002
00003 #include "OglGui/OglLib.cpp"
00004
00005 #include "Persistency/SimilarityTableSetRepository.h"
00006 #include "Persistency/FeatureTableSetRepository.h"
00007 #include "OglGui/Tabs.h"
00008 #include "OglGui/SplashScreen.h"
00009 #include "Visualization/OptionsLook.h"
00010 #include "Visualization/SegmentationDocumentGuiAnno.h"
00011 #include "Visualization/AnnoPUNS.h"
00012 #include "Visualization/AnnotationTableGui.h"
00013 #include "Visualization/FeatureTableSetRank.h"
00014 #include "Visualization/SimilarityTableSetRank.h"
00015
00016 #include "Visualization/AllFramesTLineVideo.h"
00017 #include "Visualization/SegmentationDocumentGuiStills.h"
00018 #include "Visualization/SegmentationDocumentGuiMain.h"
00019 #include "Visualization/SegmentationDocumentGuiKeyframes.h"
00020
00021 #include "Core/VideoSet/MakeSegmentationDocument.h"
00022
00023 #include "Link/ImpalaLib.cpp"
00024
00025 namespace Impala {
00026 namespace Application {
00027
00028 using namespace Visualization;
00029
00030 class WindowShowVidSet : public Window, public OglGui::ButtonListener,
00031 public OglGui::TabsListener
00032 {
00033 public:
00034
00035 const static int TAB_SET = 0;
00036 const static int TAB_MAIN = 1;
00037 const static int TAB_KEYFRAMES = 2;
00038 const static int TAB_ANNOTATIONS = 3;
00039 const static int TAB_CONCEPTS = 4;
00040 const static int TAB_SIMPLOTNEEDLEIMAGE = 5;
00041 const static int TAB_ALLFRAMESTLINEVIDEO = 6;
00042 const static int TAB_CONCEPTSSIM = 7;
00043 const static int TAB_CONCEPTSTRUTH = 8;
00044 const static int TAB_FEATURES = 9;
00045 const static int TAB_FEATURESPLOT = 10;
00046 const static int TAB_STILLS = 11;
00047 const static int TAB_ANNOCONTROL = 12;
00048 const static int TAB_ANNOPUNS = 13;
00049
00050 WindowShowVidSet(int width, int height) : Window(0, 0, width, height, true)
00051 {
00052 CmdOptions& options = CmdOptions::GetInstance();
00053 mViewScale = options.GetDouble("viewScale");
00054
00055
00056
00057 std::string title = options.GetString("title");
00058 mOglWnd->topTitle = new char [1024];
00059 strcpy(mOglWnd->topTitle,title.c_str());
00060
00061
00062
00063 ILOG_INFO("loading data");
00064 InitData();
00065 ILOG_INFO("building GUI");
00066 View::SetTags(selectableTag | showBgTag | showBorderTag |
00067 showBorderTag |showTitleTag);
00068
00069 BuildGUI(width, height);
00070 this->GuiGeneralName("WindowShowVidSet");
00071 OptionsLooks(this);
00072
00073
00074 }
00075
00076
00077
00078 virtual void
00079 TabSelectionEvent(OglGui::Tabs* src, int tabNr, void* listenerData,
00080 int tabControlData)
00081 {
00082 AppController::Instance().SetCurrentControl(tabControlData);
00083 }
00084
00085 virtual void
00086 DisplayFunc()
00087 {
00088 static bool initialized = false;
00089
00090 if (!initialized)
00091 {
00092 initialized = true;
00093 ScaleChildren(0, true);
00094 SetReposChildren(false, true);
00095 }
00096 Window::DisplayFunc();
00097 }
00098
00099 private:
00100
00101
00102
00103 void
00104 InitData()
00105 {
00106 CmdOptions& options = CmdOptions::GetInstance();
00107 mShowAnno = options.GetBool("showAnno");
00108 mShowTimeLineVideo = options.GetBool("timeLineVideo");
00109 mShowAnnoControl = options.GetBool("annotateControl");
00110 String videoSetName = options.GetString("videoSet");
00111 mSegDoc = Core::VideoSet::MakeSegmentationDocument(videoSetName);
00112 Core::ImageSet::ImageSet* imSetThumb = mSegDoc->GetImSetKeyframes(true);
00113 imSetThumb->SetImageSrc(options.GetBool("imArchive"),
00114 options.GetBool("imFileArchive"),
00115 options.GetBool("imSplitArchive"));
00116 if (imSetThumb)
00117 {
00118 Core::Array::Array2dVec3UInt8* im = imSetThumb->GetImage(0);
00119 mThumbWidth = im->CW();
00120 mThumbHeight = im->CH();
00121 delete im;
00122 }
00123 String conceptSetName = options.GetString("conceptSet");
00124 mConceptRanking = 0;
00125 if (!conceptSetName.empty())
00126 {
00127 String model = options.GetString("conceptModel");
00128 String feature = options.GetString("conceptFeature");
00129 ILOG_INFO("reading concept similarity set");
00130 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00131 mConceptRanking = Core::Table::SimilarityTableSet::MakeFromFile
00132 (mSegDoc->GetVideoSet(), conceptSetName, model, feature);
00133 #else // REPOSITORY_USED
00134 typedef Persistency::SimilarityTableSetLocator SimLoc;
00135 SimLoc loc(mSegDoc->GetVideoSet()->GetLocator(), true, "Keyframes",
00136 conceptSetName, model, feature, "");
00137 mConceptRanking = Persistency::SimilarityTableSetRepository().Get(loc);
00138 #endif // REPOSITORY_USED
00139 }
00140 String featureSetName = options.GetString("featureSet");
00141 mFeatureSet = 0;
00142 if (!featureSetName.empty())
00143 {
00144 ILOG_INFO("reading feature set");
00145 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00146 mFeatureSet =
00147 Core::Feature::FeatureTableSet::MakeFromFile("FeatureIndex",
00148 true,
00149 featureSetName,
00150 mSegDoc->GetVideoSet());
00151 #else // REPOSITORY_USED
00152 typedef Persistency::FeatureLocator FeatLoc;
00153 FeatLoc loc(mSegDoc->GetVideoSet()->GetLocator(), false, true,
00154 "", featureSetName, "");
00155 mFeatureSet = Persistency::FeatureTableSetRepository().Get(loc);
00156 #endif // REPOSITORY_USED
00157 }
00158 }
00159
00160 void
00161 BuildGUI(int wndWidth, int wndHeight)
00162 {
00163 CmdOptions& options = CmdOptions::GetInstance();
00164
00165 SetBorderType(-1);
00166 if (!GetBorderBackground())
00167 SetBorderBackground(oglGUI_BG);
00168
00169 mTabs = new OglGui::Tabs(this, wndWidth, wndHeight);
00170 mTabs->SetTabsListener(this);
00171
00172 int tabAnim = options.GetInt("mainTabAnimation", 0);
00173 int tabDiv = options.GetInt("mainTabAnimationDivider", 4);
00174 int transit1 = options.GetInt("mainTabTransit1", 0);
00175 int transit2 = options.GetInt("mainTabTransit2", 0);
00176 int transitGridX = options.GetInt("mainTabTransitNx", 3);
00177 int transitGridY = options.GetInt("mainTabTransitNy", 3);
00178 bool tabDissolve = options.GetBool("mainTabDissolve",false);
00179 mTabs->TabsAnimated(tabAnim);
00180 mTabs->TabsAnimDivider(tabDiv);
00181 mTabs->TabsDissolve(tabDissolve);
00182 if (transit1 || transit2)
00183 mTabs->TabsTransition(transit1,transit2);
00184 mTabs->TabsTransitionGridXY(transitGridX,transitGridY);
00185
00186 OglGui::Window* tab = mTabs->CreateTab("Data set", 80, TAB_SET);
00187
00188 int nrImOnRow = wndWidth / (mThumbWidth + 3);
00189
00190 typedef Core::VideoSet::SegmentationDocument SegmentationDocument;
00191 DataDocumentGui<SegmentationDocument>* dataGui =
00192 new DataDocumentGui<SegmentationDocument>(tab, wndWidth, wndHeight,
00193 mSegDoc, TAB_SET, true,
00194 true, false, 1, 12,
00195 mShowAnno, mShowAnno);
00196 AppController& ctr = AppController::Instance();
00197 ctr.AddControl((AppControlDoc*) dataGui);
00198
00199
00200 dataGui->StringSelectionEvent(NULL,0,(void*)1);
00201
00202 tab = mTabs->CreateTab("Main", 56, TAB_MAIN);
00203 mSegDocMain = new SegmentationDocumentGuiMain
00204 (tab, wndWidth, wndHeight, nrImOnRow, mThumbWidth, mThumbHeight,
00205 mViewScale, mShowAnno, mSegDoc, 0, false, TAB_MAIN);
00206 ctr.AddControl((AppControlDoc*) mSegDocMain);
00207
00208 if (mSegDoc->GetImSetKeyframes(true))
00209 {
00210 tab = mTabs->CreateTab("Keyframes", 94, TAB_KEYFRAMES);
00211 mSegDocKeyframes = new SegmentationDocumentGuiKeyframes
00212 (tab, 0,0,tab->W(), tab->H(), nrImOnRow, mThumbWidth,
00213 mThumbHeight, mViewScale, mSegDoc, TAB_KEYFRAMES);
00214 ctr.AddControl((AppControlDoc*) mSegDocKeyframes);
00215 }
00216
00217 String conceptAnnotations = options.GetString("conceptAnnotations");
00218 if (!conceptAnnotations.empty())
00219 {
00220 tab = mTabs->CreateTab("Annotations", 100, TAB_ANNOTATIONS);
00221 mAnnotation = new AnnotationTableGui
00222 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00223 mViewScale, mSegDoc, conceptAnnotations, TAB_ANNOTATIONS);
00224 ctr.AddControl((AppControlDoc*) mAnnotation);
00225 }
00226
00227 if (mConceptRanking)
00228 {
00229 tab = mTabs->CreateTab("Concepts", 82, TAB_CONCEPTS);
00230 mSimSetRank = new SimilarityTableSetRank
00231 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00232 mViewScale, mSegDoc, mConceptRanking, false,
00233 conceptAnnotations, false, TAB_CONCEPTS);
00234 ctr.AddControl((AppControlDoc*) mSimSetRank);
00235
00236 tab = mTabs->CreateTab("ConceptsSim", -1, TAB_CONCEPTSSIM);
00237 mSimSetRankSim = new SimilarityTableSetRank
00238 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth, mThumbHeight,
00239 mViewScale, mSegDoc, mConceptRanking, true,
00240 conceptAnnotations, false, TAB_CONCEPTSSIM);
00241 ctr.AddControl((AppControlDoc*) mSimSetRankSim);
00242
00243 if (!conceptAnnotations.empty())
00244 {
00245 tab = mTabs->CreateTab("ConceptsTruth", 120, TAB_CONCEPTSTRUTH);
00246 mSimSetRankTruth = new SimilarityTableSetRank
00247 (tab, tab->W(), tab->H(), nrImOnRow, mThumbWidth,
00248 mThumbHeight, mViewScale, mSegDoc, mConceptRanking, false,
00249 conceptAnnotations, true, TAB_CONCEPTSTRUTH);
00250 ctr.AddControl((AppControlDoc*) mSimSetRankTruth);
00251 }
00252 }
00253
00254 if (mShowTimeLineVideo)
00255 {
00256 tab = mTabs->CreateTab("TLineVideo", 100, TAB_ALLFRAMESTLINEVIDEO);
00257 mAllFramesTLineVideo = new AllFramesTLineVideo
00258 (tab, tab->W(), tab->H(), mSegDoc, TAB_ALLFRAMESTLINEVIDEO);
00259 ctr.AddControl((AppControlDoc*) mAllFramesTLineVideo);
00260 }
00261
00262 if (mShowAnnoControl)
00263 {
00264 std::string conceptSet = options.GetString("conceptSet");
00265 int maxAnno = options.GetInt("maxAnnoPerVideo");
00266 tab = mTabs->CreateTab("AnnoControl",100,TAB_ANNOCONTROL);
00267 mSegDocGuiAnno = new SegmentationDocumentGuiAnno(tab,tab->W(),tab->H(),mSegDoc,
00268 conceptSet,maxAnno,
00269 TAB_ANNOCONTROL);
00270
00271 ctr.AddControl((AppControlDoc*) mSegDocGuiAnno);
00272
00273 AnnoPUNS::VideoAnnotations* vidAnnos
00274 = mSegDocGuiAnno->GetVideoAnnotations();
00275 tab = mTabs->CreateTab("AnnoPUNS",100,TAB_ANNOPUNS);
00276 mAnnoPUNS = new AnnoPUNS(tab,tab->W(),tab->H(),mThumbWidth,
00277 mThumbHeight,mSegDoc,vidAnnos,
00278 TAB_ANNOPUNS);
00279 ctr.AddControl((AppControlDoc*) mAnnoPUNS);
00280 }
00281
00282 if (mFeatureSet)
00283 {
00284 tab = mTabs->CreateTab("Features", 80, TAB_FEATURES);
00285 mFeatSetRank = new FeatureTableSetRank
00286 (tab, wndWidth, wndHeight, nrImOnRow, mThumbWidth, mThumbHeight,
00287 mViewScale, mSegDoc, mFeatureSet, false, TAB_FEATURES);
00288 ctr.AddControl((AppControlDoc*) mFeatSetRank);
00289
00290 tab = mTabs->CreateTab("FeaturesPlot", -1, TAB_FEATURESPLOT);
00291 mFeatSetRankPlot = new FeatureTableSetRank
00292 (tab, wndWidth, wndHeight, nrImOnRow, mThumbWidth, mThumbHeight,
00293 mViewScale, mSegDoc, mFeatureSet, true, TAB_FEATURESPLOT);
00294 ctr.AddControl((AppControlDoc*) mFeatSetRankPlot);
00295 }
00296
00297 if (mSegDoc->GetImSetStills())
00298 {
00299 tab = mTabs->CreateTab("Stills", 60, TAB_STILLS);
00300 bool imageStills = options.GetBool("imageStills");
00301 mSegDocStills = new SegmentationDocumentGuiStills
00302 (tab, wndWidth, wndHeight, nrImOnRow, mThumbWidth, mThumbHeight,
00303 mViewScale, true, imageStills, mSegDoc, TAB_STILLS);
00304 ctr.AddControl((AppControlDoc*) mSegDocStills);
00305 }
00306 mTabs->SetActiveTab(0);
00307 }
00308
00309 char GetKeyBinding(std::string name, std::string dflt)
00310 {
00311 CmdOptions& options = CmdOptions::GetInstance();
00312 std::string str = options.GetString(name, dflt);
00313 return str[0];
00314 }
00315
00316
00317
00318 bool mShowAnno;
00319 bool mShowTimeLineVideo;
00320 bool mShowAnnoControl;
00321 int mThumbWidth;
00322 int mThumbHeight;
00323 ULONG mBackGround;
00324
00325
00326 double mViewScale;
00327 Core::VideoSet::SegmentationDocument* mSegDoc;
00328 Core::Table::SimilarityTableSet* mConceptRanking;
00329 Core::Feature::FeatureTableSet* mFeatureSet;
00330
00331
00332 OglGui::Tabs* mTabs;
00333 SegmentationDocumentGuiAnno* mSegDocGuiAnno;
00334 AnnoPUNS* mAnnoPUNS;
00335 SegmentationDocumentGuiMain* mSegDocMain;
00336 SegmentationDocumentGuiKeyframes* mSegDocKeyframes;
00337 AnnotationTableGui* mAnnotation;
00338 SimilarityTableSetRank* mSimSetRank;
00339 SimilarityTableSetRank* mSimSetRankSim;
00340 SimilarityTableSetRank* mSimSetRankTruth;
00341
00342 AllFramesTLineVideo* mAllFramesTLineVideo;
00343 FeatureTableSetRank* mFeatSetRank;
00344 FeatureTableSetRank* mFeatSetRankPlot;
00345 SegmentationDocumentGuiStills* mSegDocStills;
00346
00347 ILOG_VAR_DEC;
00348 };
00349
00350 ILOG_VAR_INIT(WindowShowVidSet, Application);
00351
00352
00353 int
00354 mainShowVidSet(int argc, char* argv[])
00355 {
00356 OglInit(&argc, &argv[0]);
00357 CmdOptions& options = CmdOptions::GetInstance();
00358
00359 options.Initialise(true, false, true);
00360 options.SetDefault("wndWidth", "1272");
00361 options.SetDefault("wndHeight", "955");
00362 options.AddOption(0, "small", "", "0");
00363 options.AddOption(0, "noArchive", "", "0");
00364 options.AddOption(0, "imFileArchive", "", "0");
00365 options.AddOption(0, "conceptSetSubDir", "featurename", "");
00366 if (! options.ParseArgs(argc, argv, "", 0))
00367 return 1;
00368
00369 ILOG_VAR(Application.mainShowVidSet);
00370
00371 int reqWndWidth = options.GetInt("wndWidth");
00372 int reqWndHeight = options.GetInt("wndHeight");
00373 if (options.GetBool("small"))
00374 {
00375 reqWndWidth = 1020;
00376 reqWndHeight = 740;
00377 }
00378
00379 #if !defined(OGL_USING_GLUT) && !defined(OGL_USING_QT)
00380 OglGui::SplashScreen* splash;
00381 if (options.GetBool("splashScreen"))
00382 {
00383 splash = new OglGui::SplashScreen(0,0,reqWndWidth,reqWndHeight);
00384 OGLStartThread(splash->GetOGLWND());
00385 }
00386 #endif
00387
00388 WindowShowVidSet* oglWnd = new WindowShowVidSet(reqWndWidth, reqWndHeight);
00389
00390 #if !defined(OGL_USING_GLUT) && !defined(OGL_USING_QT)
00391 if (options.GetBool("splashScreen"))
00392 splash->Stop();
00393 #endif
00394
00395 if (! oglWnd->Valid())
00396 {
00397 ILOG_ERROR("WindowShowVidSet failed");
00398 return 1;
00399 }
00400
00401 ILOG_INFO("STARTING MAIN LOOP");
00402 AppController::Instance().MainLoop();
00403
00404 return 0;
00405 }
00406
00407 }
00408 }
00409
00410 #ifndef NO_MAIN
00411 int main(int argc, char* argv[])
00412 {
00413 return Impala::Application::mainShowVidSet(argc, argv);
00414 }
00415 #endif