00001 #ifndef Impala_Core_VideoSet_TestBlocksFile_h
00002 #define Impala_Core_VideoSet_TestBlocksFile_h
00003
00004 #include "Core/VideoSet/Reporter.h"
00005 #include "Core/VideoSet/Segmentation.h"
00006
00007 namespace Impala
00008 {
00009 namespace Core
00010 {
00011 namespace VideoSet
00012 {
00013
00014
00015 class TestBlocksFile : public Listener
00016 {
00017 public:
00018
00019 TestBlocksFile(Reporter* reporter)
00020 {
00021 mReporter = reporter;
00022 }
00023
00024 virtual void
00025 HandleNewWalk(VideoSet* vs)
00026 {
00027 mSegmentation = new Segmentation(vs, "segmentation");
00028 }
00029
00030 virtual void
00031 HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00032 {
00033 String fName = vs->GetFilePathMetaData(fileId, "", true, ".blocks",
00034 false, false);
00035 ILOG_INFO("Checking " << fName);
00036 File shots(fName, "r");
00037 if (!shots.Valid())
00038 {
00039 ILOG_ERROR("couldn't find " << fName);
00040 return;
00041 }
00042 int firstShot = mSegmentation->GetFirstShotVideo(fileId);
00043 int nrShots = mSegmentation->GetNrShotsVideo(fileId);
00044
00045 int i = 0;
00046 while (! shots.Eof())
00047 {
00048
00049 String line = shots.ReadLine(true);
00050 if (! line[0])
00051 continue;
00052 Util::StringParser p(line);
00053 if (p.GetInt() != mSegmentation->GetStart(firstShot + i))
00054 {
00055 ILOG_ERROR("start didn't match in shot " << i+1);
00056 }
00057 if (p.GetInt() != mSegmentation->GetEnd(firstShot + i))
00058 {
00059 ILOG_ERROR("end didn't match in shot " << i+1);
00060 }
00061 if (p.GetString() != mSegmentation->GetName(firstShot + i))
00062 {
00063 ILOG_ERROR("name didn't match in shot " << i+1);
00064 }
00065 i++;
00066 }
00067 if (i != nrShots)
00068 {
00069 ILOG_ERROR("nr shots didn't match in " << fName);
00070 }
00071 }
00072
00073 private:
00074
00075 Reporter* mReporter;
00076 Segmentation* mSegmentation;
00077
00078 ILOG_VAR_DEC;
00079
00080 };
00081
00082 ILOG_VAR_INIT(TestBlocksFile, Impala.Core.VideoSet);
00083
00084 }
00085 }
00086 }
00087
00088 #endif