Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ofxKinect2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,8 @@ void Body::update(IBody* body)

HRESULT hr = body->get_HandLeftState(&left_hand_state);
hr = body->get_HandRightState(&right_hand_state);
hr = body->get_HandLeftConfidence(&left_hand_confidence);
hr = body->get_HandRightConfidence(&right_hand_confidence);

body->get_LeanTrackingState(&lean_state);
PointF pnt;
Expand Down Expand Up @@ -1389,6 +1391,15 @@ bool BodyStream::readFrame()

if (SUCCEEDED(hr))
{
Vector4 floor;
hr = p_frame->get_FloorClipPlane(&floor);
if (SUCCEEDED(hr)) {
floor_clip_plane.x = floor.x;
floor_clip_plane.y = floor.y;
floor_clip_plane.z = floor.z;
floor_clip_plane.w = floor.w;
}

hr = p_frame->get_RelativeTime((INT64*)&frame.timestamp);

IBody* ppBodies[BODY_COUNT] = {0};
Expand Down
9 changes: 8 additions & 1 deletion src/ofxKinect2.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ class ofxKinect2::Body
public:
typedef ofPtr<Body> Ref;

Body():left_hand_state(HandState_Unknown), right_hand_state(HandState_Unknown), is_tracked(false), is_update_scale(false) {
Body():left_hand_state(HandState_Unknown), right_hand_state(HandState_Unknown), left_hand_confidence(TrackingConfidence_Low), right_hand_confidence(TrackingConfidence_Low), is_tracked(false), is_update_scale(false) {
joints.resize(JointType_Count);
joint_points.resize(JointType_Count);
}
Expand Down Expand Up @@ -367,6 +367,9 @@ class ofxKinect2::Body
inline HandState getLeftHandState() const { return left_hand_state; }
inline HandState getRightHandState() const { return left_hand_state; }

inline TrackingConfidence getLeftHandConfidence() const { return left_hand_confidence; }
inline TrackingConfidence getRightHandConfidence() const { return left_hand_confidence; }

inline size_t getNumJoints() { return JointType_Count; }

const Joint& getJoint(size_t idx) { return joints[idx]; }
Expand All @@ -388,6 +391,8 @@ class ofxKinect2::Body
HandState left_hand_state;
HandState right_hand_state;

TrackingConfidence left_hand_confidence, right_hand_confidence;

ofPoint jointToScreen(const JointType jointType, int x = 0, int y = 0, int w = ofGetWidth(), int h = ofGetHeight());
ofPoint bodyPointToScreen(const CameraSpacePoint& bodyPoint, int x = 0, int y = 0, int w = ofGetWidth(), int h = ofGetHeight());
};
Expand Down Expand Up @@ -422,6 +427,7 @@ class ofxKinect2::BodyStream : public Stream
void drawHandRight(int x = 0, int y = 0, int w = ofGetWidth(), int h = ofGetHeight(), size_t idx = BODY_COUNT);
void drawLean(int x = 0, int y = 0, int w = ofGetWidth(), int h = ofGetHeight(), size_t idx = BODY_COUNT);

ofVec4f getFloorClipPlane() const { return floor_clip_plane; }

inline size_t getNumBodies() { return bodies.size(); }
const vector<Body> getBodies() { return bodies; }
Expand Down Expand Up @@ -449,6 +455,7 @@ class ofxKinect2::BodyStream : public Stream
protected:
DoubleBuffer<ofShortPixels> pix;
vector<Body> bodies;
ofVec4f floor_clip_plane;

bool readFrame();
void setPixels(Frame frame);
Expand Down