00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef Impala_Application_IDash_ScreenTimeLineVideo_h
00014 #define Impala_Application_IDash_ScreenTimeLineVideo_h
00015
00016 #include "Core/VideoSet/SegmentationDocument.h"
00017 #include "Visualization/VideoTimeLine.h"
00018 #include "ScreenBase.h"
00019
00020 namespace Impala {
00021 namespace Application {
00022 namespace IDash {
00023
00024
00025 class ScreenTimeLineVideo : public ScreenBase
00026 {
00027 typedef Core::VideoSet::SegmentationDocument SegmentationDocument;
00028 typedef Core::VideoSet::VideoSet VideoSet;
00029 typedef Core::Stream::RgbDataSrc RgbDataSrc;
00030
00031 typedef Visualization::VideoTimeLine VideoTimeLine;
00032
00033 public:
00034
00035 ScreenTimeLineVideo(int w, int h, int id) :
00036 ScreenBase(w, h)
00037 {
00038 InitScreen(id);
00039 }
00040
00041 ScreenTimeLineVideo(OglGui::Window *parent, int w, int h,int id) :
00042 ScreenBase(parent, w, h)
00043 {
00044 InitScreen(id);
00045 }
00046
00047 ScreenTimeLineVideo(OglGui::Window *parent, int id) :
00048 ScreenBase(parent)
00049 {
00050 InitScreen(id);
00051 }
00052
00053 void SetSegmentationDoc(SegmentationDocument* segDoc)
00054 {
00055 mSegDoc = segDoc;
00056 }
00057
00058 virtual void
00059 HandleActivate()
00060 {
00061 int fileId = mSegDoc->CurFileId();
00062 if (fileId == mCurFile && fileId != -1)
00063 {
00064 mVideoTimeLine->VidPlayer()->Stop();
00065 mVideoTimeLine->VidPlayer()->MoveToFrame(mSegDoc->CurFrame());
00066 return;
00067 }
00068 mCurFile = fileId;
00069 HandleNewVideo();
00070 }
00071
00072 void HandleNewVideo()
00073 {
00074 VideoSet* videoSet = mSegDoc->GetSegmentation()->GetVideoSet();
00075 String relativeVideoPath = videoSet->GetAsPath(mCurFile);
00076 mVideoTimeLine->OpenVideo("No index: " + relativeVideoPath, 0, 0);
00077 if (mCurFile == -1)
00078 return;
00079 RgbDataSrc* videoRgb = videoSet->GetVideo(mCurFile);
00080 RgbDataSrc* stripRgb = videoSet->GetVideo(mCurFile);
00081 if (!CheckValidity(videoRgb, stripRgb))
00082 return;
00083 mVideoTimeLine->OpenVideo(relativeVideoPath, videoRgb, stripRgb);
00084 mVideoTimeLine->VidPlayer()->MoveToFrame(mSegDoc->CurFrame());
00085 }
00086
00087
00088 protected:
00089
00090 bool CheckValidity(RgbDataSrc* vRgb, RgbDataSrc* sRgb)
00091 {
00092 if (!vRgb || !sRgb || !vRgb->HasIndex() || !sRgb->HasIndex())
00093 {
00094 if (vRgb) delete vRgb;
00095 if (sRgb) delete sRgb;
00096 return false;
00097 }
00098 return true;
00099 }
00100
00101 private:
00102 void
00103 InitScreen(int controlId)
00104 {
00105 ILOG_DEBUG("constructing screen TimeLineVideo");
00106 SetControlId(controlId);
00107 mCurFile = -1;
00108 mVideoTimeLine = new VideoTimeLine(this,4,4,W()-8,H()-8);
00109 }
00110
00111 SegmentationDocument* mSegDoc;
00112 VideoTimeLine* mVideoTimeLine;
00113
00114 int mCurFile;
00115 ILOG_VAR_DEC;
00116 };
00117
00118 ILOG_VAR_INIT(ScreenTimeLineVideo, Application.IDash);
00119
00120 }
00121 }
00122 }
00123
00124 #endif