From 4a22154737b991c7e6e268c3ee56caee164c3df5 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Mon, 8 Jul 2013 11:35:42 -0700 Subject: [PATCH] Fix for leaning, smoothing. --- interface/src/Avatar.cpp | 5 +++++ interface/src/Webcam.cpp | 7 +++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/interface/src/Avatar.cpp b/interface/src/Avatar.cpp index 174a0a4aa5..d471bd166b 100755 --- a/interface/src/Avatar.cpp +++ b/interface/src/Avatar.cpp @@ -306,6 +306,11 @@ void Avatar::updateFromGyrosAndOrWebcam(bool gyroLook, const glm::vec3& amplifyA if (joints.size() > i && joints[i].isValid) { JointData data = { i, joints[i].orientation }; _joints.push_back(data); + + if (i == AVATAR_JOINT_CHEST) { + // if we have a chest rotation, don't apply lean based on head + estimatedPosition = glm::vec3(); + } } } } else { diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index 28026697a9..2ca7260ffe 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -214,7 +214,7 @@ void Webcam::setFrame(const Mat& frame, int format, const Mat& depth, const Rota if (!_joints[i].isValid) { continue; } - const float JOINT_SMOOTHING = 0.5f; + const float JOINT_SMOOTHING = 0.95f; _estimatedJoints[i].isValid = true; _estimatedJoints[i].position = glm::mix(_joints[i].position - origin, _estimatedJoints[i].position, JOINT_SMOOTHING); @@ -380,7 +380,9 @@ void FrameGrabber::grabFrame() { format = GL_RGB; Mat depth = Mat(_depthMetaData.YRes(), _depthMetaData.XRes(), CV_16UC1, (void*)_depthGenerator.GetDepthMap()); - depth.convertTo(_grayDepthFrame, CV_8UC1, 256.0 / 2048.0); + const double EIGHT_BIT_MAX = 255; + const double ELEVEN_BIT_MAX = 2047; + depth.convertTo(_grayDepthFrame, CV_8UC1, EIGHT_BIT_MAX / ELEVEN_BIT_MAX); _userID = 0; XnUInt16 userCount = 1; @@ -493,6 +495,7 @@ bool FrameGrabber::init() { _userGenerator.GetSkeletonCap().RegisterToCalibrationComplete(calibrationCompleted, 0, calibrationCompleteCallback); _userGenerator.GetSkeletonCap().SetSkeletonProfile(XN_SKEL_PROFILE_UPPER); + //_userGenerator.GetSkeletonCap().SetSmoothing(0.9f); _xnContext.StartGeneratingAll(); return true;