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 #include "Core/VideoSet/VideoSet.h"
00008 #include "Core/Array/WritePng.h"
00009
00010
00011
00012
00013 #ifdef __BITMAP_FUNC__
00014 #include "Core/Feature/Bitmap.h"
00015 #endif
00016
00017 #ifndef BYTE
00018 #define BYTE unsigned char
00019 #endif
00020
00021 #ifndef BOOL
00022 #define BOOL bool
00023 #endif
00024
00025 #ifndef UINT
00026 #define UINT unsigned int
00027 #endif
00028
00029
00030 namespace Impala
00031 {
00032 namespace Core
00033 {
00034 namespace Feature
00035 {
00036
00037
00038 class Grid
00039 {
00040 public:
00041
00042 Grid()
00043 {
00044 }
00045
00046 Grid(int nRow, int nCol)
00047 {
00048 mRow = nRow;
00049 mCol = nCol;
00050 }
00051
00052 ~Grid()
00053 {
00054 }
00055
00056 String
00057 GetName() const
00058 {
00059 return mName;
00060 }
00061
00062
00063
00064 void
00065 RetrievalGridBuffers(BYTE* im, BYTE** buf_list, int nWidth, int nHeight, Core::VideoSet::VideoSet* vs = NULL)
00066 {
00067 String fileName;
00068
00069 #ifdef __BITMAP_FUNC__
00070
00071
00072
00073 Array::Array2dVec3UInt8* buf = Array::ArrayCreate<Array::Array2dVec3UInt8>
00074 (nWidth, nHeight, 0, 0, im, true);
00075 fileName = "rgb_00.png";
00076 Core::Array::WritePng(buf, fileName, vs->GetDatabase());
00077 #endif
00078
00079
00080
00081
00082
00083
00084 for (int x=0; x<mRow; x++)
00085 {
00086 for (int y=0; y<mCol; y++)
00087 {
00088 int nFrameWidth = nWidth;
00089 int nFrameHeight = nHeight;
00090
00091 int nGridWidth = nWidth/mCol;
00092 int nGridHeight = nHeight/mRow;
00093
00094 int idx = y+x*mCol;
00095
00096 BYTE* cur_buf = buf_list[idx];
00097
00098 for (int j=0; j<nGridHeight; j++)
00099 {
00100 int nCurSize = nGridWidth*3*sizeof(BYTE);
00101
00102
00103 BYTE* dst = cur_buf + j*nGridWidth*3;
00104
00105 int nFrameRowOffset1 = (nGridHeight * x) * nFrameWidth * 3;
00106 int nFrameRowOffset2 = j * nFrameWidth * 3;
00107 int nFrameColOffset = nGridWidth * y * 3;
00108
00109 int nOffset = nFrameRowOffset1 + nFrameRowOffset2 + nFrameColOffset;
00110 BYTE* src = im + nOffset;
00111 memcpy(dst, src, nCurSize);
00112 }
00113
00114
00115 #ifdef __BITMAP_FUNC__
00116 String idxStr;
00117 char index[128];
00118 itoa(idx+1,index,10);
00119 idxStr = index;
00120 fileName = "rgb_grid_0" + idxStr + ".bmp";
00121
00122
00123
00124
00125 Array::Array2dVec3UInt8* sc = Array::ArrayCreate<Array::Array2dVec3UInt8>
00126 (nGridWidth, nGridHeight, 0, 0, cur_buf, true);
00127 fileName = "rgb_grid_0" + idxStr + ".png";
00128 Core::Array::WritePng(sc, fileName, vs->GetDatabase());
00129 #endif
00130 }
00131 }
00132
00133 }
00134
00135
00136 private:
00137
00138 String mName;
00139 int mRow;
00140 int mCol;
00141
00142 };
00143
00144 }
00145 }
00146 }
00147
00148 #endif