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

VideoPlayerListener.h

Go to the documentation of this file.
00001 #ifndef Impala_Application_SDash_VideoPlayerListener_h
00002 #define Impala_Application_SDash_VideoPlayerListener_h
00003 
00004 #include <string>
00005 #include <vector>
00006 
00007 #include "Visualization/Video.h"
00008 #include "Visualization/VideoJpgPlayer.h"
00009 #include "Visualization/VideoJpgPlayerListener.h"
00010 
00011 #include "Core/Geometry/Rectangle.h"
00012 
00013 #include "Application/sdash/VideoPlayerView.h"
00014 #include "Application/sdash/RegionsOfInterestInfo.h"
00015 
00016 namespace Impala {
00017 namespace Application {
00018 namespace SDash {
00019 
00021 // Listening to the Inspect VideoPlayer.
00022 
00023 class VideoPlayerListener : public Visualization::VideoJpgPlayerListener
00024 {
00025 
00026 public:
00027 
00028     typedef Visualization::VideoJpgPlayer            VideoJpgPlayer;
00029     typedef Visualization::VideoJpgPlayerListener    VideoJpgPlayerListener;
00030     typedef Core::Geometry::Rectangle Rectangle;
00031 
00032     VideoPlayerListener(
00033         const std::vector<Visualization::Video>& videos, 
00034         const RegionsOfInterestInfo& detectedPersons)
00035         : mVideos(videos), mDetectedPersons(detectedPersons)
00036     {
00037     }
00038 
00039     virtual void OnNewFrame(VideoJpgPlayer *src, int frameNr, void* userData)
00040     {
00041         VideoPlayerView* theView = (VideoPlayerView*) userData;
00042 
00043         static const int imageWidth = theView->GetImage()->w;
00044         static const int imageHeight = theView->GetImage()->h;
00045         static const float scale = (float) imageHeight / (float) mDetectedPersons.GetFrameHeight();
00046 
00047         std::vector<RegionsOfInterestInfo::ScaledRegion> regions;
00048         if (!mVideos[mVideoId].IsMovementFrame(frameNr))
00049             regions = mDetectedPersons.GetRoisScaled(mVideoId, frameNr, scale); // SK: correct for frame start nr
00050         //else
00051         //    printf("no roi's displayed for movement frame %i of video %i\n", frameNr, mVideoId);
00052 
00053         // normalize every frame once (and not on every display event!)
00054         int nrOfRegions = regions.size();
00055         for (int i = 0; i < nrOfRegions; i++)
00056         {
00057             RegionsOfInterestInfo::ScaledRegion& region = regions[i];
00058             region.left = region.left / imageWidth;
00059             region.top = region.top / imageHeight;
00060             region.width = region.width / imageWidth;
00061             region.height = region.height / imageHeight;
00062         }
00063 
00064         theView->SetVideoId(mVideoId);
00065         theView->SetFrameNr(frameNr);
00066         theView->SetRegionsOfInterest(regions);
00067         theView->SetRoiNr(-1);
00068     }
00069 
00070     void SetVideo(int videoId)
00071     {
00072         mVideoId = videoId;
00073     }
00074 
00075 private:
00076 
00077     int mVideoId;
00078 
00079     const std::vector<Visualization::Video>& mVideos;
00080     const RegionsOfInterestInfo& mDetectedPersons;
00081 
00082 }; //class VideoPlayerListener
00083 
00084 
00085 } // namespace SDash
00086 } // namespace Application
00087 } // namespace Impala
00088 
00089 #endif

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