GestureRecognitionToolkit  Version: 0.2.0
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 intToString(const int &i);
90 
97  static std::string intToString(const unsigned int &i);
98 
105  static std::string toString(const int &i);
106 
113  static std::string toString(const unsigned int &i);
114 
121  static std::string toString(const long &i);
122 
129  static std::string toString(const unsigned long &i);
130 
137  static std::string toString(const unsigned long long &i);
138 
145  static std::string toString(const bool &b);
146 
153  static std::string toString(const float &v);
154 
161  static std::string toString(const double &v);
162 
169  static std::string toString(const long double &v);
170 
177  static int stringToInt(const std::string &s);
178 
185  static double stringToDouble(const std::string &s);
186 
193  static Float stringToFloat(const std::string &s);
194 
201  static bool stringToBool(const std::string &s);
202 
210  static bool stringEndsWith(const std::string &str, const std::string &ending);
211 
223  static Float limit(const Float value,const Float minValue,const Float maxValue);
224 
231  static Float sum(const VectorFloat &x);
232 
240  static Float dotProduct(const VectorFloat &a,const VectorFloat &b);
241 
249  static Float euclideanDistance(const VectorFloat &a,const VectorFloat &b);
250 
259  static Float manhattanDistance(const VectorFloat &a,const VectorFloat &b);
260 
270  static Float cosineDistance(const VectorFloat &a,const VectorFloat &b);
271 
283  static VectorFloat scale(const VectorFloat &x,const Float minSource,const Float maxSource,const Float minTarget=0,const Float maxTarget=1,const bool constrain=false);
284 
291  static VectorFloat normalize(const VectorFloat &x);
292 
302  static VectorFloat limit(const VectorFloat &x,const Float minValue,const Float maxValue);
303 
310  static Float getMin(const VectorFloat &x);
311 
318  static unsigned int getMinIndex(const VectorFloat &x);
319 
326  static Float getMax(const VectorFloat &x);
327 
334  static unsigned int getMaxIndex(const VectorFloat &x);
335 
342  static unsigned int getMin(const std::vector< unsigned int > &x);
343 
350  static unsigned int getMax(const std::vector< unsigned int > &x);
351 
357  static unsigned int getOS();
358 
368  static void cartToPolar(const Float x,const Float y,Float &r, Float &theta);
369 
379  static void polarToCart(const Float r,const Float theta,Float &x, Float &y);
380 
393  static bool parseDirectory( const std::string directoryPath, const std::string type, std::vector< std::string > &filenames );
394 
398  enum OperatingSystems{OS_UNKNOWN=0,OS_OSX,OS_LINUX,OS_WINDOWS};
399 
400 };
401 
402 GRT_END_NAMESPACE
403 
404 #endif // GRT_UTIL_HEADER
~Util()
Definition: Util.h:55
Util()
Definition: Util.h:50
OperatingSystems
Definition: Util.h:398
Definition: Util.h:45