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

AnnoPUNS.h

Go to the documentation of this file.
00001 //345678901234567890123456789012345678901234567890123456789012345678901234567890
00002 
00003 #ifndef Impala_Visualization_AnnoPUNS_h
00004 #define Impala_Visualization_AnnoPUNS_h
00005 
00006 #include "Core/VideoSet/SegmentationDocument.h"
00007 #include "Visualization/PunsOnlyControl.h"
00008 #include "Visualization/ShowNextFromControl.h"
00009 #include "Visualization/ImageSet.h"
00010 #include "Visualization/ImageSetIdxGridScroller.h"
00011 #include "OglGui/Button.h"
00012 #include "OglGui/TextEdit.h"
00013 #include "OglGui/CheckBox.h"
00014 
00015 namespace Impala {
00016 namespace Visualization {
00017 
00018 class AnnoPUNS : public OglGui::Window,
00019                  public AppControlDoc,
00020                  public Core::Database::DataDocumentListener,
00021                  public PunsOnlyControlListener,
00022                  public ShowNextFromControlListener,
00023                  public OglGui::WindowListener,
00024                  public OglGui::ButtonListener,
00025                  public OglGui::CheckBoxListener,
00026                  public ImageSetIdxGridListener,
00027                  public ImagesListener
00028 {
00029 public:
00030 
00031     typedef std::vector<UCHAR>                       VideoAnnotation;
00032     typedef std::vector<VideoAnnotation*>            VideoAnnotations;
00033     typedef Core::VideoSet::SegmentationDocument     SegmentationDocument;
00034     typedef Core::VideoSet::Segmentation             Segmentation;
00035     typedef Core::VideoSet::Keyframes                Keyframes;
00036     typedef Core::ImageSet::ImageSet                 ImageSet;
00037 
00038     AnnoPUNS(OglGui::Window* parent, int w, int h, int imW, int imH,
00039              SegmentationDocument* segDoc, VideoAnnotations* vidAnnos,
00040              int controlId):
00041         OglGui::Window(parent, w, h),
00042         AppControlDoc(controlId, segDoc)
00043     {
00044         Init(w,h,imW,imH,segDoc,vidAnnos);
00045     }
00046 
00047     virtual void
00048     HandleNewFile()
00049     {
00050         if (mImageSetWnd)
00051         {
00052             mImageSetWnd->SetImageSelected(-1);
00053             mImageSetWnd->SetFirstVisY(0, true);
00054         }
00055         if (mImSetIdxGrid)
00056             mImSetIdxGrid->SetSelected(-1);
00057 
00058         int curFileId = mSegDoc->CurFileId();
00059         String vidName;
00060         if (curFileId != -1 && mVideoCheckBox->GetSelected())
00061             vidName = mSegDoc->GetDataSet()->GetFile(curFileId);
00062         mVideoText->SetText(vidName);
00063 
00064         UpdateAnno();
00065         UpdatePUNS();
00066     }
00067 
00068     void UpdateAnno()
00069     {
00070         mKeyframeVec.clear();
00071 
00072         Segmentation*   seg     = mSegDoc->GetSegmentation();
00073         Keyframes*      kFrames = mSegDoc->GetKeyframes();
00074         int             iSize   = mVideoAnnotations->size();
00075         int             bit     = -1;
00076 
00077         if (mPunsOnly->UnknownCheckBox()->GetSelected())
00078             bit = 0;
00079         if (mPunsOnly->PositiveCheckBox()->GetSelected())
00080             bit = 2;
00081         if (mPunsOnly->SkipCheckBox()->GetSelected())
00082             bit = 4;
00083         if (mPunsOnly->NegativeCheckBox()->GetSelected())
00084             bit = 8;
00085 
00086         for (int i=0; i<iSize; i++)
00087         {
00088             VideoAnnotation* vidAnno = (*mVideoAnnotations)[i];
00089             int  firstShot   = seg->GetFirstShotVideo(i);
00090             int  sz          = seg->GetNrShotsVideo(i);
00091             int  lastShot    = firstShot+sz;
00092             int  jSize       = vidAnno->size();
00093             if (mVideoCheckBox->GetSelected() && i != mSegDoc->CurFileId())
00094                 continue;
00095 
00096             for (int j=0; j<jSize; j++)
00097             {
00098                 int vidBit = (*vidAnno)[j];
00099                 if (bit==-1 || vidBit == bit)
00100                 {
00101                     int   kFrame   = kFrames->GetShotRKF(j+firstShot);
00102                     mKeyframeVec.push_back(kFrame);
00103                 }
00104             }
00105         }
00106         int nrIm = mKeyframeVec.size();
00107         if (mImageSetWnd)
00108         {
00109             mShowNextFrom->MaxVal(nrIm);
00110             mStartIm = mShowNextFrom->StartVal();
00111         }
00112         if (mIdxGridTotalTxt)
00113             mIdxGridTotalTxt->SetText("Total: " + MakeString(nrIm));
00114     }
00115 
00116     void UpdatePUNS()
00117     {
00118         ImageSet*  imSet = mSegDoc->GetImSetKeyframes(true);
00119         if (mImageSetWnd)
00120         {
00121             mImageSetWnd->RemoveImages();
00122             mImageSetWnd->SetFirstVisY(0, true);
00123         }
00124         if (mImSetIdxGrid)
00125             mImSetIdxGrid->Clear();
00126 
00127         int curShot = mSegDoc->CurShot();
00128         int curKey = -1;
00129         if (curShot != -1)
00130             curKey = mKeyframes->GetShotRKF(curShot);
00131         int sz = mKeyframeVec.size();
00132         for (int i=0; i<mKeyframeVec.size(); i++)
00133         {
00134             if (i>=mStartIm && i<mStartIm+mNrToShow)
00135             {
00136                 if (mImageSetWnd)
00137                     mImageSetWnd->AddImage(mKeyframeVec[i],imSet);
00138                 if (mImSetIdxGrid)
00139                     mImSetIdxGrid->AddImageSetIdx(imSet,mKeyframeVec[i]);
00140                 if (mKeyframeVec[i] == curKey)
00141                 {
00142                     if (mImageSetWnd)
00143                         mImageSetWnd->SetImageSelected(i-mStartIm);
00144                     if (mImSetIdxGrid)
00145                         mImSetIdxGrid->SetSelected(i);
00146                 }
00147             }
00148         }
00149         if (mImSetIdxGrid)
00150             mImSetIdxGrid->UpdateLayout(true);
00151     }
00152 
00153     virtual void PunsOnlyChanged(PunsOnlyControl *src, void* userData)
00154     {
00155         HandleNewFile();
00156     }
00157 
00158     virtual void
00159     ShowNextFromChanged(ShowNextFromControl *src, void* userData)
00160     {
00161         mNrToShow = src->NrToShow();
00162         HandleNewFile();
00163     }
00164 
00165 
00166     virtual void
00167     CheckBoxEvent(OglGui::CheckBox *src, bool checked, void* userData)
00168     {
00169         HandleNewFile();
00170     }
00171 
00172     virtual void
00173     ImageSelectionEvent(ImagesWindow* src, int imIndex, void* listenerData)
00174     {
00175         int keyfr = mKeyframeVec[imIndex+mStartIm];
00176         mSegDoc->GotoKeyfr(keyfr);
00177     }
00178 
00179     virtual void
00180     ImageSelectionEvent(ImageSetIdxGrid* src, int imIndex, void* listenerData)
00181     {
00182         int keyfr = mKeyframeVec[imIndex];
00183         mSegDoc->GotoKeyfr(keyfr);
00184     }
00185 private:
00186 
00187     void Init(int w, int h, int imW, int imH, SegmentationDocument* segDoc,
00188               VideoAnnotations* vidAnnos)
00189     {
00190         CmdOptions& options = CmdOptions::GetInstance();
00191         mNrToShow = options.GetInt("annoNrToShow", 200);
00192         int punsNrToShow = options.GetInt("annoNrToShowPUNS", -1);
00193         if (punsNrToShow != -1)
00194             mNrToShow = punsNrToShow;
00195 
00196         mSegDoc = segDoc;
00197         mVideoAnnotations = vidAnnos;
00198         mKeyframeSet = mSegDoc->GetImSetKeyframes(false);
00199         mKeyframes   = mSegDoc->GetKeyframes();
00200 
00201         mVideoCheckBox = new OglGui::CheckBox(this, 100, 20, "OneVideo", false);
00202         mVideoCheckBox->SetCheckBoxListener(this, 0);
00203         mVideoText = new OglGui::TextArea(this, w/2 - 110, 20, "empty");
00204         mVideoText->SetBorderType(0);
00205 
00206         new OglGui::Strut(this,2000,1);
00207         mPunsOnly = new PunsOnlyControl(this, 446, 20, 15);
00208         mPunsOnly->SetListener(this);
00209 
00210         mIdxGridTotalTxt = 0;
00211         mStartIm = 0;
00212         mShowNextFrom = 0;
00213         mImageSetWnd = 0;
00214         mImSetIdxGrid = 0;
00215         if (!options.GetBool("annoPunsIdxGrid",false))
00216         {
00217             mShowNextFrom = new ShowNextFromControl(this, 350, 20, mNrToShow);
00218             mShowNextFrom->SetListener(this);
00219             mImageSetWnd = new Visualization::ImageSet(this,imW,imH,1.,7,5);
00220             mImageSetWnd->SetImagesListener(this, 0);
00221             mImageSetWnd->ConnectTo(this);
00222         }
00223         else
00224         {
00225             mIdxGridTotalTxt = new OglGui::StaticText(this, 160, 20, "Total:");
00226             mIdxGridTotalTxt->SetAlign(oglLeftAlign);
00227             mImSetIdxGridScroller =
00228                 new ImageSetIdxGridScroller(this,2,2,w-4,h-60,7);
00229             mImSetIdxGrid = mImSetIdxGridScroller->ImSetIdxGrid();
00230             mImSetIdxGrid->SetImageSetIdxGridListener(this);
00231             mImSetIdxGrid->ShowDims(false);
00232             mImSetIdxGridScroller->ConnectTo(this);
00233             mNrToShow = 10000000;
00234         }
00235 
00236         AddDocListener(this);
00237     }
00238 
00239     VideoAnnotations*           mVideoAnnotations;
00240     std::vector<int>            mKeyframeVec;
00241     Core::ImageSet::ImageSet*   mKeyframeSet;
00242     Core::VideoSet::Keyframes*  mKeyframes;
00243 
00244     Visualization::ImageSet*    mImageSetWnd;
00245     ImageSetIdxGridScroller*    mImSetIdxGridScroller;
00246     ImageSetIdxGrid*            mImSetIdxGrid;
00247     OglGui::StaticText*         mIdxGridTotalTxt;
00248     SegmentationDocument*       mSegDoc;
00249 
00250     OglGui::TextArea*           mInfoText;
00251     OglGui::CheckBox*           mVideoCheckBox;
00252     PunsOnlyControl*            mPunsOnly;
00253     ShowNextFromControl*        mShowNextFrom;
00254     OglGui::TextArea*           mVideoText;
00255 
00256     int                         mStartIm;
00257     int                         mNrToShow;
00258 };
00259 
00260 } // namespace Visualization
00261 } // namespace Impala
00262 
00263 #endif

Generated on Fri Mar 19 09:31:48 2010 for ImpalaSrc by  doxygen 1.5.1