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

ReadBlocksFile.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_ReadBlocksFile_h
00002 #define Impala_Core_VideoSet_ReadBlocksFile_h
00003 
00004 #include "Core/VideoSet/Reporter.h"
00005 #include "Core/VideoSet/Segmentation.h"
00006 #include "Core/VideoSet/Keyframes.h"
00007 
00008 namespace Impala
00009 {
00010 namespace Core
00011 {
00012 namespace VideoSet
00013 {
00014 
00015 
00016 class ReadBlocksFile : public Listener
00017 {
00018 public:
00019 
00020     ReadBlocksFile(Reporter* reporter, CmdOptions& options)
00021     {
00022         mReporter = reporter;
00023         mCurShot = 0;
00024     }
00025 
00026     virtual void
00027     HandleNewWalk(VideoSet* vs)
00028     {
00029         mSegmentation = new Segmentation(vs, "");
00030         mKeyframes = new Keyframes(vs, "");
00031     }
00032 
00033     virtual void
00034     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00035     {
00036         // todo : this doesn't work anymore, but is also not needed anymore
00037         //std::string fName = vs->GetFilePathId("VideoMetaData", "", fileId, true,
00038         //                                      ".blocks", false);
00039         std::string fName("dummy");
00040         ILOG_DEBUG("Checking " << fName);
00041         File shots(fName, "r");
00042         if (!shots.Valid())
00043         {
00044             ILOG_ERROR("couldn't find " << fName);
00045             return;
00046         }
00047         int i = 1;
00048         while (! shots.Eof())
00049         {
00050             // start with shots file
00051             std::string line = shots.ReadLine(true);
00052             if (! line[0])
00053                 continue;
00054             Util::StringParser p(line);
00055             int startFrame = p.GetInt();
00056             int endFrame = p.GetInt();
00057             std::string name = p.GetString();
00058             mSegmentation->Add(fileId, startFrame, endFrame, name);
00059             mKeyframes->Add(fileId, mCurShot++, (startFrame+endFrame)/2,
00060                             name + "_RKF.jpg");
00061             i++;
00062         }
00063     }
00064 
00065     virtual void
00066     HandleDoneWalk(VideoSet* vs)
00067     {
00068         bool binary = true;
00069         mSegmentation->Save("segmentation", binary);
00070         mKeyframes->Save("keyframes", binary);
00071         mKeyframes->WriteImageSets();
00072     }
00073 
00074 private:
00075 
00076     Reporter*     mReporter;
00077     int           mCurShot;
00078     Segmentation* mSegmentation;
00079     Keyframes*    mKeyframes;
00080 
00081     ILOG_VAR_DEC;
00082 };
00083 
00084 ILOG_VAR_INIT(ReadBlocksFile, Core.VideoSet);
00085 
00086 } // namespace VideoSet
00087 } // namespace Core
00088 } // namespace Impala
00089 
00090 #endif

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