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