root / rgbdslam / external / siftgpu / src / ServerSiftGPU / ServerSiftGPU.h @ 9240aaa3
History | View | Annotate | Download (6 KB)
1 | 9240aaa3 | Alex | ////////////////////////////////////////////////////////////////////////////
|
---|---|---|---|
2 | // File: ServerSiftGPu.h
|
||
3 | // Author: Changchang Wu
|
||
4 | // Description : interface for the ServerSiftGPU class.
|
||
5 | // It starts a SiftGPU server in a new process
|
||
6 | // or connects to an existing server.
|
||
7 | //
|
||
8 | // Copyright (c) 2007 University of North Carolina at Chapel Hill
|
||
9 | // All Rights Reserved
|
||
10 | //
|
||
11 | // Permission to use, copy, modify and distribute this software and its
|
||
12 | // documentation for educational, research and non-profit purposes, without
|
||
13 | // fee, and without a written agreement is hereby granted, provided that the
|
||
14 | // above copyright notice and the following paragraph appear in all copies.
|
||
15 | //
|
||
16 | // The University of North Carolina at Chapel Hill make no representations
|
||
17 | // about the suitability of this software for any purpose. It is provided
|
||
18 | // 'as is' without express or implied warranty.
|
||
19 | //
|
||
20 | // Please send BUG REPORTS to ccwu@cs.unc.edu
|
||
21 | //
|
||
22 | ////////////////////////////////////////////////////////////////////////////
|
||
23 | |||
24 | #ifndef GPU_SIFT_SERVER_H
|
||
25 | #define GPU_SIFT_SERVER_H
|
||
26 | |||
27 | |||
28 | class ComboSiftGPU; |
||
29 | class LiteWindow; |
||
30 | |||
31 | /////////////////////////////////////////////////////////////////////////////
|
||
32 | //ServerSiftGPU::ServerSiftGPU(int port, char* remote_server)
|
||
33 | //Run SiftGPU/SiftMatchGPU computation on a remote computer/process
|
||
34 | //if( remote_server == NULL)
|
||
35 | // a local server is created in a different process and connects to it
|
||
36 | // multiple-GPU can be used by creating multiple instances
|
||
37 | // GPU selection done through ParseParam function
|
||
38 | //otherwise,
|
||
39 | // Assumes the existenc of a remote server and connects to it
|
||
40 | // GPU selection is done on the server-end when create the server by running
|
||
41 | // server_siftgpu -server port [siftgpu_param]
|
||
42 | /////////////////////////////////////////////////////////////////////////////
|
||
43 | |||
44 | |||
45 | class ServerSiftGPU: public ComboSiftGPU |
||
46 | { |
||
47 | enum
|
||
48 | { |
||
49 | COMMAND_NONE= 0,
|
||
50 | COMMAND_EXIT= 1,
|
||
51 | COMMAND_DISCONNECT, |
||
52 | ///////////////////////////////
|
||
53 | COMMAND_INITIALIZE, |
||
54 | COMMAND_ALLOCATE_PYRAMID, |
||
55 | COMMAND_RUNSIFT, |
||
56 | COMMAND_RUNSIFT_FILE, |
||
57 | COMMAND_RUNSIFT_KEY, |
||
58 | COMMAND_RUNSIFT_DATA, |
||
59 | COMMAND_SAVE_SIFT, |
||
60 | COMMAND_SET_MAX_DIMENSION, |
||
61 | COMMAND_SET_KEYPOINT, |
||
62 | COMMAND_GET_FEATURE_COUNT, |
||
63 | COMMAND_SET_TIGHTPYRAMID, |
||
64 | COMMAND_GET_KEY_VECTOR, |
||
65 | COMMAND_GET_DES_VECTOR, |
||
66 | COMMAND_PARSE_PARAM, |
||
67 | |||
68 | /////////////////////////////////
|
||
69 | COMMAND_MATCH_INITIALIZE, |
||
70 | COMMAND_MATCH_SET_LANGUAGE, |
||
71 | COMMAND_MATCH_SET_DES_FLOAT, |
||
72 | COMMAND_MATCH_SET_DES_BYTE, |
||
73 | COMMAND_MATCH_SET_MAXSIFT, |
||
74 | COMMAND_MATCH_GET_MATCH, |
||
75 | ///////////////////////////////
|
||
76 | DEFAULT_PORT = 7777
|
||
77 | }; |
||
78 | private:
|
||
79 | #ifdef _WIN64
|
||
80 | unsigned __int64 _socketfd;
|
||
81 | #else
|
||
82 | int _socketfd;
|
||
83 | #endif
|
||
84 | int _port;
|
||
85 | int _connected;
|
||
86 | char _server_name[1024]; |
||
87 | private:
|
||
88 | void SetParamSiftGPU(int argc, char** argv); |
||
89 | int InitializeConnection(int argc, char** argv); |
||
90 | int StartServerProcess(int argc, char** argv); |
||
91 | int ConnectServer(const char* server_name, int port); |
||
92 | void Disconnect();
|
||
93 | static int InitSocket(); |
||
94 | static int GetPixelSizeGL(unsigned int gl_format, unsigned int gl_type); |
||
95 | static void ServerLoop(int port, int argc, char** argv); |
||
96 | public:
|
||
97 | //two options : multi-threading or multi-processing
|
||
98 | SIFTGPU_EXPORT ServerSiftGPU(int port = DEFAULT_PORT, char* remote_server = NULL); |
||
99 | virtual ~ServerSiftGPU(); |
||
100 | ////////////////////////////////////////
|
||
101 | virtual void ParseParam(int argc, char **argv); |
||
102 | virtual int VerifyContextGL();
|
||
103 | ////////////////////////////////////////////////////////////////////////
|
||
104 | //available SiftGPU functions are the following:
|
||
105 | virtual int RunSIFT(const char * imgpath); |
||
106 | virtual int RunSIFT();
|
||
107 | //note the difference with class SiftGPU for the function below,
|
||
108 | //you have to provide the number of bytes of the data.
|
||
109 | virtual int RunSIFT(int width, int height, const void * data, unsigned int gl_format, unsigned int gl_type); |
||
110 | virtual int RunSIFT(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1); |
||
111 | virtual int AllocatePyramid(int width, int height); |
||
112 | /////////////////////////////////////////////////////////////////////
|
||
113 | virtual int GetFeatureNum();
|
||
114 | virtual void SetTightPyramid(int tight = 1); |
||
115 | virtual void SetMaxDimension(int sz); |
||
116 | virtual void GetFeatureVector(SiftGPU::SiftKeypoint * keys, float * descriptors); |
||
117 | virtual void SetKeypointList(int num, const SiftGPU::SiftKeypoint * keys, int keys_have_orientation = 1); |
||
118 | /////////////////////////////////////////////////////////////////////////////
|
||
119 | //the following functions do not block in multi-process mode
|
||
120 | //for example, SaveSIFT will return before the file is written
|
||
121 | virtual void SaveSIFT(const char * szFileName); |
||
122 | |||
123 | //simplified functions
|
||
124 | int GetImageCount(){return 1;} |
||
125 | int CreateContextGL(){return VerifyContextGL();} |
||
126 | int IsFullSupported(){return VerifyContextGL() == SiftGPU::SIFTGPU_FULL_SUPPORTED;} |
||
127 | int RunSIFT(int index) {return RunSIFT();} |
||
128 | |||
129 | ////////////////////////
|
||
130 | public:
|
||
131 | virtual int _CreateContextGL() {return _VerifyContextGL();} |
||
132 | virtual int _VerifyContextGL();
|
||
133 | virtual void SetLanguage(int gpu_language); |
||
134 | virtual void SetDeviceParam(int argc, char**argv); |
||
135 | virtual void SetMaxSift(int max_sift); |
||
136 | virtual void SetDescriptors(int index, int num, const float* descriptors, int id = -1); |
||
137 | virtual void SetDescriptors(int index, int num, const unsigned char * descriptors, int id = -1); |
||
138 | virtual int GetSiftMatch(int max_match, int match_buffer[][2], //buffeture indices |
||
139 | float distmax, float ratiomax, int mutual_best_match); // |
||
140 | public:
|
||
141 | //////////////////////////////////////////////////////
|
||
142 | //Some SiftGPU functions are not supported
|
||
143 | void SetImageList(int nimage, const char** filelist) {} |
||
144 | void SetVerbose(){}
|
||
145 | |||
146 | ///Guided matching is not supported here, not hard to implement yourself
|
||
147 | virtual void SetFeautreLocation(int index, const float* locations, int gap) {return ;} |
||
148 | virtual int GetGuidedSiftMatch(int max_match, int match_buffer[][2], float H[3][3],float F[3][3], |
||
149 | float distmax, float ratiomax, float hdistmax, float fdistmax, int mutual_best_match) {return 0; } |
||
150 | |||
151 | friend void RunServerLoop(int port, int argc, char** argv); |
||
152 | |||
153 | }; |
||
154 | |||
155 | |||
156 | |||
157 | #endif
|
||
158 |