00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __COMMON_H__
00029 #define __COMMON_H__
00030
00031
00032
00033
00034
00035
00036
00037 #include <boost/unordered_map.hpp>
00038 #include <boost/unordered_set.hpp>
00039 #include <boost/lexical_cast.hpp>
00040 #include <boost/algorithm/string.hpp>
00041 #include <boost/thread/thread.hpp>
00042 #include <boost/bind.hpp>
00043 #include <stdio.h>
00044 #include <string>
00045 #include <windows.h>
00046 #include <exception>
00047 #include <iostream>
00048 #include <map>
00049 #include <list>
00050 #include <set>
00051 #include <sstream>
00052 #include <tchar.h>
00053
00054
00055 #include <cassert>
00056
00057
00058 #include "XnCppWrapper.h"
00059
00060
00061 #include "XnVNite.h"
00062
00063
00064 #include <scol.h>
00065
00066
00067 using namespace std;
00068
00069
00070
00071
00072
00073
00074 #define NIDEVICE_STRINGER(MAKE_THIS_AS_STRING) #MAKE_THIS_AS_STRING
00075
00076
00077 #define NIDEVICE_GET_CLASS_NAME_AS_STRING(CLASS_NAME) \
00078 { \
00079 std::string tmpName(NIDEVICE_STRINGER(CLASS_NAME)); \
00080 std::string type(tmpName.substr(tmpName.find_last_of("::")+1)); \
00081 return type; \
00082 }
00083
00084
00090 #pragma warning (disable: 4661)
00091
00092
00096 #define NIDEVICE_GET_OBJECT_TYPE_AS_STRING(CLASS_NAME) \
00097 std::string GetObjectTypeAsString() \
00098 { \
00099 NIDEVICE_GET_CLASS_NAME_AS_STRING(CLASS_NAME) \
00100 }; \
00101
00102
00103
00104 #define NIDEVICE_GET_ERROR_MESSAGE(ERROR,DESC) \
00105 std::string GetNiDeviceMessage() \
00106 { \
00107 std::string msg = DESC; \
00108 msg += " - "; \
00109 msg += xnGetStatusString(ERROR); \
00110 return msg; \
00111 }; \
00112
00113
00114
00115
00116
00117 namespace NIDevice
00118 {
00119
00120 namespace Core
00121 {
00122 template <class DERIVATED_CLASS> class Singleton;
00123 class Exception;
00124 class Thread;
00125 template <class GENERATOR_TYPE, XnProductionNodeType OPENNI_GENERATOR_TYPE> class GenericGenerator;
00126 class DataSkeleton;
00127 }
00128
00129
00130 namespace Generator
00131 {
00132 class Depth;
00133 class Image;
00134 class User;
00135 class Gesture;
00136 class Hands;
00137 }
00138
00139
00140 namespace Objects
00141 {
00142 class KinectDevice;
00143 class KinectUser;
00144 class KinectGesture;
00145 }
00146
00147
00148 class DeviceManager;
00149 }
00150
00151
00152
00153
00154
00155 typedef std::list<NIDevice::Objects::KinectUser*> KinectUserList;
00156 typedef std::set<unsigned int> OpenNIUserList;
00157 typedef std::map<unsigned int, NIDevice::Objects::KinectDevice*> KinectDeviceMap;
00158
00159
00160 class Quaternion
00161 {
00162 public:
00163 Quaternion()
00164 {
00165 x = 0.0f;
00166 y = 0.0f;
00167 z = 0.0f;
00168 w = 1.0f;
00169 }
00170
00171 float x;
00172 float y;
00173 float z;
00174 float w;
00175 };
00176
00177 class Matrix3
00178 {
00179 public:
00180
00181 Matrix3 (float fEntry00, float fEntry01, float fEntry02,
00182 float fEntry10, float fEntry11, float fEntry12,
00183 float fEntry20, float fEntry21, float fEntry22)
00184 {
00185 m[0][0] = fEntry00;
00186 m[0][1] = fEntry01;
00187 m[0][2] = fEntry02;
00188 m[1][0] = fEntry10;
00189 m[1][1] = fEntry11;
00190 m[1][2] = fEntry12;
00191 m[2][0] = fEntry20;
00192 m[2][1] = fEntry21;
00193 m[2][2] = fEntry22;
00194 }
00195
00196
00197
00198 inline float* operator[] (size_t iRow) const
00199 {
00200 return (float*)m[iRow];
00201 }
00202
00203 bool operator== (const Matrix3& rkMatrix) const;
00204 inline bool operator!= (const Matrix3& rkMatrix) const
00205 {
00206 return !operator==(rkMatrix);
00207 }
00208
00209
00210 Matrix3 operator+ (const Matrix3& rkMatrix) const;
00211 Matrix3 operator- (const Matrix3& rkMatrix) const;
00212 Matrix3 operator* (const Matrix3& rkMatrix) const;
00213 Matrix3 operator- () const;
00214
00215
00216
00217
00218 protected:
00219 float m[3][3];
00220 };
00221
00222 #endif