cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
osaOpenNI.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
4 /*
5 
6  Author(s): Kelleher Guerin, Simon Leonard
7  Created on: 2011
8 
9  (C) Copyright 2011 Johns Hopkins University (JHU), All Rights
10  Reserved.
11 
12 --- begin cisst license - do not edit ---
13 
14 This software is provided "as is" under an open source license, with
15 no warranty. The complete license can be found in license.txt and
16 http://www.cisst.org/cisst/license.txt.
17 
18 --- end cisst license ---
19 
20 */
21 
22 
23 #ifndef _osaOpenNI_h
24 #define _osaOpenNI_h
25 
27 // Always include last!
29 
30 
31 #define WAIT_AND_UPDATE_ALL 1
32 #define WAIT_ANY_UPDATE_ONE 2
33 #define WAIT_NONE_UPDATE_ALL 3
34 
35 #define CNI_USR_NEW 0
36 #define CNI_USR_LOST 1
37 #define CNI_USR_POSE 2
38 #define CNI_USR_CAL_START 3
39 #define CNI_USR_CAL_END 4
40 #define CNI_USR_SUCCESS 5
41 #define CNI_USR_FAIL 6
42 #define CNI_USR_WAIT 7
43 #define CNI_USR_IDLE -1
44 
45 #define CNI_HEA 1
46 #define CNI_NEK 2 //XN_SKEL_NECK = 2,
47 #define CNI_TOR 3 //XN_SKEL_TORSO = 3,
48 #define CNI_WAI 4 //XN_SKEL_WAIST = 4,
49 
50 #define CNI_LCO 5 //XN_SKEL_LEFT_COLLAR = 5,
51 #define CNI_LSH 6 //XN_SKEL_LEFT_SHOULDER = 6,
52 #define CNI_LEL 7 //XN_SKEL_LEFT_ELBOW = 7,
53 #define CNI_LWR 8 //XN_SKEL_LEFT_WRIST = 8,
54 #define CNI_LHN 9 //XN_SKEL_LEFT_HAND = 9,
55 #define CNI_LFI 10 //XN_SKEL_LEFT_FINGERTIP =10,
56 
57 #define CNI_RCO 11 //XN_SKEL_RIGHT_COLLAR =11,
58 #define CNI_RSH 12 //XN_SKEL_RIGHT_SHOULDER =12,
59 #define CNI_REL 13 //XN_SKEL_RIGHT_ELBOW =13,
60 #define CNI_RWR 14 //XN_SKEL_RIGHT_WRIST =14,
61 #define CNI_RHN 15 //XN_SKEL_RIGHT_HAND =15,
62 #define CNI_RFI 16 //XN_SKEL_RIGHT_FINGERTIP =16,
63 
64 #define CNI_LHP 17 //XN_SKEL_LEFT_HIP =17,
65 #define CNI_LKN 18 //XN_SKEL_LEFT_KNEE =18,
66 #define CNI_LAN 19 //XN_SKEL_LEFT_ANKLE =19,
67 #define CNI_LFT 20 //XN_SKEL_LEFT_FOOT =20,
68 
69 #define CNI_RHP 21 //XN_SKEL_RIGHT_HIP =21,
70 #define CNI_RKN 22 //XN_SKEL_RIGHT_KNEE =22,
71 #define CNI_RAN 23 //XN_SKEL_RIGHT_ANKLE =23,
72 #define CNI_RFT 24 //XN_SKEL_RIGHT_FOOT =24
73 
74 
85 class osaOpenNIData;
86 
88 
89  friend class osaOpenNISkeleton;
90 
91  public:
92 
93  enum Errno {ESUCCESS, EFAILURE};
94 
95  private:
96 
98  osaOpenNIData* Data;
99 
101  std::string name;
102 
103  std::vector<osaOpenNISkeleton*> skeletons;
104 
105  int users;
106  bool usingPrecapturedCalibration;
107 
108  char* ProjectivePointsBuffer;
109  char* WorldPointsBuffer;
110  unsigned int PointsBufferSize;
111 
112  public:
113 
115  osaOpenNI(int numUsers = 0);
116 
118  osaOpenNI(int numUsers, char usrPath);
119 
121  ~osaOpenNI();
122 
124  void CleanupExit();
125 
127 
131  void Configure(const std::string & devname = "");
132 
134 
138  void Update(int type);
139 
141  void InitSkeletons();
142 
144 
151  osaOpenNI::Errno GetRangeData(vctDynamicMatrix<double> & rangedata,
152  const std::vector< vctFixedSizeVector<unsigned short, 2> > & pixels);
153  osaOpenNI::Errno GetRangeData(vctDynamicMatrixRef<vctFloat3> rangedata);
154 
156 
161  osaOpenNI::Errno GetDepthImageRaw(vctDynamicMatrix<double> & depthimage);
162  osaOpenNI::Errno GetDepthImageRaw(vctDynamicMatrixRef<unsigned short> depthimage);
163 
165 
170  void GetDepthImage(vctDynamicMatrix<double> & placeHolder);
171 
173 
176  osaOpenNI::Errno GetRGBImage(vctDynamicMatrix<unsigned char> & RGBinterlaced);
177  osaOpenNI::Errno GetRGBImage(vctDynamicMatrixRef<unsigned char> RGBinterlaced);
178 
180 
182  osaOpenNI::Errno GetRGBPlanarImage(vctDynamicNArray<unsigned char,3> & RGBplanar);
183 
184 
186 
188  std::vector<osaOpenNISkeleton*> & UpdateAndGetUserSkeletons(void);
189 
191 
193  void UpdateUserSkeletons(void);
194 
196 
198  std::vector<osaOpenNISkeleton*> & GetUserSkeletons(void);
199 
200  // Convert 3D to projective
202  Convert3DToProjectiveMask(const vctDynamicMatrix<double> & rangedata,
203  vctDynamicMatrix<bool> & mask);
204  void Convert3DToProjective(const vctFloat3& point3d, vctFloat3& point2d);
205 
206 };
207 
208 #endif
Definition: osaOpenNI.h:93
#define CISST_EXPORT
Definition: cmnExportMacros.h:50
An nArray object of dynamic size.
Definition: vctDynamicNArray.h:122
Definition: osaOpenNI.h:87
Dynamic matrix referencing existing memory.
Definition: vctDynamicMatrixRef.h:74
void Update(int id)
Build Skeleton Using XN Context for a given user.
Implementation of a fixed-size vector using template metaprogramming.
Definition: vctFixedSizeVector.h:52
Definition: osaOpenNISkeleton.h:33
Errno
Definition: osaOpenNI.h:93