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

IndexSegmentation.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_IndexSegmentation_h
00002 #define Impala_Core_VideoSet_IndexSegmentation_h
00003 
00004 #include "Persistency/SegmentationRepository.h"
00005 #include "Persistency/KeyframesRepository.h"
00006 #include "Persistency/Mpeg7DocRepository.h"
00007 #include "Core/VideoSet/Reporter.h"
00008 #include "Core/VideoSet/Segmentation.h"
00009 #include "Core/VideoSet/Keyframes.h"
00010 #include "Core/VideoSet/Mpeg7Doc.h"
00011 
00012 namespace Impala
00013 {
00014 namespace Core
00015 {
00016 namespace VideoSet
00017 {
00018 
00019 
00020 class IndexSegmentation : public Listener
00021 {
00022 public:
00023 
00024     IndexSegmentation(Reporter* reporter, CmdOptions& options)
00025     {
00026         mReporter = reporter;
00027     }
00028 
00029     virtual void
00030     HandleNewWalk(VideoSet* vs)
00031     {
00032         mSegmentation = new Segmentation(vs, "");
00033         mKeyframes = new Keyframes(vs, "");
00034     }
00035 
00036     virtual void
00037     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00038     {
00039 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00040         String fileName = vs->GetFile(fileId);
00041         String s = vs->GetFilePathMpeg7Shot(fileId, false, false);
00042         if (s.empty())
00043         {
00044             ILOG_ERROR("unable to find mpeg7 file for " << fileName);
00045             return;
00046         }
00047         Mpeg7Doc mp7(s, vs->GetDatabase());
00048         for (int s=0 ; s<mp7.NrShots() ; s++)
00049         {
00050             mSegmentation->Add(fileId, mp7.StartFrame(s), mp7.EndFrame(s),
00051                                mp7.ShotName(s));
00052             int shotId = mSegmentation->Size() - 1;
00053             for (int k=0 ; k<mp7.NrKeyframes(s) ; k++)
00054             {
00055                 String name = mp7.KeyframeName(s, k) + ".jpg";
00056                 mKeyframes->Add(fileId, shotId, mp7.KeyframeFrame(s, k), name);
00057             }
00058         }
00059 #else // REPOSITORY_USED
00060         String container = vs->GetContainerFile(fileId);
00061         String name = vs->GetFileBase(fileId) + ".xml";
00062         const int MPEG7_SHOT = Persistency::Mpeg7DocLocator::MPEG7_SHOT;
00063         Persistency::Mpeg7DocLocator loc(vs->GetLocator(), MPEG7_SHOT,
00064                                          container, name);
00065         Mpeg7Doc* mp7 = Persistency::Mpeg7DocRepository().Get(loc);
00066         for (int s=0 ; s<mp7->NrShots() ; s++)
00067         {
00068             mSegmentation->Add(fileId, mp7->StartFrame(s), mp7->EndFrame(s),
00069                                mp7->ShotName(s));
00070             int shotId = mSegmentation->Size() - 1;
00071             for (int k=0 ; k<mp7->NrKeyframes(s) ; k++)
00072             {
00073                 String name = mp7->KeyframeName(s, k) + ".jpg";
00074                 mKeyframes->Add(fileId, shotId, mp7->KeyframeFrame(s, k), name);
00075             }
00076         }
00077         delete mp7;
00078 #endif // REPOSITORY_USED
00079     }
00080 
00081     virtual void
00082     HandleDoneWalk(VideoSet* vs)
00083     {
00084         bool binary = true;
00085 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00086         mSegmentation->Save("segmentation", binary);
00087         mKeyframes->Save("keyframes", binary);
00088 #else // REPOSITORY_USED
00089         Persistency::SegmentationLocator sLoc(vs->GetLocator(), "segmentation");
00090         Persistency::SegmentationRepository().Add(sLoc, mSegmentation);
00091         Persistency::KeyframesLocator kLoc(vs->GetLocator(), "keyframes");
00092         Persistency::KeyframesRepository().Add(kLoc, mKeyframes);
00093 #endif // REPOSITORY_USED
00094         mKeyframes->WriteImageSets();
00095     }
00096 
00097 private:
00098 
00099     Reporter*     mReporter;
00100     Segmentation* mSegmentation;
00101     Keyframes*    mKeyframes;
00102 
00103     ILOG_VAR_DEC;
00104 
00105 };
00106 
00107 ILOG_VAR_INIT(IndexSegmentation, Impala.Core.VideoSet);
00108 
00109 } // namespace VideoSet
00110 } // namespace Core
00111 } // namespace Impala
00112 
00113 #endif

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