ServerSiftGPU.h
Go to the documentation of this file.
00001 
00002 //      File:           ServerSiftGPu.h
00003 //      Author:         Changchang Wu
00004 //      Description :   interface for the ServerSiftGPU class.
00005 //                                      It starts a SiftGPU server in a new process
00006 //                                      or connects to an existing server.
00007 //
00008 //      Copyright (c) 2007 University of North Carolina at Chapel Hill
00009 //      All Rights Reserved
00010 //
00011 //      Permission to use, copy, modify and distribute this software and its
00012 //      documentation for educational, research and non-profit purposes, without
00013 //      fee, and without a written agreement is hereby granted, provided that the
00014 //      above copyright notice and the following paragraph appear in all copies.
00015 //      
00016 //      The University of North Carolina at Chapel Hill make no representations
00017 //      about the suitability of this software for any purpose. It is provided
00018 //      'as is' without express or implied warranty. 
00019 //
00020 //      Please send BUG REPORTS to ccwu@cs.unc.edu
00021 //
00023 
00024 #ifndef GPU_SIFT_SERVER_H
00025 #define GPU_SIFT_SERVER_H
00026 
00027 
00028 class ComboSiftGPU;
00029 class LiteWindow;
00030 
00032 //ServerSiftGPU::ServerSiftGPU(int port, char* remote_server)
00033 //Run SiftGPU/SiftMatchGPU computation on a remote computer/process
00034 //if( remote_server == NULL) 
00035 //                      a local server is created in a different process and connects to it
00036 //                      multiple-GPU can be used by creating multiple instances
00037 //                      GPU selection done through ParseParam function
00038 //otherwise, 
00039 //                      Assumes the existenc of a remote server and connects to it
00040 //                      GPU selection is done on the server-end when create the server by running
00041 //                      server_siftgpu -server port [siftgpu_param]
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         //two options : multi-threading or multi-processing
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         //available SiftGPU functions are the following:
00105         virtual int RunSIFT(const char * imgpath);
00106     virtual int RunSIFT();
00107         //note the difference with class SiftGPU for the function below, 
00108         //you have to provide the number of bytes of the data.
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         //the following functions do not block in multi-process mode
00120         //for example, SaveSIFT will return before the file is written
00121         virtual void SaveSIFT(const char * szFileName);
00122 
00123         //simplified functions
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], //buffeture indices
00139                                 float distmax, float ratiomax,  int mutual_best_match); //
00140 public:
00142     //Some SiftGPU functions  are not supported
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 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


rgbd_registration
Author(s): Ross Kidson
autogenerated on Sun Oct 6 2013 12:00:40