00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00026
00027
00028 #ifndef GPU_SIFT_H
00029 #define GPU_SIFT_H
00030
00031 #if defined(_WIN32)
00032 #ifdef SIFTGPU_DLL
00033 #ifdef DLL_EXPORT
00034 #define SIFTGPU_EXPORT __declspec(dllexport)
00035 #else
00036 #define SIFTGPU_EXPORT __declspec(dllimport)
00037 #endif
00038 #else
00039 #define SIFTGPU_EXPORT
00040 #endif
00041
00042 #define SIFTGPU_EXPORT_EXTERN SIFTGPU_EXPORT
00043
00044 #if _MSC_VER > 1000
00045 #pragma once
00046 #endif
00047 #else
00048 #define SIFTGPU_EXPORT
00049 #define SIFTGPU_EXPORT_EXTERN extern "C"
00050 #endif
00051
00053
00054
00056 class GlobalUtil;
00057 class SiftParam
00058 {
00059 public:
00060 float* _sigma;
00061 float _sigma_skip0;
00062 float _sigma_skip1;
00063
00064
00065 float _sigma0;
00066 float _sigman;
00067 int _sigma_num;
00068
00069
00070 int _dog_level_num;
00071 int _level_num;
00072
00073
00074 int _level_min;
00075 int _level_max;
00076 int _level_ds;
00077
00078 float _dog_threshold;
00079
00080 float _edge_threshold;
00081 void ParseSiftParam();
00082 public:
00083 float GetLevelSigma(int lev);
00084 float GetInitialSmoothSigma(int octave_min);
00085 SIFTGPU_EXPORT SiftParam();
00086 virtual ~SiftParam();
00087 };
00088
00089 class LiteWindow;
00090 class GLTexInput;
00091 class ShaderMan;
00092 class SiftPyramid;
00093 class ImageList;
00095
00096
00098 class SiftGPU:public SiftParam
00099 {
00100 public:
00101 enum
00102 {
00103 SIFTGPU_NOT_SUPPORTED = 0,
00104 SIFTGPU_PARTIAL_SUPPORTED = 1,
00105 SIFTGPU_FULL_SUPPORTED = 2
00106 };
00107 typedef struct SiftKeypoint
00108 {
00109 float x, y, s, o;
00110 }SiftKeypoint;
00111 protected:
00112
00113
00114 int _current;
00115
00116
00117
00118 int _initialized;
00119
00120 int _image_loaded;
00121
00122 char* _imgpath;
00123
00124 char* _outpath;
00125
00126 ImageList * _list;
00127
00128 GLTexInput * _texImage;
00129
00130 SiftPyramid * _pyramid;
00131
00132 static void PrintUsage();
00133
00134 void InitSiftGPU();
00135
00136 void LoadImageList(const char *imlist);
00137 public:
00138
00139 float _timing[10];
00140 inline const char* GetCurrentImagePath() {return _imgpath; }
00141 public:
00142
00143 SIFTGPU_EXPORT virtual void SetImageList(int nimage, const char** filelist);
00144
00145 SIFTGPU_EXPORT virtual int GetFeatureNum();
00146
00147 SIFTGPU_EXPORT virtual void SaveSIFT(const char * szFileName);
00148
00149 SIFTGPU_EXPORT virtual void GetFeatureVector(SiftKeypoint * keys, float * descriptors);
00150
00151 SIFTGPU_EXPORT virtual void SetKeypointList(int num, const SiftKeypoint * keys, int keys_have_orientation = 1);
00152
00153
00154
00155
00156 SIFTGPU_EXPORT virtual int CreateContextGL();
00157
00158
00159 SIFTGPU_EXPORT virtual int VerifyContextGL();
00160
00161 SIFTGPU_EXPORT virtual int IsFullSupported();
00162
00163 SIFTGPU_EXPORT virtual void SetVerbose(int verbose = 4);
00164
00165 inline void SetVerboseBrief(){SetVerbose(2);};
00166
00167 SIFTGPU_EXPORT virtual void ParseParam(int argc, char **argv);
00168
00169 SIFTGPU_EXPORT virtual int RunSIFT(const char * imgpath);
00170
00171 SIFTGPU_EXPORT virtual int RunSIFT(int index);
00172
00173
00174
00175
00176
00177 SIFTGPU_EXPORT virtual int RunSIFT(int width, int height, const void * data,
00178 unsigned int gl_format, unsigned int gl_type);
00179
00180 SIFTGPU_EXPORT virtual int RunSIFT();
00181
00182 SIFTGPU_EXPORT virtual int RunSIFT(int num, const SiftKeypoint * keys, int keys_have_orientation = 1);
00183
00184 SIFTGPU_EXPORT SiftGPU(int np = 1);
00185
00186 SIFTGPU_EXPORT virtual ~SiftGPU();
00187
00188 SIFTGPU_EXPORT virtual void SetActivePyramid(int index) {}
00189
00190 SIFTGPU_EXPORT virtual int GetImageCount();
00191
00192 SIFTGPU_EXPORT virtual void SetTightPyramid(int tight = 1);
00193
00194 SIFTGPU_EXPORT virtual int AllocatePyramid(int width, int height);
00195
00196
00197 SIFTGPU_EXPORT virtual void SetMaxDimension(int sz);
00199 public:
00200
00201
00202
00203
00204
00205 SIFTGPU_EXPORT void* operator new (size_t size);
00206 };
00207
00208
00209
00211
00212
00214
00215 class SiftGPUEX:public SiftGPU
00216 {
00217
00218 int _view;
00219
00220 int _sub_view;
00221
00222 int _view_debug;
00223
00224 enum{COLOR_NUM = 36};
00225 float _colors[COLOR_NUM*3];
00226
00227 void DisplayInput();
00228 void DisplayDebug();
00229 void DisplayFeatureBox(int i);
00230 void DisplayLevel(void (*UseDisplayShader)(), int i);
00231 void DisplayOctave(void (*UseDisplayShader)(), int i);
00232
00233
00234 void DisplayPyramid( void (*UseDisplayShader)(), int dataName, int nskip1 = 0, int nskip2 = 0);
00235
00236 static void HSVtoRGB(float hsv[3],float rgb[3]);
00237
00238 public:
00239 SIFTGPU_EXPORT SiftGPUEX();
00240
00241 SIFTGPU_EXPORT void SetView(int view, int sub_view, char * title);
00242
00243 SIFTGPU_EXPORT void DisplaySIFT();
00244
00245 SIFTGPU_EXPORT void ToggleDisplayDebug();
00246
00247 SIFTGPU_EXPORT void RandomizeColor();
00248
00249 SIFTGPU_EXPORT void GetImageDimension(int &w, int&h);
00250
00251 SIFTGPU_EXPORT void GetInitWindowPotition(int& x, int& y);
00252 };
00253
00255
00256 class SiftMatchGPU
00257 {
00258 public:
00259 enum SIFTMATCH_LANGUAGE {
00260 SIFTMATCH_SAME_AS_SIFTGPU = 0,
00261 SIFTMATCH_GLSL = 2,
00262 SIFTMATCH_CUDA = 3,
00263 SIFTMATCH_CUDA_DEVICE0 = 3
00264 };
00265 private:
00266 int __max_sift;
00267 int __language;
00268 SiftMatchGPU * __matcher;
00269 virtual void InitSiftMatch(){}
00270 protected:
00271
00272 SIFTGPU_EXPORT virtual int _CreateContextGL();
00273 SIFTGPU_EXPORT virtual int _VerifyContextGL();
00274 public:
00275
00276 inline int CreateContextGL() {return _CreateContextGL();}
00277 inline int VerifyContextGL() {return _VerifyContextGL();}
00278
00279
00280 SIFTGPU_EXPORT SiftMatchGPU(int max_sift = 4096);
00281
00282
00283 SIFTGPU_EXPORT virtual void SetLanguage(int gpu_language);
00284
00285
00286
00287
00288
00289 SIFTGPU_EXPORT virtual void SetDeviceParam(int argc, char**argv);
00290
00291
00292 SIFTGPU_EXPORT virtual void SetMaxSift(int max_sift);
00293
00294 SIFTGPU_EXPORT virtual ~SiftMatchGPU();
00295
00296
00297
00298 SIFTGPU_EXPORT virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1);
00299
00300 SIFTGPU_EXPORT virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1);
00301
00302
00303
00304 SIFTGPU_EXPORT virtual int GetSiftMatch(
00305 int max_match,
00306 int match_buffer[][2],
00307 float distmax = 0.7,
00308 float ratiomax = 0.8,
00309 int mutual_best_match = 1);
00310
00311
00312
00313
00314
00315
00316 SIFTGPU_EXPORT virtual void SetFeautreLocation(int index, const float* locations, int gap = 0);
00317 inline void SetFeatureLocation(int index, const SiftGPU::SiftKeypoint * keys)
00318 {
00319 SetFeautreLocation(index, (const float*) keys, 2);
00320 }
00321
00322
00323
00324 SIFTGPU_EXPORT virtual int GetGuidedSiftMatch(
00325 int max_match, int match_buffer[][2],
00326 float H[3][3],
00327 float F[3][3],
00328 float distmax = 0.7,
00329 float ratiomax = 0.8,
00330 float hdistmax = 32,
00331 float fdistmax = 16,
00332 int mutual_best_match = 1);
00333
00334 public:
00335
00336 SIFTGPU_EXPORT void* operator new (size_t size);
00337 };
00338
00339 typedef SiftGPU::SiftKeypoint SiftKeypoint;
00340
00341
00342 SIFTGPU_EXPORT_EXTERN SiftGPU * CreateNewSiftGPU(int np =1);
00343 SIFTGPU_EXPORT_EXTERN SiftMatchGPU* CreateNewSiftMatchGPU(int max_sift = 4096);
00344
00345
00347 class ComboSiftGPU: public SiftGPU, public SiftMatchGPU
00348 {
00349 public:
00351 SIFTGPU_EXPORT void* operator new (size_t size);
00352 };
00353 SIFTGPU_EXPORT_EXTERN ComboSiftGPU* CreateComboSiftGPU();
00354
00356
00357 SIFTGPU_EXPORT_EXTERN ComboSiftGPU* CreateRemoteSiftGPU(int port = 7777, char* remote_server = NULL);
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375
00377
00378 SIFTGPU_EXPORT int CreateLiteWindow(LiteWindow* window);
00379 SIFTGPU_EXPORT void RunServerLoop(int port, int argc, char** argv);
00380 #endif