GestureRecognitionToolkit  Version: 0.2.5
The Gesture Recognition Toolkit (GRT) is a cross-platform, open-source, c++ machine learning library for real-time gesture recognition.
Util.h
Go to the documentation of this file.
1 
12 #ifndef GRT_UTIL_HEADER
13 #define GRT_UTIL_HEADER
14 
15 //Include the GRTVersionInfo header to find which operating system we are building for
16 #include "GRTVersionInfo.h"
17 #include "GRTTypedefs.h"
18 #include "../DataStructures/VectorFloat.h"
19 #include "../DataStructures/MatrixFloat.h"
20 
21 #ifdef __GRT_WINDOWS_BUILD__
22 //Include any Windows specific headers
23 #include <windows.h>
24 //Hey User: Make sure you add the path to the Kernel32.lib to your lib search paths
25 //#pragma comment(lib,"Kernel32.lib")
26 //The min and max macros cause major headaches, so undefine them
27 #undef min
28 #undef max
29 #endif
30 
31 #ifdef __GRT_OSX_BUILD__
32 //Include any OSX specific headers
33 #include <unistd.h>
34 #include <dirent.h>
35 #endif
36 
37 #ifdef __GRT_LINUX_BUILD__
38 //Include any Linux specific headers
39 #include <unistd.h>
40 #include <dirent.h>
41 #endif
42 
43 GRT_BEGIN_NAMESPACE
44 
45 class GRT_API Util{
46 public:
50  Util(){}
51 
55  ~Util(){}
56 
60  static bool getCxx11Enabled();
61 
68  static bool sleep(const unsigned int &numMilliseconds);
69 
81  static Float scale(const Float &x,const Float &minSource,const Float &maxSource,const Float &minTarget,const Float &maxTarget,const bool constrain=false);
82 
89  static std::string timeAsString(const bool includeDate=true);
90 
97  static std::string intToString(const int &i);
98 
105  static std::string intToString(const unsigned int &i);
106 
113  static std::string toString(const int &i);
114 
121  static std::string toString(const unsigned int &i);
122 
129  static std::string toString(const long &i);
130 
137  static std::string toString(const unsigned long &i);
138 
145  static std::string toString(const unsigned long long &i);
146 
153  static std::string toString(const bool &b);
154 
161  static std::string toString(const float &v);
162 
169  static std::string toString(const double &v);
170 
177  static std::string toString(const long double &v);
178 
185  static int stringToInt(const std::string &s);
186 
193  static double stringToDouble(const std::string &s);
194 
201  static Float stringToFloat(const std::string &s);
202 
209  static bool stringToBool(const std::string &s);
210 
218  static bool stringEndsWith(const std::string &str, const std::string &ending);
219 
231  static Float limit(const Float value,const Float minValue,const Float maxValue);
232 
239  static Float sum(const VectorFloat &x);
240 
248  static Float dotProduct(const VectorFloat &a,const VectorFloat &b);
249 
257  static Float euclideanDistance(const VectorFloat &a,const VectorFloat &b);
258 
266  static Float squaredEuclideanDistance(const VectorFloat &a,const VectorFloat &b);
267 
276  static Float manhattanDistance(const VectorFloat &a,const VectorFloat &b);
277 
287  static Float cosineDistance(const VectorFloat &a,const VectorFloat &b);
288 
300  static VectorFloat scale(const VectorFloat &x,const Float minSource,const Float maxSource,const Float minTarget=0,const Float maxTarget=1,const bool constrain=false);
301 
308  static VectorFloat normalize(const VectorFloat &x);
309 
319  static VectorFloat limit(const VectorFloat &x,const Float minValue,const Float maxValue);
320 
327  static Float getMin(const VectorFloat &x);
328 
335  static unsigned int getMinIndex(const VectorFloat &x);
336 
343  static Float getMax(const VectorFloat &x);
344 
351  static unsigned int getMaxIndex(const VectorFloat &x);
352 
359  static unsigned int getMin(const std::vector< unsigned int > &x);
360 
367  static unsigned int getMax(const std::vector< unsigned int > &x);
368 
374  static unsigned int getOS();
375 
385  static void cartToPolar(const Float x,const Float y,Float &r, Float &theta);
386 
396  static void polarToCart(const Float r,const Float theta,Float &x, Float &y);
397 
410  static bool parseDirectory( const std::string directoryPath, const std::string type, std::vector< std::string > &filenames );
411 
415  enum OperatingSystems{OS_UNKNOWN=0,OS_OSX,OS_LINUX,OS_WINDOWS};
416 
417 };
418 
419 GRT_END_NAMESPACE
420 
421 #endif // GRT_UTIL_HEADER
~Util()
Definition: Util.h:55
Util()
Definition: Util.h:50
OperatingSystems
Definition: Util.h:415
Definition: Util.h:45