From d15ea9772440a9878043f2e0ebe9576198d792e0 Mon Sep 17 00:00:00 2001 From: nariakiiwatani Date: Fri, 8 Jul 2016 08:28:04 +0900 Subject: [PATCH 1/2] added joint_hand confidence --- src/ofxKinect2.cpp | 2 ++ src/ofxKinect2.h | 7 ++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/ofxKinect2.cpp b/src/ofxKinect2.cpp index 9d16292..ef80e12 100644 --- a/src/ofxKinect2.cpp +++ b/src/ofxKinect2.cpp @@ -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; diff --git a/src/ofxKinect2.h b/src/ofxKinect2.h index ab28532..ea4e375 100644 --- a/src/ofxKinect2.h +++ b/src/ofxKinect2.h @@ -338,7 +338,7 @@ class ofxKinect2::Body public: typedef ofPtr 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); } @@ -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]; } @@ -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()); }; From 03970d8cb4222fc4704d5243fc573f0b07bd3fcd Mon Sep 17 00:00:00 2001 From: nariakiiwatani Date: Fri, 8 Jul 2016 08:29:01 +0900 Subject: [PATCH 2/2] added FloorClipPane support --- src/ofxKinect2.cpp | 9 +++++++++ src/ofxKinect2.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/ofxKinect2.cpp b/src/ofxKinect2.cpp index ef80e12..633ca55 100644 --- a/src/ofxKinect2.cpp +++ b/src/ofxKinect2.cpp @@ -1391,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}; diff --git a/src/ofxKinect2.h b/src/ofxKinect2.h index ea4e375..464d923 100644 --- a/src/ofxKinect2.h +++ b/src/ofxKinect2.h @@ -427,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 getBodies() { return bodies; } @@ -454,6 +455,7 @@ class ofxKinect2::BodyStream : public Stream protected: DoubleBuffer pix; vector bodies; + ofVec4f floor_clip_plane; bool readFrame(); void setPixels(Frame frame);