Definition at line 40 of file RegionsOfInterestInfo.h. References Impala::Core::Geometry::Rectangle::Height(), Impala::Core::Geometry::Rectangle::mBottom, mFrameHeight, Impala::Core::Geometry::Rectangle::mLeft, mNrOfVideos, Impala::Core::Geometry::Rectangle::mRight, mRoiCountPerVideo, mRois, Impala::Core::Geometry::Rectangle::mTop, Impala::Util::IOBufferFile::Read(), ROI_INFO_COUNT, Impala::Util::IOBufferFile::SetPosition(), and Impala::Core::Geometry::Rectangle::Width(). 00045 : 00046 mNrOfVideos(nrOfVideosToCollectRoisFor), 00047 mFrameWidth(ROI_FRAME_WIDTH), 00048 mFrameHeight(ROI_FRAME_HEIGHT) 00049 { 00050 std::cout << "reading regions of interest info from " << roiInfoFile << std::endl; 00051 00052 // create an empty map for every video; 00053 // silly impl; should add maps on the fly 00054 for (int v = 0; v < mNrOfVideos; v++) 00055 { 00056 mRois.push_back(std::map< int, std::vector<Rectangle> >()); 00057 mRoiCountPerVideo[v] = 0; 00058 } 00059 00060 const bool readOnly = true; 00061 const bool readIntoMem = false; 00062 Util::IOBufferFile ioBuffer(roiInfoFile, readOnly, readIntoMem); 00063 const int REC_SIZE = 6172; // record size for detected person information 00064 00065 // limitation of metadata to store: 00066 //static const float ESTIMATED_FPS = 2.6f; // SK: to be on the safe side 00067 //static const int ESTIMATED_FPM = (int) (ESTIMATED_FPS * 60.0f); 00068 //static const int MAX_FRAME_NR = MAX_MINUTES_OF_VIDEO * ESTIMATED_FPM; 00069 //int maxFrameNr = videoLengthSecs * ESTIMATED_FPM; 00070 //int maxFrameNr = videoLengthSecs * ESTIMATED_FPS; 00071 00072 unsigned char byteBuffer[REC_SIZE]; 00073 long position = 0; 00074 for (int i = 0; i < ROI_INFO_COUNT; i++) 00075 { 00076 const int bytesOfInterest = REC_SIZE; 00077 ioBuffer.SetPosition(position); 00078 int bytesRead = ioBuffer.Read(byteBuffer, bytesOfInterest); 00079 if (bytesRead < bytesOfInterest) 00080 throw std::logic_error("unable to read complete roi info record "); 00081 00082 int video = byteBuffer[2] * 256 + byteBuffer[3]; 00083 int frame = byteBuffer[6] * 256 + byteBuffer[7] - 1; 00084 00085 //if (video < nrOfVideosToCollectRoisFor && frame <= MAX_FRAME_NR) 00086 if (video < nrOfVideosToCollectRoisFor && frame <= maxFrames[video]) 00087 { 00088 int top = byteBuffer[10] * 256 + byteBuffer[11]; 00089 int left = byteBuffer[14] * 256 + byteBuffer[15]; 00090 int bottom = byteBuffer[18] * 256 + byteBuffer[19]; 00091 int right = byteBuffer[22] * 256 + byteBuffer[23]; 00092 Rectangle region(left, top, right, bottom); 00093 00094 if (makeSizesEven) 00095 { 00096 int origWidth = region.Width(); 00097 int origHeight= region.Height(); 00098 00099 if (origWidth % 2 != 0) 00100 { 00101 region.mRight -= 1; 00102 region.mBottom = region.mTop + (2 * region.Width()) - 1; 00103 } 00104 else if (origHeight % 4 != 0) 00105 { 00106 region.mBottom -= origHeight % 4; 00107 region.mRight = region.mLeft + (region.Height() / 2) - 1; 00108 } 00109 00110 //int newWidth = region.Width(); 00111 //int newHeight= region.Height(); 00112 } 00113 00114 if (invertYaxis) 00115 { 00116 int topUpward = mFrameHeight - region.mBottom - 1; 00117 int bottomUpward = mFrameHeight - region.mTop - 1; 00118 region.mTop = topUpward; 00119 region.mBottom = bottomUpward; 00120 } 00121 00122 std::map<int, std::vector<Rectangle> >& roisInVideo = mRois[video]; 00123 std::vector<Rectangle>& roisInFrame = roisInVideo[frame]; 00124 roisInFrame.push_back(region); 00125 } 00126 00127 mRoiCountPerVideo[video] += 1; 00128 position += REC_SIZE; 00129 } 00130 00131 std::cout << "finished reading regions of interest info" << std::endl; 00132 }
Here is the call graph for this function:
|