00001
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef VL_DSIFT_H
00014 #define VL_DSIFT_H
00015
00016 #include "generic.h"
00017
00019 typedef struct VlDsiftKeypoint_
00020 {
00021 double x ;
00022 double y ;
00023 double s ;
00024 double norm ;
00025 } VlDsiftKeypoint ;
00026
00028 typedef struct VlDsiftDescriptorGeometry_
00029 {
00030 int numBinT ;
00031 int numBinX ;
00032 int numBinY ;
00033 int binSizeX ;
00034 int binSizeY ;
00035 } VlDsiftDescriptorGeometry ;
00036
00038 typedef struct VlDsiftFilter_
00039 {
00040 int imWidth ;
00041 int imHeight ;
00043 int stepX ;
00044 int stepY ;
00046 int boundMinX ;
00047 int boundMinY ;
00048 int boundMaxX ;
00049 int boundMaxY ;
00052 VlDsiftDescriptorGeometry geom ;
00053
00054 int useFlatWindow ;
00056 int numFrames ;
00057 int descrSize ;
00058 VlDsiftKeypoint *frames ;
00059 float *descrs ;
00061 int numBinAlloc ;
00062 int numFrameAlloc ;
00063 int numGradAlloc ;
00065 float **grads ;
00066 float *convTmp1 ;
00067 float *convTmp2 ;
00068 } VlDsiftFilter ;
00069
00070 VL_EXPORT VlDsiftFilter *vl_dsift_new (int width, int height) ;
00071 VL_EXPORT VlDsiftFilter *vl_dsift_new_basic (int width, int height, int step, int binSize) ;
00072 VL_EXPORT void vl_dsift_delete (VlDsiftFilter *self) ;
00073 VL_EXPORT void vl_dsift_process (VlDsiftFilter *self, float const* im) ;
00074 VL_INLINE void vl_dsift_transpose_descriptor (float* dst,
00075 float const* src,
00076 int numBinT,
00077 int numBinX,
00078 int numBinY) ;
00079
00083 VL_INLINE void vl_dsift_set_steps (VlDsiftFilter *self,
00084 int stepX,
00085 int stepY) ;
00086 VL_INLINE void vl_dsift_set_bounds (VlDsiftFilter *self,
00087 int minX,
00088 int minY,
00089 int maxX,
00090 int maxY) ;
00091 VL_INLINE void vl_dsift_set_geometry (VlDsiftFilter *self,
00092 VlDsiftDescriptorGeometry const* geom) ;
00093 VL_INLINE void vl_dsift_set_flat_window (VlDsiftFilter *self, vl_bool flatWindow) ;
00099 VL_INLINE float const *vl_dsift_get_descriptors (VlDsiftFilter const *self) ;
00100 VL_INLINE int vl_dsift_get_descriptor_size (VlDsiftFilter const *self) ;
00101 VL_INLINE int vl_dsift_get_keypoint_num (VlDsiftFilter const *self) ;
00102 VL_INLINE VlDsiftKeypoint const *vl_dsift_get_keypoints (VlDsiftFilter const *self) ;
00103 VL_INLINE void vl_dsift_get_bounds (VlDsiftFilter const *self,
00104 int* minX,
00105 int* minY,
00106 int* maxX,
00107 int* maxY) ;
00108 VL_INLINE void vl_dsift_get_steps (VlDsiftFilter const*self,
00109 int* stepX,
00110 int* stepY) ;
00111 VL_INLINE VlDsiftDescriptorGeometry const* vl_dsift_get_geometry (VlDsiftFilter const *self) ;
00112 VL_INLINE vl_bool vl_dsift_get_flat_window (VlDsiftFilter const *self) ;
00115 VL_EXPORT
00116 void _vl_dsift_update_buffers (VlDsiftFilter *self) ;
00117
00124 int
00125 vl_dsift_get_descriptor_size (VlDsiftFilter const *self)
00126 {
00127 return self->descrSize ;
00128 }
00129
00136 float const *
00137 vl_dsift_get_descriptors (VlDsiftFilter const *self)
00138 {
00139 return self->descrs ;
00140 }
00141
00147 VlDsiftKeypoint const *
00148 vl_dsift_get_keypoints (VlDsiftFilter const *self)
00149 {
00150 return self->frames ;
00151 }
00152
00158 int
00159 vl_dsift_get_keypoint_num (VlDsiftFilter const *self)
00160 {
00161 return self->numFrames ;
00162 }
00163
00174 VlDsiftDescriptorGeometry const* vl_dsift_get_geometry (VlDsiftFilter const *self)
00175 {
00176 return &self->geom ;
00177 }
00178
00188 void
00189 vl_dsift_get_bounds (VlDsiftFilter const* self,
00190 int *minX, int *minY, int *maxX, int *maxY)
00191 {
00192 *minX = self->boundMinX ;
00193 *minY = self->boundMinY ;
00194 *maxX = self->boundMaxX ;
00195 *maxY = self->boundMaxY ;
00196 }
00197
00204 int
00205 vl_dsift_get_flat_window (VlDsiftFilter const* self)
00206 {
00207 return self->useFlatWindow ;
00208 }
00209
00217 void
00218 vl_dsift_get_steps (VlDsiftFilter const* self,
00219 int* stepX,
00220 int* stepY)
00221 {
00222 *stepX = self->stepX ;
00223 *stepY = self->stepY ;
00224 }
00225
00233 void
00234 vl_dsift_set_steps (VlDsiftFilter* self,
00235 int stepX,
00236 int stepY)
00237 {
00238 self->stepX = stepX ;
00239 self->stepY = stepY ;
00240 _vl_dsift_update_buffers(self) ;
00241 }
00242
00252 void
00253 vl_dsift_set_bounds (VlDsiftFilter* self,
00254 int minX, int minY, int maxX, int maxY)
00255 {
00256 self->boundMinX = minX ;
00257 self->boundMinY = minY ;
00258 self->boundMaxX = maxX ;
00259 self->boundMaxY = maxY ;
00260 _vl_dsift_update_buffers(self) ;
00261 }
00262
00269 void
00270 vl_dsift_set_geometry (VlDsiftFilter *self,
00271 VlDsiftDescriptorGeometry const *geom)
00272 {
00273 self->geom = *geom ;
00274 _vl_dsift_update_buffers(self) ;
00275 }
00276
00283 void
00284 vl_dsift_set_flat_window (VlDsiftFilter* self,
00285 int useFlatWindow)
00286 {
00287 self->useFlatWindow = useFlatWindow ;
00288 }
00289
00305 VL_INLINE void
00306 vl_dsift_transpose_descriptor (float* dst,
00307 float const* src,
00308 int numBinT,
00309 int numBinX,
00310 int numBinY)
00311 {
00312 int t, x, y ;
00313
00314 for (y = 0 ; y < numBinY ; ++y) {
00315 for (x = 0 ; x < numBinX ; ++x) {
00316 int offset = numBinT * (x + y * numBinX) ;
00317 int offsetT = numBinT * (y + x * numBinY) ;
00318
00319 for (t = 0 ; t < numBinT ; ++t) {
00320 int tT = numBinT / 4 - t ;
00321 dst [offsetT + (tT + numBinT) % numBinT] = src [offset + t] ;
00322 }
00323 }
00324 }
00325 }
00326
00327
00328 #endif