00001 #include "Visualization/SegmentationDocumentGuiAnno.h"
00002 #include "OglGui/Tabs.h"
00003 #include "OglGui/OglLib.cpp"
00004 #include "Core/VideoSet/MakeSegmentationDocument.h"
00005 #include "Visualization/SegmentationDocumentGuiStills.h"
00006
00007
00008 #include "Link/ImpalaLib.cpp"
00009
00010
00011 namespace Impala {
00012 namespace Application {
00013
00014 using namespace Visualization;
00015
00016 class WindowAnnoVidSet : public Window,
00017 public OglGui::ButtonListener,
00018 public OglGui::TabsListener
00019 {
00020 public:
00021
00022 const static int TAB_ANNO = 0;
00023 const static int TAB_STILLS = 1;
00024
00025 WindowAnnoVidSet(int width, int height)
00026 : Window(0, 0, width, height, true)
00027 {
00028 SetControlId(-10);
00029 CmdOptions& options = CmdOptions::GetInstance();
00030 mViewScale = options.GetDouble("viewScale");
00031 ILOG_INFO("loading data");
00032 InitData();
00033 ILOG_INFO("building GUI");
00034 BuildGUI(width, height);
00035 ILOG_INFO("STARTING MAIN LOOP");
00036 AppController::Instance().MainLoop();
00037 }
00038
00039
00040
00041 virtual void
00042 TabSelectionEvent(OglGui::Tabs* src, int tabNr, void* listenerData,
00043 int tabControlData)
00044 {
00045 AppController::Instance().SetCurrentControl(tabControlData);
00046 }
00047
00048 virtual void
00049 DisplayFunc()
00050 {
00051 static bool initialized = false;
00052
00053 if (!initialized)
00054 {
00055 initialized = true;
00056 ScaleChildren(0, true);
00057 SetReposChildren(false, true);
00058 }
00059 Window::DisplayFunc();
00060 }
00061
00062 private:
00063
00064
00065
00066 void
00067 InitData()
00068 {
00069 CmdOptions& options = CmdOptions::GetInstance();
00070 std::string videoSetName = options.GetString("videoSet");
00071 printf("VideoSetName = %s\n", videoSetName.c_str());
00072 mSegDoc = Core::VideoSet::MakeSegmentationDocument(videoSetName);
00073 }
00074
00075 void BuildGUI(int wndWidth, int wndHeight)
00076 {
00077 CmdOptions& options = CmdOptions::GetInstance();
00078
00079 SetBackground(oglGUI_BG);
00080 mTabs = new OglGui::Tabs(this, wndWidth, wndHeight);
00081 mTabs->SetTabsListener(this);
00082 OglGui::Window* tab;
00083 AppController& ctr = AppController::Instance();
00084
00085 typedef Core::VideoSet::SegmentationDocument SegmentationDocument;
00086 tab = mTabs->CreateTab("Anno", -1, TAB_ANNO);
00087 std::string conceptSet = options.GetString("conceptSet");
00088 int maxAnno = options.GetInt("maxAnnoPerVideo");
00089 mSegDocAnno = new SegmentationDocumentGuiAnno
00090 (tab, tab->W(), tab->H(), mSegDoc, conceptSet, maxAnno, TAB_ANNO);
00091 ctr.AddControl((AppControlDoc*) mSegDocAnno);
00092
00093 mSegDocAnno->StringSelectionEvent(NULL,0,(void*)1);
00094
00095 if (mSegDoc->GetImSetStills())
00096 {
00097 Core::ImageSet::ImageSet* imSet = mSegDoc->GetImSetKeyframes(false);
00098 Core::Array::Array2dVec3UInt8* im = imSet->GetImage(0);
00099 int thumbWidth = im->CW() / 2;
00100 int thumbHeight = im->CH() / 2;
00101 delete im;
00102 Window* wnd2 = new Window(wndWidth+6, 0, wndWidth, wndHeight);
00103 wnd2->SetControlId(-11);
00104 wnd2->SetBackground(0xffd2c799);
00105 mSegDocStills = new SegmentationDocumentGuiStills
00106 (wnd2, wndWidth, wndHeight, 4, thumbWidth,
00107 thumbHeight, mViewScale, true, true, mSegDoc, TAB_STILLS);
00108 mSegDocAnno->AddDocListener(mSegDocStills);
00109 oglSys.SetAlwaysDraw(mSegDocStills->GetOGLWND(), 1);
00110 }
00111
00112 mTabs->SetActiveTab(0);
00113 }
00114
00115 double mViewScale;
00116 Core::VideoSet::SegmentationDocument* mSegDoc;
00117
00118 OglGui::Tabs* mTabs;
00119 SegmentationDocumentGuiAnno* mSegDocAnno;
00120 SegmentationDocumentGuiStills* mSegDocStills;
00121
00122 ILOG_VAR_DEC;
00123 };
00124
00125 ILOG_VAR_INIT(WindowAnnoVidSet, Application);
00126
00127
00128 char GetKeyBinding(std::string name, std::string dflt)
00129 {
00130 CmdOptions& options = CmdOptions::GetInstance();
00131 std::string str = options.GetString(name, dflt);
00132 return str[0];
00133 }
00134
00135 int
00136 mainAnnoVidSet(int argc, char* argv[])
00137 {
00138 OglInit(&argc, &argv[0]);
00139
00140 CmdOptions& options = CmdOptions::GetInstance();
00141
00142 options.Initialise(true, false, true);
00143 options.SetDefault("wndWidth", "1272");
00144 options.SetDefault("wndHeight", "955");
00145 if (! options.ParseArgs(argc, argv, "", 0))
00146 return 1;
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 ILOG_VAR(Application.mainAnnoVidSet);
00159
00160 int reqWndWidth = options.GetInt("wndWidth");
00161 int reqWndHeight = options.GetInt("wndHeight");
00162 WindowAnnoVidSet* oglWnd =
00163 new WindowAnnoVidSet(reqWndWidth, reqWndHeight);
00164 if (! oglWnd->Valid())
00165 {
00166 ILOG_ERROR("WindowAnnoVidSet failed");
00167 return 1;
00168 }
00169 return 0;
00170 }
00171
00172 }
00173 }
00174
00175 int
00176 main(int argc, char* argv[])
00177 {
00178 return Impala::Application::mainAnnoVidSet(argc, argv);
00179 }