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

ActivityReader.h

Go to the documentation of this file.
00001 #ifndef Impala_Application_SDash_ActivityReader_h
00002 #define Impala_Application_SDash_ActivityReader_h
00003 
00004 #include <string>
00005 #include <map>
00006 #include <vector>
00007 
00008 #include "Basis/String.h"
00009 
00010 #include "Application/sdash/Sax2Reader.h"
00011 #include "Application/sdash/CameraEvent.h"
00012 #include "Application/sdash/ActivityHandler.h"
00013 
00014 namespace Impala {
00015 namespace Application {
00016 namespace SDash {
00017 
00018 class ActivityReader : public Sax2Reader
00019 {
00020 
00021 private:
00022 
00023     static const int ARGC;
00024     static const char* ARGV[];
00025     static const int SEQ_SIZES[];
00026 
00027 public:
00028 
00029     static const int FRAME_RATE;
00030     static const int EMPTY_SEQUENCE;
00031 
00032     ActivityReader() : Sax2Reader(ARGC, ARGV, new ActivityHandler())
00033     {
00034     }
00035 
00036     ActivityReader(int argC, const char* argV[]) : Sax2Reader(argC, argV, new ActivityHandler())
00037     {
00038     }
00039 
00040     virtual ~ActivityReader()
00041     {
00042     }
00043 
00044     static int TotalSequenceLength()
00045     {
00046         int len = 0;
00047 #ifdef RICHARD
00048         len = SEQ_SIZES[2];
00049 #else
00050         for (int i = 0; i < 3; i++)
00051         {
00052             len += EMPTY_SEQUENCE;
00053             len += SEQ_SIZES[i];
00054         }
00055 #endif
00056         return len;
00057     }
00058 
00059     // reads a file by a name that has yet to be constructed
00060     virtual int Read(const std::string& basePath, std::map<int, std::vector<CameraEvent> >& camEventSchedule)
00061     {
00062         ActivityHandler* handler = (ActivityHandler*) GetHandler();
00063         int nrOfEventsFound = 0;
00064         int totalNrOfFrames = 0;
00065         int eventOffset = 17 * TotalSequenceLength(); // SK: ca. 30 minutes
00066         char buf[2048];
00067 
00068         static std::string sequenceNames[] = {"argument", "gesticulation", "pickpocketing"};
00069         static int sequenceSizes[] = {232, 80, 179};
00070 
00071 #ifdef RICHARD
00072     for (int seq = 2; seq < 3; seq++)
00073 #else
00074     for (int seq = 0; seq < 3; seq++)
00075 #endif
00076     {
00077         std::string prevActivity = "";
00078         for (int frameNr = 0; frameNr < sequenceSizes[seq]; frameNr++)
00079         {
00080 #ifdef RICHARD
00081             sprintf(buf, "%sHAR_%03d.xml", basePath.c_str(), frameNr);
00082 #else
00083             sprintf(buf, "%s%s/HAR_output%03d.xml", basePath.c_str(), sequenceNames[seq].c_str(), frameNr);
00084 #endif
00085             mFileToRead = std::string(buf);
00086 
00087             int rc = Sax2Reader::Read();
00088             if (rc != 0)
00089                 return rc;
00090 
00091             const std::string& activity = handler->GetActivity();
00092             if (activity != prevActivity)
00093             {
00094                 if (activity != "walking" && activity != "standing")
00095                 {
00096                     int cumFrameNr = totalNrOfFrames + frameNr;
00097                     int eventTime = (eventOffset + cumFrameNr) / FRAME_RATE;
00098                     //int videoId = 14;
00099                     int videoId = 12 + ((totalNrOfFrames + frameNr) % 3) + 1;
00100                     camEventSchedule[eventTime].push_back(CameraEvent(videoId, 2, cumFrameNr, activity));
00101                     nrOfEventsFound++;
00102                 }
00103                 prevActivity = activity;
00104             }
00105         }
00106         totalNrOfFrames += sequenceSizes[seq];
00107 #ifndef RICHARD
00108         totalNrOfFrames += EMPTY_SEQUENCE;
00109 #endif
00110     }
00111 
00112         std::cout << "activity events found: " << nrOfEventsFound << " (in " << totalNrOfFrames << " frames)" << std::endl;
00113         return 0;
00114     }
00115 
00116 private:
00117 
00118 
00119 }; //class
00120 
00121 const char* ActivityReader::ARGV[] = {"-n", "-i", "-s", "-v=never", "dummy_value"};
00122 const int ActivityReader::ARGC = 5;
00123 const int ActivityReader::FRAME_RATE = 10;
00124 const int ActivityReader::EMPTY_SEQUENCE = 200; // SK: note that this value is duplicated in class Video
00125 const int ActivityReader::SEQ_SIZES[] = {232, 80, 179}; // SK: note that this value is duplicated in class Video
00126 
00127 }
00128 }
00129 }
00130 
00131 #endif

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