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 };
00087
00088 class LiteWindow;
00089 class GLTexInput;
00090 class ShaderMan;
00091 class SiftPyramid;
00092 class ImageList;
00094
00095
00097 class SiftGPU:public SiftParam
00098 {
00099 public:
00100 enum
00101 {
00102 SIFTGPU_NOT_SUPPORTED = 0,
00103 SIFTGPU_PARTIAL_SUPPORTED = 1,
00104 SIFTGPU_FULL_SUPPORTED = 2
00105 };
00106 typedef struct SiftKeypoint
00107 {
00108 float x, y, s, o;
00109 }SiftKeypoint;
00110 protected:
00111
00112
00113 int _current;
00114
00115
00116
00117 int _initialized;
00118
00119 int _image_loaded;
00120
00121 char* _imgpath;
00122
00123 char* _outpath;
00124
00125 ImageList * _list;
00126
00127 GLTexInput * _texImage;
00128
00129 SiftPyramid * _pyramid;
00130
00131 static void PrintUsage();
00132
00133 void InitSiftGPU();
00134
00135 void LoadImageList(char *imlist);
00136 public:
00137
00138 float _timing[10];
00139 inline const char* GetCurrentImagePath() {return _imgpath; }
00140 public:
00141
00142 SIFTGPU_EXPORT virtual void SetImageList(int nimage, const char** filelist);
00143
00144 SIFTGPU_EXPORT virtual int GetFeatureNum();
00145
00146 SIFTGPU_EXPORT virtual void SaveSIFT(const char * szFileName);
00147
00148 SIFTGPU_EXPORT virtual void GetFeatureVector(SiftKeypoint * keys, float * descriptors);
00149
00150 SIFTGPU_EXPORT virtual void SetKeypointList(int num, const SiftKeypoint * keys, int keys_have_orientation = 1);
00151
00152
00153
00154
00155 SIFTGPU_EXPORT virtual int CreateContextGL();
00156
00157
00158 SIFTGPU_EXPORT virtual int VerifyContextGL();
00159
00160 SIFTGPU_EXPORT virtual int IsFullSupported();
00161
00162 SIFTGPU_EXPORT virtual void SetVerbose(int verbose = 4);
00163
00164 inline void SetVerboseBrief(){SetVerbose(2);};
00165
00166 SIFTGPU_EXPORT virtual void ParseParam(int argc, char **argv);
00167
00168 SIFTGPU_EXPORT virtual int RunSIFT(const char * imgpath);
00169
00170 SIFTGPU_EXPORT virtual int RunSIFT(int index);
00171
00172
00173
00174
00175
00176 SIFTGPU_EXPORT virtual int RunSIFT(int width, int height, const void * data,
00177 unsigned int gl_format, unsigned int gl_type);
00178
00179 SIFTGPU_EXPORT virtual int RunSIFT();
00180
00181 SIFTGPU_EXPORT virtual int RunSIFT(int num, const SiftKeypoint * keys, int keys_have_orientation = 1);
00182
00183 SIFTGPU_EXPORT SiftGPU(int np = 1);
00184
00185 SIFTGPU_EXPORT virtual ~SiftGPU();
00186
00187 SIFTGPU_EXPORT virtual void SetActivePyramid(int index) {}
00188
00189 SIFTGPU_EXPORT virtual int GetImageCount();
00190
00191 SIFTGPU_EXPORT virtual void SetTightPyramid(int tight = 1);
00192
00193 SIFTGPU_EXPORT virtual int AllocatePyramid(int width, int height);
00194
00195
00196 SIFTGPU_EXPORT virtual void SetMaxDimension(int sz);
00198 public:
00199
00200
00201
00202
00203
00204 SIFTGPU_EXPORT void* operator new (size_t size);
00205 };
00206
00207
00208
00210
00211
00213
00214 class SiftGPUEX:public SiftGPU
00215 {
00216
00217 int _view;
00218
00219 int _sub_view;
00220
00221 int _view_debug;
00222
00223 enum{COLOR_NUM = 36};
00224 float _colors[COLOR_NUM*3];
00225
00226 void DisplayInput();
00227 void DisplayDebug();
00228 void DisplayFeatureBox(int i);
00229 void DisplayLevel(void (*UseDisplayShader)(), int i);
00230 void DisplayOctave(void (*UseDisplayShader)(), int i);
00231
00232
00233 void DisplayPyramid( void (*UseDisplayShader)(), int dataName, int nskip1 = 0, int nskip2 = 0);
00234
00235 static void HSVtoRGB(float hsv[3],float rgb[3]);
00236
00237 public:
00238 SIFTGPU_EXPORT SiftGPUEX();
00239
00240 SIFTGPU_EXPORT void SetView(int view, int sub_view, char * title);
00241
00242 SIFTGPU_EXPORT void DisplaySIFT();
00243
00244 SIFTGPU_EXPORT void ToggleDisplayDebug();
00245
00246 SIFTGPU_EXPORT void RandomizeColor();
00247
00248 SIFTGPU_EXPORT void GetImageDimension(int &w, int&h);
00249
00250 SIFTGPU_EXPORT void GetInitWindowPotition(int& x, int& y);
00251 };
00252
00254
00255 class SiftMatchGPU
00256 {
00257 public:
00258 enum SIFTMATCH_LANGUAGE {
00259 SIFTMATCH_SAME_AS_SIFTGPU = 0,
00260 SIFTMATCH_GLSL = 2,
00261 SIFTMATCH_CUDA = 3,
00262 SIFTMATCH_CUDA_DEVICE0 = 3
00263 };
00264 private:
00265 int __max_sift;
00266 int __language;
00267 SiftMatchGPU * __matcher;
00268 virtual void InitSiftMatch(){}
00269 protected:
00270
00271 SIFTGPU_EXPORT virtual int _CreateContextGL();
00272 SIFTGPU_EXPORT virtual int _VerifyContextGL();
00273 public:
00274
00275 inline int CreateContextGL() {return _CreateContextGL();}
00276 inline int VerifyContextGL() {return _VerifyContextGL();}
00277
00278
00279 SIFTGPU_EXPORT SiftMatchGPU(int max_sift = 4096);
00280
00281
00282 SIFTGPU_EXPORT virtual void SetLanguage(int gpu_language);
00283
00284
00285
00286
00287
00288 SIFTGPU_EXPORT virtual void SetDeviceParam(int argc, char**argv);
00289
00290
00291 SIFTGPU_EXPORT virtual void SetMaxSift(int max_sift);
00292
00293 SIFTGPU_EXPORT virtual ~SiftMatchGPU();
00294
00295
00296
00297 SIFTGPU_EXPORT virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1);
00298
00299 SIFTGPU_EXPORT virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1);
00300
00301
00302
00303 SIFTGPU_EXPORT virtual int GetSiftMatch(
00304 int max_match,
00305 int match_buffer[][2],
00306 float distmax = 0.7,
00307 float ratiomax = 0.8,
00308 int mutual_best_match = 1);
00309
00310
00311
00312
00313
00314
00315 SIFTGPU_EXPORT virtual void SetFeautreLocation(int index, const float* locations, int gap = 0);
00316 inline void SetFeatureLocation(int index, const SiftGPU::SiftKeypoint * keys)
00317 {
00318 SetFeautreLocation(index, (const float*) keys, 2);
00319 }
00320
00321
00322
00323 SIFTGPU_EXPORT virtual int GetGuidedSiftMatch(
00324 int max_match, int match_buffer[][2],
00325 float H[3][3],
00326 float F[3][3],
00327 float distmax = 0.7,
00328 float ratiomax = 0.8,
00329 float hdistmax = 32,
00330 float fdistmax = 16,
00331 int mutual_best_match = 1);
00332
00333 public:
00334
00335 SIFTGPU_EXPORT void* operator new (size_t size);
00336 };
00337
00338 typedef SiftGPU::SiftKeypoint SiftKeypoint;
00339
00340
00341 SIFTGPU_EXPORT_EXTERN SiftGPU * CreateNewSiftGPU(int np =1);
00342 SIFTGPU_EXPORT_EXTERN SiftMatchGPU* CreateNewSiftMatchGPU(int max_sift = 4096);
00343
00344
00346 class ComboSiftGPU: public SiftGPU, public SiftMatchGPU
00347 {
00348 public:
00350 SIFTGPU_EXPORT void* operator new (size_t size);
00351 };
00352 SIFTGPU_EXPORT_EXTERN ComboSiftGPU* CreateComboSiftGPU();
00353
00355
00356 SIFTGPU_EXPORT_EXTERN ComboSiftGPU* CreateRemoteSiftGPU(int port = 7777, char* remote_server = NULL);
00357
00358
00359
00360
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00376
00377 SIFTGPU_EXPORT int CreateLiteWindow(LiteWindow* window);
00378 SIFTGPU_EXPORT void RunServerLoop(int port, int argc, char** argv);
00379 #endif