00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef Impala_Application_SDash_RegionsOfInterestCorrelation_h
00012 #define Impala_Application_SDash_RegionsOfInterestCorrelation_h
00013
00014 #include <string>
00015
00016
00017
00018 #include "Util/IOBuffer.h"
00019 #include "Util/IOBufferFile.h"
00020
00021
00022
00023 #include "Application/sdash/RegionsOfInterestInfo.h"
00024
00025 namespace Impala
00026 {
00027 namespace Application
00028 {
00029 namespace SDash
00030 {
00031
00032 static const int NR_OF_VIDEOS = 12;
00033
00034 static const int CORRELATED_PER_ROI = 1000;
00035
00036 static const int ROI_COUNT = 33494;
00037 static const int INPUT_VALUES_PER_ROI = 1000;
00038 static const int BYTES_PER_CORR = 2;
00039
00040 static const int ROIS_PER_VIDEO[NR_OF_VIDEOS] = {2472, 452, 3473, 2921, 653, 4147, 3328, 4542, 25, 4707, 3794, 2980};
00041
00042 class RegionsOfInterestCorrelation {
00043
00044 public:
00045
00046 RegionsOfInterestCorrelation(
00047 std::string roiCorrFile,
00048
00049 const RegionsOfInterestInfo& roiInfos)
00050 {
00051 std::cout << "reading regions of interest correlation from " << roiCorrFile << std::endl;
00052
00053
00054 firstRoiPosPerVideo[0] = 0;
00055 for (int i = 1; i < NR_OF_VIDEOS; i++)
00056 firstRoiPosPerVideo[i] = firstRoiPosPerVideo[i - 1] + ROIS_PER_VIDEO[i];
00057
00058 static const int REC_SIZE = INPUT_VALUES_PER_ROI * 2;
00059 unsigned char bytes[REC_SIZE];
00060
00061 const bool readOnly = true;
00062 const bool readIntoMem = false;
00063 Util::IOBufferFile ioBuffer(roiCorrFile, readOnly, readIntoMem);
00064
00065 int pos = 0;
00066 int loByte = 1;
00067 for (int roi = 0; roi < ROI_COUNT; roi++)
00068 {
00069 int bytesRead = ioBuffer.Read(bytes, REC_SIZE);
00070 if (bytesRead < REC_SIZE)
00071 throw std::logic_error("unable to read complete roi correlation record ");
00072
00073
00074 for (int matchedRoi = 0; matchedRoi < CORRELATED_PER_ROI; matchedRoi++)
00075 {
00076 int pos = matchedRoi * 2;
00077 int matchedRoiNr = bytes[pos] * 256 + bytes[pos + 1];
00078
00079
00080
00081
00082
00083
00084
00085 mValues[roi][matchedRoi] = (unsigned short) matchedRoiNr;
00086
00087
00088 }
00089 }
00090
00091 std::cout << "finished reading regions of interest correlation" << std::endl;
00092 }
00093
00094 ~RegionsOfInterestCorrelation()
00095 {
00096 }
00097
00098 const unsigned short* const GetAllCorrelated(int absRoiNr) const
00099 {
00100 return (mValues[absRoiNr]);
00101 }
00102
00103 private:
00104
00105 int firstRoiPosPerVideo[NR_OF_VIDEOS];
00106 unsigned short mValues[ROI_COUNT][CORRELATED_PER_ROI];
00107
00108 };
00109
00110 }
00111 }
00112 }
00113
00114 #endif