00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00023
00024 #ifndef GPU_SIFT_SERVER_H
00025 #define GPU_SIFT_SERVER_H
00026
00027
00028 class ComboSiftGPU;
00029 class LiteWindow;
00030
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00043
00044
00045 class ServerSiftGPU: public ComboSiftGPU
00046 {
00047 enum
00048 {
00049 COMMAND_NONE= 0,
00050 COMMAND_EXIT= 1,
00051 COMMAND_DISCONNECT,
00053 COMMAND_INITIALIZE,
00054 COMMAND_ALLOCATE_PYRAMID,
00055 COMMAND_RUNSIFT,
00056 COMMAND_RUNSIFT_FILE,
00057 COMMAND_RUNSIFT_KEY,
00058 COMMAND_RUNSIFT_DATA,
00059 COMMAND_SAVE_SIFT,
00060 COMMAND_SET_MAX_DIMENSION,
00061 COMMAND_SET_KEYPOINT,
00062 COMMAND_GET_FEATURE_COUNT,
00063 COMMAND_SET_TIGHTPYRAMID,
00064 COMMAND_GET_KEY_VECTOR,
00065 COMMAND_GET_DES_VECTOR,
00066 COMMAND_PARSE_PARAM,
00067
00069 COMMAND_MATCH_INITIALIZE,
00070 COMMAND_MATCH_SET_LANGUAGE,
00071 COMMAND_MATCH_SET_DES_FLOAT,
00072 COMMAND_MATCH_SET_DES_BYTE,
00073 COMMAND_MATCH_SET_MAXSIFT,
00074 COMMAND_MATCH_GET_MATCH,
00076 DEFAULT_PORT = 7777
00077 };
00078 private:
00079 #ifdef _WIN64
00080 unsigned __int64 _socketfd;
00081 #else
00082 int _socketfd;
00083 #endif
00084 int _port;
00085 int _connected;
00086 char _server_name[1024];
00087 private:
00088 void SetParamSiftGPU(int argc, char** argv);
00089 int InitializeConnection(int argc, char** argv);
00090 int StartServerProcess(int argc, char** argv);
00091 int ConnectServer(const char* server_name, int port);
00092 void Disconnect();
00093 static int InitSocket();
00094 static int GetPixelSizeGL(unsigned int gl_format, unsigned int gl_type);
00095 static void ServerLoop(int port, int argc, char** argv);
00096 public:
00097
00098 SIFTGPU_EXPORT ServerSiftGPU(int port = DEFAULT_PORT, char* remote_server = NULL);
00099 virtual ~ServerSiftGPU();
00101 virtual void ParseParam(int argc, char **argv);
00102 virtual int VerifyContextGL();
00104
00105 virtual int RunSIFT(const char * imgpath);
00106 virtual int RunSIFT();
00107
00108
00109 virtual int RunSIFT(int width, int height, const void * data, unsigned int gl_format, unsigned int gl_type);
00110 virtual int RunSIFT(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1);
00111 virtual int AllocatePyramid(int width, int height);
00113 virtual int GetFeatureNum();
00114 virtual void SetTightPyramid(int tight = 1);
00115 virtual void SetMaxDimension(int sz);
00116 virtual void GetFeatureVector(SiftGPU::SiftKeypoint * keys, float * descriptors);
00117 virtual void SetKeypointList(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1);
00119
00120
00121 virtual void SaveSIFT(const char * szFileName);
00122
00123
00124 int GetImageCount(){return 1;}
00125 int CreateContextGL(){return VerifyContextGL();}
00126 int IsFullSupported(){return VerifyContextGL() == SiftGPU::SIFTGPU_FULL_SUPPORTED;}
00127 int RunSIFT(int index) {return RunSIFT();}
00128
00130 public:
00131 virtual int _CreateContextGL() {return _VerifyContextGL();}
00132 virtual int _VerifyContextGL();
00133 virtual void SetLanguage(int gpu_language);
00134 virtual void SetDeviceParam(int argc, char**argv);
00135 virtual void SetMaxSift(int max_sift);
00136 virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1);
00137 virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1);
00138 virtual int GetSiftMatch(int max_match, int match_buffer[][2],
00139 float distmax, float ratiomax, int mutual_best_match);
00140 public:
00142
00143 void SetImageList(int nimage, const char** filelist) {}
00144 void SetVerbose(){}
00145
00147 virtual void SetFeautreLocation(int index, const float* locations, int gap) {return ;}
00148 virtual int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3],float F[3][3],
00149 float distmax, float ratiomax, float hdistmax, float fdistmax, int mutual_best_match) {return 0; }
00150
00151 friend void RunServerLoop(int port, int argc, char** argv);
00152
00153 };
00154
00155
00156
00157 #endif
00158
00159