00001 #ifndef TrackVisualiser_h
00002 #define TrackVisualiser_h
00003
00004 #include "OglGui/Window.h"
00005 #include "Visualization/ViewListenerWithRectangles.h"
00006 #include "Visualization/Plot/Plot.h"
00007 #include "Visualization/Plot/Line.h"
00008 #include "Visualization/Plot/TimeLine.h"
00009 #include "Visualization/Window.h"
00010 #include "Domain/FrameRegionTrack.h"
00011 #include "Core/Geometry/Rectangle.h"
00012 #include "Core/Array/Sort.h"
00013
00014 namespace Impala
00015 {
00016
00017
00018 class TrackVisualiser
00019 {
00020 public:
00021 TrackVisualiser(OglGui::Window* parent,
00022 Domain::ImageRegionTrack* track,
00023 Domain::DataArray* similarity,
00024 Domain::ImageSequence* video)
00025 {
00026 using Visualization::Plot::Plot;
00027 using Visualization::Plot::Line;
00028 using Visualization::Plot::TimeLine;
00029
00030 mTrack = track;
00031 mSimilarity = similarity;
00032 mVideoViewer = new Visualization::Window(parent, video->GetWidth(), video->GetHeight());
00033 mVideoViewer->SetBackground(0xffff0000);
00034 mVideoPlayer = new Domain::ImageSequenceReader(video);
00035 mFeatureViewer = new Visualization::Window(parent, 23, 23);
00036 mSortedFeature = 0;
00037
00038 mPlot1 = new Plot(parent, 300, 300);
00039 mPlot1->SetPerspective(false);
00040 mPlot1->SetDrawAxes(true);
00041 mPlotDistribution = new Line(0);
00042 mPlotDistribution->SetColor(1, 1, 0);
00043 mPlot1->Add(mPlotDistribution);
00044
00045 mPlot2 = new Plot(parent, 700, 300);
00046 mPlot2->SetPerspective(false);
00047 mPlot2->SetDrawAxes(true);
00048 mPlotHighest = new TimeLine(0, 200);
00049 mPlotHighest->SetColor(0, 1, 0);
00050 mPlot2->Add(mPlotHighest);
00051 }
00052
00053 void operator()()
00054 {
00055 using Core::Array::Array2dScalarReal64;
00056
00057 Visualization::ViewListenerWithRectangles* rectDrawer = new Visualization::ViewListenerWithRectangles;
00058 for(int i=0 ; i<mTrack->size() && mVideoPlayer->HasAvailable() ; i++)
00059 {
00060 if(i<mTrack->size())
00061 {
00062 Core::Geometry::Rectangle& rect = mTrack->at(i)->GetRectangle();
00063 rectDrawer->SetRectangle(rect.mLeft, rect.mTop, rect.mRight, rect.mBottom);
00064 }
00065 Domain::Image* im = mVideoPlayer->GetImage();
00066 Array2dVec3UInt8* a = im->GetData()->mDataVec3UInt8;
00067 mVideoViewer->UpdateView(0, a, rectDrawer);
00068
00069 if(i<mTrack->size() && i>0)
00070 {
00071 Array2dScalarReal64* feature = reinterpret_cast<Array2dScalarReal64*>(mSimilarity->at(i-1));
00072 mFeatureViewer->UpdateView(0, feature, "Stretch");
00073 Core::Array::Sort(mSortedFeature, feature);
00074
00075 mPlotDistribution->SetData(mSortedFeature->CPB(), mSortedFeature->W() * mSortedFeature->H());
00076 mPlot1->AutoScale();
00077 mPlotHighest->Add(*mSortedFeature->CPE());
00078 mPlot2->AutoScale();
00079 }
00080 else
00081 {
00082
00083 }
00084 if(OglGui::Sys::Instance().WindowManage())
00085 break;
00086 Sleep(50);
00087 }
00088 }
00089
00090
00091 private:
00092 Visualization::Window* mVideoViewer;
00093 Visualization::Window* mFeatureViewer;
00094 Visualization::Plot::Plot* mPlot1;
00095 Visualization::Plot::Plot* mPlot2;
00096 Visualization::Plot::TimeLine* mPlotHighest;
00097 Visualization::Plot::Line* mPlotDistribution;
00098 Core::Array::Array2dScalarReal64* mSortedFeature;
00099 Domain::ImageRegionTrack* mTrack;
00100 Domain::DataArray* mSimilarity;
00101 Domain::ImageSequenceReader* mVideoPlayer;
00102 };
00103
00104 }
00105
00106 #endif TrackVisualiser_h