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

Grid.h

Go to the documentation of this file.
00001 #ifndef Impala_Core_Feature_Grid_h
00002 #define Impala_Core_Feature_Grid_h
00003 
00004 #include "Basis/String.h"
00005 #include "Core/Database/RawDataSet.h"
00006 #include "Core/Feature/FeatureDefinition.h"
00007 
00008 // comment this line when commit to impala
00009 //#define __BITMAP_FUNC__
00010 
00011 #ifdef __BITMAP_FUNC__
00012 #include "Core/Feature/Bitmap.h"
00013 #endif
00014 
00015 namespace Impala
00016 {
00017 namespace Core
00018 {
00019 namespace Feature
00020 {
00021 
00022 
00023 class Grid
00024 {
00025 public:
00026 
00027     Grid()
00028     {
00029     }
00030 
00031     Grid(int nRow, int nCol)
00032     {
00033         mRow = nRow;
00034         mCol = nCol;
00035     }
00036     
00037     ~Grid()
00038     {
00039     }
00040 
00041     String
00042     GetName() const
00043     {
00044         return mName;
00045     }
00046 
00047     // have verified for 2x2, 4x4, 2x4, 4x2, 
00048     // not yet: 3x3
00049     void
00050     RetrievalGridBuffers(BYTE* im, BYTE** buf_list, int nWidth, int nHeight)
00051     {
00052 
00053 #ifdef __BITMAP_FUNC__
00054         Core::Feature::Bitmap bitmap;
00055         bitmap.SaveRgb2BitmapFile("rgb_00.bmp", im, nWidth, nHeight);
00056 #endif
00057 
00058         //--------------
00059         //   1   |   2
00060         //--------------
00061         //   3   |   4
00062         //--------------
00063         for (int x=0; x<mRow; x++)
00064         {
00065             for (int y=0; y<mCol; y++)
00066             {
00067                 int nFrameWidth = nWidth;
00068                 int nFrameHeight = nHeight;
00069 
00070                 int nGridWidth = nWidth/mCol;
00071                 int nGridHeight = nHeight/mRow;
00072 
00073                 int idx = y+x*mCol;
00074 
00075                 BYTE* cur_buf = buf_list[idx];
00076                 // process each row of the buffer
00077                 for (int j=0; j<nGridHeight; j++)
00078                 {
00079                     int nCurSize = nGridWidth*3*sizeof(BYTE);
00080 
00081                     //memcpy(cur_buf + j*nGridWidth*3, im + j*nFrameWidth*3, nCurSize);
00082                     BYTE* dst = cur_buf + j*nGridWidth*3;
00083                     //BYTE* src = im + j*nFrameWidth*3 + (nGridWidth*3*y+x*nGridWidth*nGridHeight*3*2);
00084                     int nFrameRowOffset1 = (nGridHeight * x) * nFrameWidth * 3; // three entry points
00085                     int nFrameRowOffset2 = j * nFrameWidth * 3;                 // within one grid row
00086                     int nFrameColOffset = nGridWidth * y * 3;                   // in column dimension   
00087                     
00088                     int nOffset = nFrameRowOffset1 + nFrameRowOffset2 + nFrameColOffset;
00089                     BYTE* src = im + nOffset;
00090                     memcpy(dst, src, nCurSize);
00091                 }
00092 
00093                 //verificatiion of the buffers
00094 #ifdef __BITMAP_FUNC__
00095                 String fileName, idxStr;
00096                 char index[128];
00097                 itoa(idx+1,index,10);
00098                 idxStr = index;
00099                 fileName = "rgb_grid_0" + idxStr + ".bmp";
00100 
00101                 Core::Feature::Bitmap bitmap;
00102                 bitmap.SaveRgb2BitmapFile(fileName.c_str(), cur_buf, nGridWidth, nGridHeight);
00103 #endif
00104             }
00105         }
00106 
00107     }
00108 
00109 
00110 private:
00111 
00112     String                mName;
00113     int                   mRow;
00114     int                   mCol;
00115 
00116 };
00117 
00118 } // namespace Feature
00119 } // namespace Core
00120 } // namespace Impala
00121 
00122 #endif

Generated on Fri Mar 19 09:31:06 2010 for ImpalaSrc by  doxygen 1.5.1