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

RegionsOfInterestCorrelation.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *
00003  * Application: An instance of this class may hold information on correlation
00004  *              of regions of interest for multiple frames of multiple video's.
00005  *              This implementation uses a description file as used by Thang
00006  *              Viet Pham on person detection.
00007  *
00008  * Primary author(s): Sander Kruseman
00009  ******************************************************************************/
00010 
00011 #ifndef Impala_Application_SDash_RegionsOfInterestCorrelation_h
00012 #define Impala_Application_SDash_RegionsOfInterestCorrelation_h
00013 
00014 #include <string>
00015 //#include <vector>
00016 //#include <map>
00017 
00018 #include "Util/IOBuffer.h"
00019 #include "Util/IOBufferFile.h"
00020 
00021 //#include "Core/Geometry/Rectangle.h"
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         //const std::vector<Visualization::Video>& videos, 
00049         const RegionsOfInterestInfo& roiInfos) 
00050     {
00051         std::cout << "reading regions of interest correlation from " << roiCorrFile << std::endl;
00052 
00053         // calculate start position per video
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; // bytes per roi
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             //int insertPos = 0;
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                 //RoiInfo roiInfo = roiInfos.GetRoiInfo(matchedRoiNr);
00079                 //if (true)
00080                 //if (roiInfo.videoId >= 0 && !videos[roiInfo.videoId].IsMovement(roiInfo.frameNr))
00081                 //{
00082                     //mValues[roi][index] = (unsigned short) ((unsigned short) bytes[pos] * 256);
00083                     //mValues[roi][index] += (unsigned short) bytes[pos + 1];
00084                     //mValues[roi][insertPos] = (unsigned short) matchedRoiNr;
00085                     mValues[roi][matchedRoi] = (unsigned short) matchedRoiNr;
00086                     //insertPos++;
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 }; //class RegionsOfInterestCorrelation
00109 
00110 } // namespace SDash
00111 } // namespace Application
00112 } // namespace Impala
00113 
00114 #endif

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