forked from gameoverhack/ofxOpenNI
/
ofxUserGenerator.h
77 lines (55 loc) · 1.86 KB
/
ofxUserGenerator.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#ifndef _H_OFXUSERGENERATOR
#define _H_OFXUSERGENERATOR
#include "ofxOpenNIContext.h"
#include "ofxDepthGenerator.h"
#include "ofxImageGenerator.h"
#define MAX_NUMBER_USERS 8
class ofxTrackedUser;
class ofxUserGenerator {
public:
ofxUserGenerator();
~ofxUserGenerator(){};
bool setup(ofxOpenNIContext* pContext);
void draw();
void update();
void startTracking(XnUserID nID);
void startPoseDetection(XnUserID nID);
void stopPoseDetection(XnUserID nID);
void requestCalibration(XnUserID nID);
bool needsPoseForCalibration();
void setUseMaskPixels(bool b);
void setUseCloudPoints(bool b);
void setSmoothing(float smooth);
float getSmoothing();
xn::UserGenerator& getXnUserGenerator();
void setMaxNumberOfUsers(int nUsers);
int getNumberOfTrackedUsers();
ofxTrackedUser* getTrackedUser(int nUserNum);
unsigned char * getUserPixels(int userID = 0);
ofPoint getWorldCoordinateAt(int x, int y, int userID = 0);
ofColor getWorldColorAt(int x, int y, int userID = 0);
int getWidth();
int getHeight();
private:
void drawUser(int nUserNum);
void updateUserPixels();
void updateCloudPoints();
ofxOpenNIContext* context;
xn::DepthGenerator depth_generator;
xn::ImageGenerator image_generator;
xn::UserGenerator user_generator;
// vars for user tracking
XnBool needs_pose;
XnChar calibration_pose[20];
ofxTrackedUser * tracked_users[MAX_NUMBER_USERS];
XnUInt16 found_users;
int max_num_users;
// vars for cloud point and masking
XnUInt16 width, height;
unsigned char * maskPixels[MAX_NUMBER_USERS+1];//including 0 as all users
ofPoint * cloudPoints[MAX_NUMBER_USERS+1];//including 0 as all users
ofColor * cloudColors[MAX_NUMBER_USERS+1];//including 0 as all users
bool useMaskPixels, useCloudPoints;
float smoothing_factor;
};
#endif