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

SurveillanceApp.cpp

Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Application: Surveillance Dashboard (MultimediaN project 6)
00004  *
00005  * Primary author(s): Richard van Balen
00006  *                  : Sander Kruseman
00007  *                  
00008  ******************************************************************************/
00009 /*
00010 12345678901234567890123456789012345678901234567890123456789012345678901234567890
00011 */
00012 
00013 // If the monitors try to read the next frame all at the
00014 // same time, the display could become jerky. The next define
00015 // allows to test if this is the case.
00016 // Put into comment when not testing
00017 //#define PRINT_JPG_READ
00018 
00019 // Experimental: Probably to be removed
00020 // Allows to switch between 3 monitors and 12 monitors
00021 // Put into comment to prevent the Show all monitor option
00022 #define ALL_MONITORS
00023 
00024 #include <string>
00025 #include <map>
00026 #include <vector>
00027 
00028 #include "OglGui/Button.h"
00029 #include "OglGui/Tabs.h"
00030 #include "OglGui/GroupBox.h"
00031 #include "OglGui/CheckBox.h"
00032 #include "OglGui/RadioGroup.h"
00033 #include "OglGui/FramesPerSecond.h"
00034 #include "OglGui/WindowView2D.h"
00035 #include "OglGui/ViewStrip.h"
00036 #include "OglGui/AlertTimeLine.h"
00037 
00038 #include "Visualization/Video.h"
00039 #include "Visualization/VideoJpgPlayer.h"
00040 #include "Visualization/VideoJpgPlayerControl.h"
00041 //#include "Visualization/RgbOglImage.h"
00042 
00043 #include "Basis/CmdOptions.h"
00044 
00045 #include "Application/sdash/SurveillanceMap.h"
00046 #include "Application/sdash/CameraEventListPane.h"
00047 #include "Application/sdash/VideoJpgCamera.h"
00048 #include "Application/sdash/VideoPlayerListener.h"
00049 #include "Application/sdash/VideoPlayerView.h"
00050 #include "Application/sdash/RegionsOfInterestInfo.h"
00051 #include "Application/sdash/RegionsOfInterestCorrelation.h"
00052 #include "Application/sdash/AlertWindow.h"
00053 #include "Application/sdash/RoiLoader.h"
00054 #include "Application/sdash/IdentificationPane.h"
00055 #include "Application/sdash/RoiInfo.h"
00056 #include "Application/sdash/GuiEventListener.h"
00057 #include "Application/sdash/MonitorSelector.h"
00058 #include "Application/sdash/PoliceMan.h"
00059 #include "Application/sdash/ActivityReader.h"
00060 #include "Application/sdash/TimeSlider.h"
00061 #include "Application/sdash/ApplicationEnding.h"
00062 #include "Application/sdash/CameraMovementReader.h"
00063 
00064 #include "Application/sdash/LogoAnimation.h"
00065 
00066 
00067 #include "OglGui/OglLib.cpp"
00068 #include "Link/ImpalaLib.cpp"
00069 
00070 namespace Impala {
00071 namespace Application {
00072 namespace SDash {
00073 
00074 static const int NR_OF_CAMERAS_STREET = 12;
00075 static const int NR_OF_CAMERAS_STATION = 3;
00076 static const int NR_OF_CAMERAS = NR_OF_CAMERAS_STREET + NR_OF_CAMERAS_STATION;
00077 
00078 // video ID's follow from position in this list:
00079 // (ID's must be compatible with Thang's metadata)
00080 static const char *VIDEO_NAMES_STREET[] = {
00081             "cam8.01",
00082             "cam8.02",
00083             "cam8.03",
00084             "cam8.04",
00085             "cam8.05",
00086             "cam8.06",
00087             "cam8.07",
00088             "cam9.01",
00089             "cam9.02",
00090             "cam9.03",
00091             "cam9.08",
00092             "cam9.09"
00093 };
00094 
00095 static const int NR_OF_POLICEMEN = 6;
00096 
00097 static const char *POLICE_TEXTS[] = {
00098             "3063: Jan Staal\nwijkagent; auto",
00099             "0233: Ruud de Jong\nstadswacht; te voet",
00100             "8956: Brenda Sikkens\nnoodhulp; te voet",
00101             "3508: Ibrahim Veder\nwijkagent; auto",
00102             "7354: Dennis Zwiers\nwijkagent; fiets",
00103             "2977: Liesbeth Verwijs\nwijkagent; fiets"
00104 };
00105 
00106 static const char *MAILTO_TEXTS[] = {
00107             "Jan Staal, wijkagent, auto",
00108             "Ruud de Jong, stadswacht, te voet",
00109             "Brenda Sikkens, noodhulp, te voet",
00110             "Ibrahim Veder, wijkagent, auto",
00111             "Dennis Zwiers, wijkagent, fiets",
00112             "Liesbeth Verwijs, wijkagent, fiets"
00113 };
00114 
00115 static const int POLICE_POSITIONS[] = {
00116      484,342,1,
00117      724,746,1,
00118      146,528,0,
00119      438,673,0,
00120      936,482,0,
00121      954,482,0
00122 };
00123 
00124 
00126 //static const float TIMES_PER_FRAME[] = {
00127 //    0.3875f,
00128 //    0.559f,
00129 //    0.3705f,
00130 //    0.3732f,
00131 //    0.378f,
00132 //    0.384f,
00133 //    0.3932f,
00134 //    0.4525f,
00135 //    0.4525f,
00136 //    0.4525f,
00137 //    0.453f,
00138 //    0.453f,
00139 //    1.0f / ActivityReader::FRAME_RATE,
00140 //    1.0f / ActivityReader::FRAME_RATE,
00141 //    1.0f / ActivityReader::FRAME_RATE
00142 //};
00143 
00144 // Optimized for 60 minutes video, 30 minutes virtual offset
00145 static const float TIMES_PER_FRAME[] = {
00146     0.3892f,
00147     0.559f,
00148     0.372f,
00149     0.374f,
00150     0.379f,
00151     0.385f,
00152     0.3932f,
00153     0.452f,
00154     0.452f,
00155     0.452f,
00156     0.4528f,
00157     0.4524f,
00158     1.0f / ActivityReader::FRAME_RATE,
00159     1.0f / ActivityReader::FRAME_RATE,
00160     1.0f / ActivityReader::FRAME_RATE
00161 };
00162 
00163 // frame times first 12 video's as 3600 / <nr of frames>:
00164     //0.3894f,
00165     //0.55814f,
00166     //0.37098f,
00167     //0.37352f,
00168     //0.37863f,
00169     //0.38457f,
00170     //0.39233f,
00171     //0.45317f,
00172     //0.45312f,
00173     //0.45260f,
00174     //0.45306f,
00175     //0.45266f,
00176 
00177 static const int MAX_FRAMES[] = {
00178 #ifdef RICHARD
00179     4623,
00180     3221,
00181     4842,
00182     4811,
00183     4748,
00184     4674,
00185     4575,
00186     3983,
00187     3983,
00188     3983,
00189     3976,
00190     3979
00191 #else
00192     9245,
00193     6450,
00194     9704,
00195     9638,
00196     9508,
00197     9361,
00198     9176,
00199     7944,
00200     7945,
00201     7954,
00202     7946,
00203     7953
00204 #endif
00205 }; // NOTE perron cameras niet in deze lijst.
00206 
00207 
00208 static const std::string    ROI_INFO_FILE  = "boxes-b.bin";
00209 static const std::string    ROI_CORR_FILE  = "boxes.corr";
00210 
00211 //static const int VIRTUAL_TIME_OFFSET  = 27 * 60;
00212 //static const int VIRTUAL_TIME_OFFSET  = 20 * 60;
00213 #ifdef RICHARD
00214 static const int VIRTUAL_TIME_OFFSET  = 15 * 60;
00215 #else
00216 static const int VIRTUAL_TIME_OFFSET  = 30 * 60;
00217 #endif
00218 //static const int VIRTUAL_TIME_OFFSET    = 10 * 60;
00219 //static const int VIRTUAL_TIME_OFFSET  = 5 * 60;
00220 
00221 #ifdef RICHARD
00222 static const int VIDEO_DURATION         = 30 * 60;
00223 #else
00224 static const int VIDEO_DURATION         = 60 * 60;
00225 #endif
00226 static const int RESTART_TIME           = VIDEO_DURATION - 20;
00227 //static const int RESTART_TIME           = VIRTUAL_TIME_OFFSET + 20;
00228 
00229 static std::string gIpAddress = "";
00230 
00231 static std::string gDataRoot = "";
00232 static std::string gVideoPathThang = "";
00233 static std::string gRoiPath = "";
00234 static std::string gVideoPathMichael = "";
00235 static std::string gXmlPathMichael = "";
00236 static std::string gCamMovementInfoPath = "";
00237 
00238 using namespace OglGui;
00239 
00241 //
00242 // Main application class
00243 //
00244 class SurveillanceApp : public Window,
00245                         public SurveillanceMapListener,
00246                         public MonitorSelectorListener,
00247                         public ButtonListener,
00248                         public PoliceManListener,
00249                         public GuiEventListener,
00250                         public WindowListener,
00251                         public TimeSliderListener
00252 {
00253 
00254     typedef Visualization::VideoJpgPlayer            VideoJpgPlayer;
00255     typedef Visualization::VideoJpgPlayerControl     VideoJpgPlayerControl;
00256     typedef Visualization::VideoJpgPlayerListener    VideoJpgPlayerListener;
00257     typedef Core::Array::Array2dVec3UInt8            Array2dVec3UInt8;
00258 
00259 public:
00260 
00261     SurveillanceApp(int width, int height) : Window(0, 0, width, height)
00262         {
00263         SetupVideoData(mVideos);
00264 
00265         const int nrOfVideosToCollectRoisFor = NR_OF_CAMERAS_STREET;
00266         const std::string roiFileName = gRoiPath + ROI_INFO_FILE;
00267         //const int maxMinutes = 32;// 32 minutes of roi's for 30 minutes of video
00268 
00269         mDetectedPersons =
00270             new RegionsOfInterestInfo(roiFileName,NR_OF_CAMERAS_STREET,MAX_FRAMES,true);
00271 
00272         mSimilarPersons =
00273             new RegionsOfInterestCorrelation(gRoiPath + ROI_CORR_FILE, *mDetectedPersons);
00274 
00275         ScheduleCamEvents(mCamEventSchedule);
00276 
00277         GetOGLWND()->topTitle =
00278             "MultimediaN - Surveillance Dashboard";
00279 
00280         mInspectVideoId = 0;
00281         //mMaxVideoFrame = 4500;
00282 
00283         SetBackground(oglGUI_BG);
00284         BuildSecondScreenGUI();
00285         BuildGUI(width, height);
00286 
00287         mMonitorSelector = new MonitorSelector(mSurveillanceMap,120,40,3);
00288         mMonitorSelector->SetVisible(false);
00289 
00290         mSurveillanceMap->SetSurveillanceMapListener(this);
00291         mSurveillanceMap->SetWindowListener(this);
00292 
00293         for (int i = 0; i < NR_OF_POLICEMEN; i++)
00294         {
00295             PoliceMan* policeMan =
00296                 new PoliceMan(mSurveillanceMap, POLICE_POSITIONS[i*3],
00297                               POLICE_POSITIONS[i*3+1],20,40,
00298                               POLICE_TEXTS[i], POLICE_POSITIONS[i*3+2] ? oglGREEN : 0xffff8080);
00299                               //POLICE_TEXTS[i], POLICE_POSITIONS[i*3+2] ? oglGREEN : oglGREY);
00300             policeMan->ScaleTo(mSurveillanceMap,NoHeight|NoWidth);
00301             policeMan->SetPoliceManListener(this,(void*)i);
00302         }
00303 
00305         // Just for fun: MultiMedian logos in lower right corner
00306         // When pressed shows the multimedian screensaver animation
00307         // drawn transparently over the entire interface
00308         // When running clicking the mouse anywhere hides the animation
00309         // Clicking the logos toggles the animation visibility
00310         new LogoAnimation(this, width, height);
00311 
00312         mCamEventSchedulePosition = mCamEventSchedule.begin();
00313 
00314         mApplicationEnding =
00315             new ApplicationEnding(this, "End of demo. Surveillance Dashboard restarting in:");
00316 
00317         if (Valid())
00318             Start(); // start OGL
00319     }
00320 
00321     ~SurveillanceApp()
00322         {
00323         printf("SurveillanceApp destructor\n");
00324         CleanUp();
00325     }
00326 
00327     void CleanUp()
00328     {
00329         printf("Cleaning Up\n");
00330         delete mDetectedPersons;
00331         delete mSimilarPersons;
00332     }
00333 
00334     void ShowEvent(const CameraEvent& camEvent)
00335     {
00336         //mTimeLine->AddAlert(camEvent.CameraId(), camEvent.PreferredBackColor(), (int) &camEvent);
00337         mTimeLine->AddAlert(camEvent.CameraId(), camEvent.PreferredBackColor(), (void*) &camEvent, camEvent.Seconds());
00338         mCameraEventListPane->EventList()->AddCameraEvent(&camEvent);
00339     }
00340 
00341     void HandleSubmitButtonState()
00342     {
00343         bool hasPositives = mIdPane->Positives()->GetOGLWND()->objectList!=0;
00344         if (!hasPositives)
00345             mSubmitButton->SetState(0);
00346         else if ((mSubmitButton->GetState() && mAlertWindow->GetVisible()) ||
00347             (!mAlertWindow->GetVisible() && !mSubmitButton->GetState()))
00348         {
00349             mSubmitButton->SetState(!mAlertWindow->GetVisible());
00350         }
00351     }
00352 
00353     virtual void DisplayFunc()
00354     {
00355         static bool initialized = false;
00356 
00357         // Here events should be generated based on the current time 
00358         long startTime = mTimeLine->GetStartTime();
00359         long currentTime = mTimeLine->GetCurrentTime();
00360         int runTime = (currentTime - startTime);
00361 
00362         mVideoPlayer->SetShowMaxFrame(runTime/TIMES_PER_FRAME[mInspectVideoId]);
00363         mVideoTimeSlider->TimeSpan(runTime);
00364         //mVideoTimeSlider->TimeSpan(30*60);
00365         long timePast = mVideoPlayer->GetTimePast();
00366         mVideoTimeSlider->CurrentTime(startTime+timePast);
00367 
00368         // SK: no longer random events
00370         //if (!initialized)
00371         //{
00372         //    if (runTime >= 1)
00373         //        initialized = true;
00374         //}
00375         //else if (ABSRND(2000)>1997)
00377         //{
00378         //    int id = 1 + ABSRND(NR_OF_CAMERAS);
00379         //    int type = 1 + ABSRND(4);
00380         //    CameraEvent* cameraEvent =
00381         //        new CameraEvent(id,type,currentTime,"random");
00382         //    ShowEvent(*cameraEvent);
00383         //}
00384 
00385         // show scheduled events; note that the map is ordered by scheduled time (secs)
00386         while (mCamEventSchedulePosition != mCamEventSchedule.end())
00387         {
00388             const int nextEventTime = mCamEventSchedulePosition->first;
00389             if (nextEventTime > runTime)
00390                 break;
00391             std::vector<CameraEvent>& scheduledEvents = mCamEventSchedulePosition->second;
00392             const int nrOfEvents = scheduledEvents.size();
00393             for (int i = 0; i < nrOfEvents; i++)
00394             {
00395                 CameraEvent& camEvent = scheduledEvents[i];
00396                 const long virtualSecs = startTime + nextEventTime;
00397                 camEvent.SetSeconds(virtualSecs);
00398                 ShowEvent(camEvent);
00399             }
00400             mCamEventSchedulePosition++;
00401         }
00402 
00403         HandleSubmitButtonState();
00404         Window::DisplayFunc();
00405 
00406 static int cnt = 0;
00407 #ifdef PRINT_JPG_READ
00408 printf("FR:%d\n", cnt++);
00409 #endif
00410 
00411         if (!mExitButton->GetVisible() && runTime >= RESTART_TIME)
00412             mApplicationEnding->StartApplicationEnding();
00413     }
00414 
00415     void BuildGUI(int w, int h)
00416         {
00417         int monitorPaneY = h-332;
00418         //BuildTimeLinePane(this,8,monitorPaneY-160,w-16,152);
00419         BuildTimeLinePane(this,412,monitorPaneY-232,w-414,228);
00420         mCameraEventListPane = new CameraEventListPane(this,2,monitorPaneY-232,406,228);
00421         SetAsBox(mCameraEventListPane);
00422         mCameraEventListPane->ScaleTo(this);
00423         BuildMonitorPane(this,2,monitorPaneY,w-4,330);
00424         BuildInspectionPane(this,2,2,w-4,monitorPaneY-240);
00425 #ifdef ALL_MONITORS
00426 mAllCamerasPane = BuildMonitorAll(this,8,monitorPaneY,w-16,330+24);
00427 mAllCamerasPane->SetToFrontOnMouseDown(false);
00428 mAllCamerasPane->SetVisible(false);
00429 #endif
00430 
00431         mTimeLine->SetTime(14*3600 + 14*60 + 40, VIRTUAL_TIME_OFFSET);
00432         for(int i=0;i<3;i++)
00433             mVideoCameras[i]->Play(VIRTUAL_TIME_OFFSET);
00434     }
00435 
00437 // Utilities
00438     void SetAsBox(Window *w)
00439     {
00440         w->SetRoundness(0,0,0,0);
00441         w->SetBorderType(BEV_ETCHED);
00442         w->SetBorderFillShaded(DEEP_SHADE_UP);
00443     }
00444 
00446 // Implementation of monitor pane
00447     void BuildMonitorPane(Window* wnd, int x, int y, int w, int h)
00448     {
00449         Window* pane = new Window(wnd, x, y, w, h);
00450 
00451         for (int i=0; i<3; i++)
00452         {
00453             int vX = i*w/3, vY = 0;
00454             int vW = w/3, vH = h;
00455             int videoId = i;// + NR_OF_CAMERAS_STREET;
00456             int camId = videoId + 1;
00457 
00458             mVideoCameras[i] = new VideoJpgCamera(pane,vX,vY,vW,vH, mVideos[videoId]);
00459             mVideoCameras[i]->Play(VIRTUAL_TIME_OFFSET);
00460             mVideoCameras[i]->SetWindowListener(this);
00461             mVideoCamerasVideoId[i] = videoId;
00462 
00463             mCameraTexts[i] = new StaticText(mVideoCameras[i],58,vH-38,180,20,
00464                                              MonitorString(camId-1),false,true);
00465             mCameraTexts[i]->SetForeground(0xffffff00); // Yellow
00466             mCameraTexts[i]->SetShadowColor(oglBLACK);
00467             mCameraTexts[i]->SetBorderType(-1);
00468             mCameraTexts[i]->SetBorderFillShaded(2);
00469 
00470             mCameraTexts[i]->SetAlign(oglLeftAlign, oglCenterAlign);
00471             Sleep(50);
00472         }
00473         pane->ScaleTo(wnd);
00474         pane->ScaleChildren(0,1);
00475         mMonitorPane = pane;
00476     }
00477 
00478     char* MonitorString(int camId)
00479     {
00480         static char    buf[100];
00481         sprintf(buf, "[%d] %s", camId+1,
00482                 mSurveillanceMap->LocationString(camId).c_str());
00483         return &buf[0];
00484     }
00485 
00486     TitledWindow* BuildMonitorAll(Window* wnd, int x, int y, int w, int h)
00487     {
00488         TitledWindow*   titleWnd = new TitledWindow(wnd,x,y,w,h,"Monitor all");
00489         Window*         pane  = new Window(titleWnd,0,0,200,200);
00490 
00491         titleWnd->SetContentPane(pane);
00492 
00493         w = pane->W(), h = pane->H();
00494         for (int i=0;i<12;i++)
00495         {
00496             int vX = (i%6)*w/6, vY = (1-i/6)*h/2;
00497             int vW = w/6, vH = h/2;
00498             int camId = i + 1;
00499             int videoId = i;
00500 
00501             VideoJpgCamera* vc =
00502                 new VideoJpgCamera(pane,vX,vY,vW,vH, mVideos[videoId]);
00503 
00504             mAllCamerasVideos[i] = vc;
00505 
00506             vc->Play(VIRTUAL_TIME_OFFSET);
00507             vc->SetWindowListener(this,(void*)(i+1));
00508 
00509             StaticText* camTxt =
00510                 new StaticText(vc,4,4,200,20,MonitorString(i),false,true);
00511             //camTxt->SetForeground(oglWHITE);
00512             camTxt->SetForeground(0xffffff00); // Yellow
00513             camTxt->SetShadowColor(oglBLACK);
00514             camTxt->SetAlign(oglLeftAlign, oglCenterAlign);
00515             Sleep(10);
00516         }
00517         pane->ScaleChildren();
00518         return titleWnd;
00519     }
00520 
00521     void BuildTimeLinePane(Window* wnd, int x, int y, int w, int h)
00522     {
00523         GroupBox* timeLinePane = new GroupBox(wnd,x,y,w,h,"Timeline" );
00524         SetAsBox(timeLinePane);
00525         timeLinePane->ScaleTo(wnd);
00526         mFramesPerSecond = new FramesPerSecond(timeLinePane,4,h-50,70,24);
00527         mFramesPerSecond->ConnectTo(timeLinePane,L2L|B2T|R2L|T2T);
00528 
00529         mTimeLine = new AlertTimeLine(timeLinePane,20,4,w-40,h-8);
00530         //mTimeLine->SetStartTime(14*3600 + 14*60 + 40);
00531         mTimeLine->SetTime(14*3600 + 14*60 + 40, VIRTUAL_TIME_OFFSET);
00532         mTimeLine->SetTimeSpan(900);
00533         mTimeLine->SetOlderThanText("older than 15 min");
00534         mTimeLine->OlderThanButton()->SetButtonListener(this);
00535         mTimeLine->ScaleTo(wnd);
00536     }
00537 
00539 // Implementation of InspectTrackAlertPane
00540 // (Note: Could also be implemented as separate class)
00541     void BuildInspectionPane(Window *wnd, int x, int y, int w, int h)
00542     {
00543         mInspectionPane = new Window(wnd,x,y,w,h);
00544         Window* pane = mInspectionPane;
00545         pane->ScaleTo(wnd);
00546 
00547         // The inspect videoplayer part
00548         GroupBox* gB = new GroupBox(pane,0,0,406,h,"Event playback");
00549         SetAsBox(gB);
00550 
00551         mVideoPlayer = new VideoJpgPlayer(gB,6,gB->H()-324,392,320, mVideos[0]);
00552         mVideoPlayer->SetVisible(false);
00553 
00554         mVideoPlayerCamText = new StaticText(mVideoPlayer,58,mVideoPlayer->H()-32,
00555                                              180, 20, "", false, true);
00556         mVideoPlayerCamText->SetForeground(0xffffff00); // Yellow
00557         mVideoPlayerCamText->SetShadowColor(oglBLACK);
00558         mVideoPlayerCamText->SetAlign(oglLeftAlign, oglCenterAlign);
00559         mVideoPlayerCamText->SetBorderType(-1);
00560         mVideoPlayerCamText->SetBorderFillShaded(2);
00561 
00562         mVideoTimeSlider =
00563             new TimeSlider(gB,2,32,gB->W()-4,46,14*3600+14*60+40,15*60);
00564         mVideoTimeSlider->SetTimeSliderListener(this);
00565 
00566         mVideoPlayerControl =
00567             new VideoJpgPlayerControl(gB,4,4,gB->W()-8,28,mVideoPlayer);
00568         mVideoPlayerControl->SetBorderType(3);
00569 
00570         for (int i=1; i<8; i++)
00571         {
00572             Button* btn = mVideoPlayerControl->GetButton(i);
00573             btn->SetRoundness(0,0,0,0);
00574             btn->SetBorderType(BEV_ETCHED);
00575         }
00576         gB->ScaleChildren(0,1);
00577 
00578         // Instantiate our class that allows us to be involved with the
00579         // OnImViewer interface (OnPreDrawView,OnDrawView, OnMouse...)
00580         // of the OGLVIEW* used in the video player.
00581         // This object is passed as userData to the videoPlayerListener
00582         mVideoPlayerView = new VideoPlayerView(mVideoPlayer->OglView());
00583 
00584         mVideoPlayerListener = new VideoPlayerListener(mVideos, *mDetectedPersons);
00585         mVideoPlayer->SetVideoJpgPlayerListener(mVideoPlayerListener,
00586                                                 (void*)mVideoPlayerView);
00587 
00588         mCameraEventListPane->EventList()->SetButtonListener(this,(void*) mVideoPlayer);
00589 
00590         mTimeLine->SetAlertTimeLineListener(mCameraEventListPane, (void*)1);
00591 
00592         int gBX = gB->X()+gB->W()+4;
00593 
00594         gB = new GroupBox(pane,gBX,h-182,72,182,"Inspect");
00595         mSubjectWindow = new WindowView2D(gB, 4, 34, 64, 128);
00596         // This solves the problem of scewed drawing for images with un-even width
00597         mSubjectWindow->GetOglView()->texturing = 0;
00598         mSimilarsButton = new Button(gB,4,4,64,26,"Search",BEV_ETCHED,true);
00599         //new Button(gB,4,4,70,24,"Clear",BEV_ETCHED,true);
00600         SetAsBox(gB);
00601 
00602         mVideoPlayerView->SubjectWindow(mSubjectWindow, gRoiPath);
00603         mSimilarsButton->SetButtonListener(this);
00604 
00605         gB->ScaleChildren();
00606 
00607         gBX+=76;
00608         //mIdPane = new IdentificationPane(gRoiPath, NR_OF_CAMERAS_STREET, pane,gBX,52,w-gBX,h-52,"");
00609         mIdPane = new IdentificationPane(mVideos, gRoiPath, pane,gBX,52,w-gBX,h-52,"");
00610         mIdPane->mRoiInfo = mDetectedPersons;
00611         mIdPane->mRoiCorrelations = mSimilarPersons;
00612         //mIdPane->TimesPerFrame(&TIMES_PER_FRAME[0]);
00613         SetAsBox(mIdPane);
00614         SetAsBox(mIdPane->Similars());
00615         SetAsBox(mIdPane->Positives());
00616         mIdPane->SetGuiEventListener(this);
00617 
00618 
00619         int btnW        = 110;
00620         int btnSpace    = 8;
00621         mShowTrackButton = new Button(pane,gBX,12,btnW,32,
00622                                       "Suggest track", BEV_ETCHED,true);
00623         mShowTrackButton->SetButtonListener(this);
00624         mHideTrackButton = new Button(pane,gBX+btnW+btnSpace,12,btnW,32,
00625                                       "Clear track", BEV_ETCHED,true);
00626         mHideTrackButton->SetButtonListener(this);
00627 
00628         mSubmitButton = new Button(pane,gBX+2*(btnW+btnSpace),12,btnW,32,
00629                                    "Alert personnel",BEV_ETCHED,true);
00630         SubmitButtonListener* submitListener = new SubmitButtonListener(this);
00631         mSubmitButton->SetButtonListener(submitListener, (void*) mIdPane);
00632 
00633 #ifdef ALL_MONITORS
00634 mAllCamerasButton = new Button(pane,gBX+3*(btnW+btnSpace),12,btnW,32,
00635                                 "All cameras", BEV_ETCHED,true);
00636 mAllCamerasButton->SetButtonListener(this);
00637 #endif
00638 
00639         mExitButton = new Button(pane,gBX+10+4*(btnW+btnSpace),12,60,32,
00640                                  "EXIT",BEV_ETCHED,true);
00641         mExitButton->SetVisible(false);
00642         mExitButton->SetButtonListener(this);
00643 
00644         pane->ScaleChildren();
00645         // See lengthy explanation in BuildSecondScreen below
00646         pane->SetAllowChildScaling(false);
00647 
00648         mAlertWindow = new AlertWindow(this, gIpAddress);
00649         for (int i = 0; i < NR_OF_POLICEMEN; i++)
00650             mAlertWindow->AddMailTo(MAILTO_TEXTS[i]);
00651         mAlertWindow->SetVisible(false);
00652         submitListener->SetAlertWindow(mAlertWindow);
00653 
00654         mInspectionPane->SetWindowListener(this);
00655     } //BuildInspectionPane()
00656 
00657     virtual void
00658     TimeSliderEvent(TimeSlider *src, long newTime, int userData)
00659     {
00660         int t = (newTime-mTimeLine->GetStartTime());
00661         mVideoPlayer->GoToFrame(t/TIMES_PER_FRAME[mInspectVideoId]);
00662     }
00663 
00664 
00665     // PoliceManListener
00666     virtual void
00667     PoliceManClicked(PoliceMan* src, int btn, int state,
00668                      int x, int y, void* vData)
00669     {
00670         int userData = (int) (long long) vData;
00671         mAlertWindow->SetMailToSelected(userData,true);
00672     }
00673 
00674     class SubmitButtonListener : public ButtonListener
00675     {
00676         SurveillanceApp* mApp;
00677 
00678     public:
00679 
00680         SubmitButtonListener(SurveillanceApp* theApp)
00681         {
00682             mApp = theApp;
00683         }
00684 
00685         virtual void ButtonSelectionEvent(Button *src, void* userData)
00686         {
00687             std::vector<int> trackOfVideoIds;
00688             std::vector<int> timesInSec;
00689             mApp->GetTrack(trackOfVideoIds, timesInSec);
00690             if (trackOfVideoIds.size() <= 0)
00691             {
00692                 std::cout << "cannot send alert without selected positives, since we need a target location for our officers" << std::endl;
00693                 return;
00694             }
00695             mApp->mSurveillanceMap->SetTrack(trackOfVideoIds, timesInSec);
00696             const std::vector<const std::string* const> addressTrack = mApp->mSurveillanceMap->GetCamAddresses(trackOfVideoIds);
00697             mAlertWindow->SpotLocations(trackOfVideoIds, addressTrack, timesInSec);
00698 
00699             for (int i = 0; i < NR_OF_POLICEMEN; i++)
00700                 mAlertWindow->SetMailToSelected(i,false);
00701             int policeStatus[NR_OF_POLICEMEN];
00702             for (int i = 0; i < NR_OF_POLICEMEN; i++)
00703                 policeStatus[i] = POLICE_POSITIONS[i * 3 + 2];
00704             mAlertWindow->SetMailToStatus(policeStatus);
00705 
00706             mAlertWindow->SubjectString("");
00707             mAlertWindow->BodyString("\n\n\n\n\n");
00708             for (int j=0; j<5; j++)
00709                 mAlertWindow->BodyEditor()->DeleteKey();
00710 
00711             mAlertWindow->FromString("M. Worring\nCamera Surveillance");
00712             mAlertWindow->Urgency(1);
00713 
00714             IdentificationPane* idPane = (IdentificationPane*) userData;
00715 
00716             mAlertWindow->SetSelectedImages(idPane->Positives());
00717             //idPane->ClearPositives(); Better let operator decide
00718 
00719             mAlertWindow->BringToFront();
00720             mAlertWindow->SetVisible(true);
00721             oglFocusWnd = mAlertWindow->SubjectEditor()->GetOGLWND();
00722         }
00723 
00724         void SetAlertWindow(AlertWindow* wnd)
00725         {
00726             mAlertWindow = wnd;
00727         }
00728 
00729     protected:
00730 
00731         AlertWindow*     mAlertWindow;
00732 
00733     };
00734 
00735     // responds to event buttons in the CameraEventList and
00736     // to several other buttons
00737     virtual void ButtonSelectionEvent(Button *src, void* userData)
00738     {
00739         if (src == mExitButton)
00740         {
00741             delete this;
00742             exit(0);
00743         }
00744         if (src == mSimilarsButton)
00745         {
00746             RoiInfo* roiInfo = (RoiInfo*) mSubjectWindow->GetOglView()->UserData1;
00747             if (!roiInfo)
00748                 return;
00749 
00750             long secsPassed =
00751                 mTimeLine->GetCurrentTime() - mTimeLine->GetStartTime();
00752             int maxFrameNr = (int)(secsPassed/TIMES_PER_FRAME[roiInfo->videoId]);
00753             mIdPane->SearchSimilars(*roiInfo, maxFrameNr);
00754 /*
00755             int userData[2];
00756             userData[0] = (int) roiInfo;
00757             userData[1] = maxFrameNr;
00758 
00759             mIdPane->ButtonSelectionEvent(0, (int) userData);
00760 */
00761         }
00762         else if (src == mShowTrackButton)
00763         {
00764             std::vector<int> trackOfVideoIds;
00765             std::vector<int> timesInSec;
00766             GetTrack(trackOfVideoIds, timesInSec);
00767             mSurveillanceMap->SetTrack(trackOfVideoIds, timesInSec);
00768         }
00769         else if (src == mHideTrackButton)
00770         {
00771             mSurveillanceMap->ClearTrack();
00772         }
00773 #ifdef ALL_MONITORS
00774         else if (src == mAllCamerasButton)
00775         {
00776             bool    visible = mAllCamerasPane->GetVisible();
00777             mMonitorPane->SetVisible(visible);
00778             mAllCamerasPane->SetVisible(!visible);
00779             mAllCamerasButton->SetText(visible ? "Monitor All" : "Monitor 3");
00780         }
00781 #endif
00782         else if (src == mTimeLine->OlderThanButton())
00783         {
00784             RadioGroup* rG = mCameraEventListPane->WhichCameraRadioGroup();
00785             Button* btn = rG->GetButton(15);
00786             rG->ButtonSelectionEvent(btn, (void*)15);
00787         }
00788         else
00789         {
00790             // RvB: No need to pass videoPlayer around as we have mVideoPlayer
00791             VideoJpgPlayer*     videoPlayer = (VideoJpgPlayer*) userData;
00792             CameraEventButton*  eventButton = (CameraEventButton*) src;
00793 
00794             if (src)
00795             {
00796                 int  camId       = eventButton->CameraId();
00797                 int  videoId     = camId - 1;
00798                 long startTime   = mTimeLine->GetStartTime();
00799                 long elapsedTime = eventButton->Seconds()-startTime;
00800                 VideoInspect(camId, videoId, elapsedTime, eventButton->FrameNr()); 
00801             }
00802             else
00803             {
00804                 videoPlayer->Stop();
00805                 videoPlayer->SetVisible(false);
00806                 mVideoPlayerCamText->SetText("");
00807             }
00808         }
00809     }
00810 
00811     void VideoInspect(int camId, int videoId, long elapsedTime, int frNr=-1)
00812     {
00813         mSurveillanceMap->SetSelectedButton(camId - 1);
00814         mVideoPlayer->OpenVideo(mVideos[videoId]);
00815         mInspectVideoId = videoId;
00816         mVideoPlayerListener->SetVideo(videoId);
00817         mVideoPlayerCamText->SetText(MonitorString(camId-1));
00818 
00819         if (frNr == -1)
00820         {
00821             //mVideoPlayer->GoToFrame(elapsedTime/TIMES_PER_FRAME[videoId]);
00822             int frmNr = elapsedTime/mVideos[videoId].GetTimePerFrame(); // SK: was made Video responsibility
00823             mVideoPlayer->GoToFrame(elapsedTime/mVideos[videoId].GetTimePerFrame());
00824         }
00825         else
00826             mVideoPlayer->GoToFrame(frNr);
00827 
00828         mVideoPlayer->Stop();
00829         mVideoPlayer->SetVisible(true);
00830     }
00831  
00832 
00833     virtual void
00834     ButtonSelectionEvent(SurveillanceMap* src, int btnId, void* userData)
00835     {
00836         Button* cameraButton = src->GetButton(btnId);
00837         int x = cameraButton->X() + cameraButton->W();
00838         int y = cameraButton->Y()-4;
00839         mMonitorSelector->SetDimensions(x,y,RETAIN,RETAIN);
00840         mMonitorSelector->SetVisible();
00841         mMonitorSelector->SetMonitorSelectorListener(this, (void*)btnId);
00842     }
00843 
00844 
00845     virtual void
00846     MonitorSelectionEvent(MonitorSelector* src, int id, void* userData)
00847     {
00848         int  camId = (int)(long long)userData;
00849         mCameraTexts[id]->SetText(MonitorString(camId));
00850         //mVideoCameras[id]->TimePerFrame(TIMES_PER_FRAME[camId]); // SK: now taken from the video obj
00851         mVideoCameras[id]->OpenVideo(mVideos[camId]);
00852         mVideoCameras[id]->OglView()->rotZ = -180;
00853         mVideoCamerasVideoId[id] = camId;
00854     }
00855 
00856     virtual void
00857     WindowMouseEvent(Window *src, int msg, int but, int state,
00858                      int x, int y, void* vData )
00859     {
00860         int userData = (int)(long long) vData;
00861         if (src == mInspectionPane &&
00862             msg == oglMouseDblClick && (state&oglControl))
00863         {
00864             if (state&oglLeftButton)
00865                 mExitButton->SetVisible(!mExitButton->GetVisible());
00866             if (state&oglRightButton)
00867             {
00868                 if(state&oglShift)
00869                     mVideoPlayerView->mShowFrameNr = !mVideoPlayerView->mShowFrameNr;
00870                 else
00871                     mFramesPerSecond->SetVisible(!mFramesPerSecond->GetVisible());
00872             }
00873         }
00874         if (src == mSurveillanceMap && msg == oglMouseDown)
00875         {
00876             mMonitorSelector->SetVisible(false);
00877             printf("X: %d y: %d\n", x, y);
00878         }
00879 #ifdef ALL_MONITORS
00880         else if (msg == oglMouseDown && userData)
00881         {
00882             int  frNr = mAllCamerasVideos[userData-1]->FrameNr();
00883             long startTime   = mTimeLine->GetStartTime();
00884             long elapsedTime = mTimeLine->GetCurrentTime()-startTime;
00885             int  videoId     = userData;
00886             VideoInspect(videoId, videoId-1, elapsedTime, frNr); 
00887         }
00888 #endif
00889         else if (msg == oglMouseDown)
00890         {
00891             // If user clicked one of the monitors then display in inspect video
00892             for (int i=0; i<3; i++)
00893                 if (src == mVideoCameras[i])
00894                 {
00895                     int frNr = mVideoCameras[i]->FrameNr();
00896                     long startTime   = mTimeLine->GetStartTime();
00897                     long elapsedTime = mTimeLine->GetCurrentTime()-startTime;
00898                     int  videoId     = mVideoCamerasVideoId[i];
00899                     VideoInspect(videoId+1, videoId, elapsedTime, frNr); 
00900                 }
00901         }
00902     }
00903 
00904     void GuiEvent(Window* src, void* userData)
00905     {
00906         if (src == mIdPane)
00907         {
00908             RoiInfo* roiInfo = (RoiInfo*) userData;
00909             if (roiInfo->videoId > -1)
00910             {
00911                 mInspectVideoId = roiInfo->videoId;
00912                 mVideoPlayer->OpenVideo(mVideos[roiInfo->videoId]);
00913                 mVideoPlayer->GoToFrame(roiInfo->frameNr);
00914                 mVideoPlayerListener->SetVideo(roiInfo->videoId);
00915                 int camId = roiInfo->videoId + 1;
00916                 //mVideoPlayerCamText->SetText("camera: " + MakeString(camId));
00917                 mVideoPlayerCamText->SetText(MonitorString(camId-1));
00918             }
00919             else
00920                 std::cout << "invalid video id in GuiEvent" << std::endl;
00921         }
00922     }
00923 
00925 // Second screen showing city map with camera buttons
00926     void BuildSecondScreenGUI()
00927     {
00928         OGLIMAGE*        im = TryReadPNG("map.png");
00929         float            imW = (float) im->w, imH = (float) im->h;
00930 
00931         mSurveillanceMap = new SurveillanceMap(1280, 0, 1272, 990, im);
00932         oglSys.ReleaseOglImage(im);
00933 
00934         // Google map coordinates.
00935         int Xs[] = {230, 271, 384, 294, 743, 682, 576, 556, 566, 682, 791, 623,    551, 571, 591};
00936         int Ys[] = {23,   49, 122, 274, 460, 342, 725, 832, 812, 935, 826, 592,    763, 769, 775};
00937 
00938         char buf[10];
00939         for (int i=0; i<NR_OF_CAMERAS; i++)
00940         {
00941             float   x = Xs[i];
00942             float   y = Ys[i];
00943             sprintf(buf,"%d",i+1);
00944             mSurveillanceMap->CreateButton(x, y, buf);
00945         }
00946 
00947         mSurveillanceMap->SelectButton(3);
00948         mSurveillanceMap->ScaleChildren();
00949 
00950         // Prevent others from scaling the children of the map.
00951         // That is, suppose this class becomes part of a much larger app,
00952         // and the larger app programmer is a lazy bastard and he
00953         // just calls ScaleChildren(0,1), 0: no restrictions, 1:recursively
00954         // on its top level window. We don't mind the map being scaled,
00955         // but prevent the children of being scaled twice
00956         // as we do scaling our-selves in the statement above.
00957         mSurveillanceMap->SetAllowChildScaling(false);
00958         mSurveillanceMap->Start();
00959     }
00960 
00961     // Schedules events on seconds relative to start-up;
00962     // note that the virtual event time has to be set dynamically;
00963     // also note that cam events use cam nrs (1, 2, ...)
00964     void ScheduleCamEvents(std::map<int, std::vector<CameraEvent> >& camEventSchedule)
00965     {
00966         // 'oude' test-events van Richard:
00967         camEventSchedule[1].push_back(CameraEvent(10, 1, "by Richard"));
00968         camEventSchedule[4].push_back(CameraEvent(1, 1, "by Richard"));
00969 
00970         // de extra jeroen-demo-momenten:
00971         camEventSchedule[55].push_back(CameraEvent(5, 1, "for Jeroen"));
00972         // RvB: Commented line below jumps to exact frameNr.
00973         camEventSchedule[55].push_back(CameraEvent(5, 1, 174, "for Jeroen"));
00974         //camEventSchedule[193].push_back(CameraEvent(7, 1, "for Jeroen"));
00975 
00976         // enkele test-events van Sander
00977         camEventSchedule[3303 * mVideos[1].GetTimePerFrame()].push_back(CameraEvent(2, 1, 3303, "by Sander"));
00978         camEventSchedule[3490 * mVideos[1].GetTimePerFrame()].push_back(CameraEvent(2, 1, 3490, "by Sander"));
00979         camEventSchedule[4426 * mVideos[6].GetTimePerFrame()].push_back(CameraEvent(7, 1, 4426, "by Sander"));
00980 
00981         // het jurrien moment van Marcel
00982         camEventSchedule[578 * mVideos[1].GetTimePerFrame()].push_back(CameraEvent(2, 1, 578, "Jurrien"));
00983 
00984         // SK: no longer random events
00986         //for (int i = 0; i < 10; i++)
00987         //{
00988         //    int id = 1 + ABSRND(NR_OF_CAMERAS);
00989         //    int type = 1 + ABSRND(4);
00990         //    int timeSec = ABSRND(VIRTUAL_TIME_OFFSET);
00991         //    camEventSchedule[timeSec].push_back(CameraEvent(id, type, "random,pre"));
00992         //}
00993 
00994         ReadActivityEvents(camEventSchedule);
00995 
00996         ReadCameraMovements(camEventSchedule);
00997     }
00998 
00999     //void ReadCameraMovements()
01000     //{
01001     //    CameraMovementReader reader;
01002     //    reader.Read2(gCamMovementInfoPath, mVideos);
01003     //}
01004 
01005     void ReadCameraMovements(std::map<int, std::vector<CameraEvent> >& camEventSchedule)
01006     {
01007         CameraMovementReader reader;
01008         reader.Read(gCamMovementInfoPath, mVideos, camEventSchedule);
01009     }
01010 
01011     void ReadActivityEvents(std::map<int, std::vector<CameraEvent> >& camEventSchedule)
01012     {
01013         ActivityReader reader;
01014         if (reader.ProperlyConstructed())
01015             reader.Read(gXmlPathMichael, camEventSchedule);
01016     }
01017 
01018     void SetupVideoData(std::vector<Visualization::Video>& videos)
01019     {
01020         for (int thang = 0; thang < NR_OF_CAMERAS_STREET; thang++)
01021         {
01022             int nrFrames = MAX_FRAMES[thang];
01023             Visualization::Video video(nrFrames, TIMES_PER_FRAME[thang]);
01024             video.mType = 0;
01025             video.mId = thang;
01026             video.mSubId = thang;
01027             const std::string& videoName = VIDEO_NAMES_STREET[video.mId % NR_OF_CAMERAS_STREET];
01028             video.mBasePath = gVideoPathThang + videoName + "/" + videoName + std::string("_");
01029             video.mFileNameSuffix = ".jpg";
01030             video.mBasePathAnnotated = "";
01031             video.mFileNameSuffixAnnotated = "";
01032             videos.push_back(video);
01033         }
01034 
01035         for (int michael = 0; michael < NR_OF_CAMERAS_STATION; michael++)
01036         {
01037 #ifdef RICHARD
01038             Visualization::Video video(20, TIMES_PER_FRAME[NR_OF_CAMERAS_STREET + michael]);
01039 #else
01040             Visualization::Video video(ActivityReader::TotalSequenceLength(), TIMES_PER_FRAME[NR_OF_CAMERAS_STREET + michael]);
01041 #endif
01042             video.mType = 1;
01043             video.mId = NR_OF_CAMERAS_STREET + michael;
01044             video.mSubId = michael;
01045 
01046 #ifdef RICHARD
01047             video.mBasePath = gVideoPathMichael + "im_000";
01048             video.mFileNameSuffix = "_r" + MakeString(video.mSubId) + ".jpg";
01049             video.mBasePathAnnotated = gVideoPathMichael + "imR_000";
01050             video.mFileNameSuffixAnnotated = "";
01051 #else
01052             //video.mBasePath = gVideoPathMichael + "pickpocketing/images_400_original/image";
01053             video.mBasePath = gVideoPathMichael + "original/";
01054             video.mFileNameSuffix = "_cam" + MakeString(video.mSubId) + ".jpg";
01055             //video.mBasePathAnnotated = gVideoPathMichael + "pickpocketing/images_400_marked/image";
01056             video.mBasePathAnnotated = gVideoPathMichael + "marked/";
01057             video.mFileNameSuffixAnnotated = "";
01058 #endif
01059 
01060             videos.push_back(video);
01061         }
01062     }
01063 
01064 
01065     void GetTrack(std::vector<int>& trackOfVideoIds, std::vector<int>& trackTimesSec)
01066     {
01067         std::vector<int> trackOfFrameNrs;
01068         mIdPane->SuggestTrack(trackOfVideoIds, trackOfFrameNrs); // track in video id's {0, ..}
01069         //std::vector<int> timesInSec;
01070         int startTimeSecs = mTimeLine->GetStartTime();
01071         for (int i = 0; i < trackOfVideoIds.size(); i++)
01072         {
01073             //timesInSec.push_back(i * 300 + 56789); // dummy value
01074             int frameTimeOffsetSecs = mVideos[trackOfVideoIds[i]].GetTimePast(trackOfFrameNrs[i]);
01075             trackTimesSec.push_back(startTimeSecs + frameTimeOffsetSecs);
01076         }
01077     }
01078 
01079 
01080 protected:
01081 
01082     Tabs*                       mTabs;
01083 
01084     ApplicationEnding*          mApplicationEnding;
01085 
01086     Window*                     mMonitorPane;
01087     Window*                     mInspectionPane;
01088 
01089     SurveillanceMap*            mSurveillanceMap;
01090     AlertTimeLine*              mTimeLine;
01091     CameraEventListPane*        mCameraEventListPane;
01092 
01093     MonitorSelector*            mMonitorSelector;
01094 
01095     VideoJpgCamera*             mVideoCameras[3];
01096     int                         mVideoCamerasVideoId[3];
01097 
01098     int                         mInspectVideoId;
01099     VideoJpgPlayer*             mVideoPlayer;
01100     VideoJpgPlayerControl*      mVideoPlayerControl;
01101     VideoPlayerListener*        mVideoPlayerListener;
01102     VideoPlayerView*            mVideoPlayerView;
01103     StaticText*                 mVideoPlayerCamText;
01104     TimeSlider*                 mVideoTimeSlider;
01105 
01106     Button*                     mSimilarsButton;
01107 
01108     Button*                     mShowTrackButton;
01109     Button*                     mHideTrackButton;
01110     Button*                     mSubmitButton;
01111     Button*                     mExitButton;
01112 
01113 #ifdef ALL_MONITORS
01114 TitledWindow*     mAllCamerasPane;
01115 Button*           mAllCamerasButton;
01116 VideoJpgCamera*   mAllCamerasVideos[NR_OF_CAMERAS_STREET];
01117 #endif
01118 
01119     StaticText*                 mCameraTexts[3];
01120     Button*                     mAltBtns[3];
01121 
01122     //int                         mMaxVideoFrame;
01123 
01124     RegionsOfInterestInfo*      mDetectedPersons;
01125     RegionsOfInterestCorrelation* 
01126                                 mSimilarPersons;
01127 
01128     IdentificationPane*         mIdPane;
01129     WindowView2D*               mSubjectWindow;
01130 
01131     AlertWindow*                mAlertWindow;
01132 
01133     FramesPerSecond*            mFramesPerSecond;
01134 
01135     std::vector<Visualization::Video> mVideos;
01136 
01137     std::map<int, std::vector<CameraEvent> > mCamEventSchedule;
01138     std::map<int, std::vector<CameraEvent> >::iterator mCamEventSchedulePosition;
01139 
01140 }; //class SurveillanceApp
01141 
01142 } // namespace SDash
01143 } // namespace Application
01144 } // namespace Impala
01145 
01146 
01147 
01148 using namespace Impala::Application::SDash;
01149 
01150 int main(int argc, char* argv[])
01151 {
01152     Impala::CmdOptions& options = Impala::CmdOptions::GetInstance();
01153     options.Initialise(false, false, false);
01154 
01155     if (! options.ParseArgs(argc, argv, "<data root path> <ip-address>", 1))
01156     {
01157         fprintf( stderr, "command line parsing failed\n" );
01158         return 1;
01159     }
01160 
01161     gDataRoot = options.GetArg(0) + std::string("/");
01162     gVideoPathThang = gDataRoot + std::string("thang/video/");
01163     gRoiPath = gDataRoot + std::string("thang/roi/");
01164 
01165 #ifdef RICHARD
01166     gVideoPathMichael = gDataRoot + std::string("michael/GD_sequence/");
01167     gXmlPathMichael = gVideoPathMichael;
01168 #else
01169     gVideoPathMichael = gDataRoot + std::string("michael/images/");
01170     gXmlPathMichael = gDataRoot + std::string("michael/annotation/");
01171 #endif
01172     gCamMovementInfoPath = gDataRoot + std::string("nicolaas/");
01173 
01174     gIpAddress = argc > 1 ? options.GetArg(1) : "";
01175 
01177     //{
01178     //    AlertRelay relay(gIpAddress);
01179     //    if (relay.IsReady())
01180     //    {
01181     //        relay.Relay("first message from sdash");
01182     //        relay.Relay("second message from sdash");
01183     //    }
01184     //}
01185 
01186     OglInit(&argc, &argv[0]);
01187 
01188     SurveillanceApp* wnd = new SurveillanceApp(1272, 960);
01189 
01190     if (!wnd->Valid())
01191     {
01192         fprintf( stderr, "GUI setup failed\n" );
01193         return 2;
01194     }
01195 
01196     OglEventLoop();
01197 
01198     wnd->CleanUp();
01199     
01200     return 0;
01201 }

Generated on Fri Mar 19 09:30:38 2010 for ImpalaSrc by  doxygen 1.5.1