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

ExportFrameHashes.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_VideoSet_ExportFrameHashes_h
00002 #define Impala_Core_VideoSet_ExportFrameHashes_h
00003 
00004 #include "Core/Array/ImageArchiveMemory.h"
00005 #include "Core/Array/WritePng.h"
00006 #include "Core/Array/WriteJpg.h"
00007 #include "Core/Array/Scale.h"
00008 
00009 #include "Util/IOBufferFile.h"
00010 
00011 #include "Core/Table/TableTem.h"
00012 
00013 #include "Persistency/FrameHashesRepository.h"
00014 
00015 #include "Core/VideoSet/Reporter.h"
00016 
00017 
00018 namespace Impala
00019 {
00020 namespace Core
00021 {
00022 namespace VideoSet
00023 {
00024 
00025 
00026 class ExportFrameHashes : public Listener
00027 {
00028 
00029 private:
00030 
00031 public:
00032 
00033     typedef Column::FixedStringColumn::ColElemType FixedString;
00034 
00035     ExportFrameHashes(Reporter* reporter, CmdOptions& options)
00036     {
00037         mReporter = reporter;
00038         mFrameHashes = 0;
00039     }
00040 
00041     virtual
00042     ~ExportFrameHashes()
00043     {
00044         if (mFrameHashes)
00045             delete mFrameHashes;
00046     }
00047 
00048     virtual void
00049     HandleNewFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00050     {
00051         mFrameHashes = 
00052             new FrameHashes(Column::ColumnTem<Int32>(1),
00053                             Column::FixedStringColumn(src->HASH_SIZE, 1),
00054                             Column::FixedStringColumn(src->HASH_SIZE, 1));
00055     }
00056 
00057     virtual void
00058     HandleNewFrame(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00059     {
00060         const int frameNr = src->FrameNr();
00061         String hashPre = src->FrameHashBeforeConversion();
00062         String hashPost = src->FrameHash();
00063         ILOG_DEBUG(frameNr << ": " << hashPre << " - " << hashPost);
00064         const FixedString hashPreFixed(src->HASH_SIZE, 
00065                                        (char*) hashPre.c_str(), true);
00066         const FixedString hashPostFixed(src->HASH_SIZE, 
00067                                         (char*) hashPost.c_str(), true);
00068         mFrameHashes->Add(frameNr, hashPreFixed, hashPostFixed);
00069     }
00070 
00071     virtual void
00072     HandleDoneFile(VideoSet* vs, int fileId, Stream::RgbDataSrc* src)
00073     {
00074 #ifndef REPOSITORY_USED // Here comes the deprecated stuff
00075         String videoName = vs->GetFile(fileId);
00076         bool toWrite = true;
00077         bool silent = true;
00078         String fileName = "hashes.tab";
00079         String filePath = vs->GetFilePathFrames(fileId, fileName, toWrite, 
00080                                                 silent);
00081         bool readMode = false;
00082         bool useMem = false;
00083         Util::Database* db = vs->GetDatabase();
00084         Util::IOBuffer* buffer = db->GetIOBuffer(filePath, readMode, useMem, 
00085                                                  "tmp");
00086         bool binary = true;
00087         Core::Table::Write(mFrameHashes, buffer, binary);
00088         delete buffer;
00089 #else // REPOSITORY_USED
00090         String container = vs->GetContainer(fileId);
00091         Persistency::FrameHashesLocator loc(vs->GetLocator(), container);
00092         Persistency::FrameHashesRepository().Add(loc, mFrameHashes);
00093 #endif // REPOSITORY_USED
00094         delete mFrameHashes;
00095         mFrameHashes = 0;
00096     }
00097 
00098 private:
00099 
00100     Reporter* mReporter;
00101 
00102     FrameHashes* mFrameHashes;
00103 
00104     ILOG_VAR_DEC;
00105 };
00106 
00107 ILOG_VAR_INIT(ExportFrameHashes, Impala.Core.VideoSet);
00108 
00109 } // namespace VideoSet
00110 } // namespace Core
00111 } // namespace Impala
00112 
00113 #endif

Generated on Thu Jan 13 09:04:45 2011 for ImpalaSrc by  doxygen 1.5.1