• Home
  • Products
    • Game Engine
      • Base
      • Mathematics
      • Geometry
      • Physics
      • Particles
      • Animation
      • Graphics
      • Game
      • Game UI
    • Windows Forms
      • Docking Windows
      • Text Editor Control
  • Downloads
  • Buy
    • Overview
    • Professional
    • Indie
    • Non-Commercial
  • Support
    • Overview
    • Blog
    • Forum
    • License FAQ
    • Documentation
  • About
    • About Us
      • Services
    • Contact Us
    • Press
    • Legal Terms
      • Imprint (English)
      • Imprint (German)
Select the search type
 
  • Site
  • Web
Search
DigitalRune.com
Login |Register
NEWS News RSS Feed BLOG Blog RSS Feed FORUM News RSS Feed DOCUMENTATION DigitalRune Software on YouTube DigitalRune Software on Twitter
You are here: SupportForum

If you want to contribute to the forum discussions, please Register or Login.

SearchHome
  • 1
  • 2
  • 3
  • 4
  • 5
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineTransforming Kinect coordinates to Character Model?Transforming Kinect coordinates to Character Model?
Previous
 
Next
New Post
12/11/2011 12:24 AM
 
nicros
No Ranking

Joined: 12/11/2011
Posts: 6
Transforming Kinect coordinates to Character Model? 

Hi!  New user of DR.  I am playing with kinect SDK and would really like to animate an avatar/character in DR with the data I get back from the kinect.  And in particular with movement/physics constraints applied.  

Frequently the data from the device is junk, and puts a joint (like a hand or foot) in a position that is completely impossible.  I was hoping to be able to control this by using the joint and motion constraints that seem to be built into DR.  My company will buy this software for me in a second if this is possible.

The data from the kinect is a Vector, with X, Y and Z coordinates showing joint positions in meters.  For Z, it is distance from the device, for X and Y it is plus or minus from a center right in front of the device.  So for example, if I move to the left, X positions will show in negative meters from center.

I think I would also need to scale the avatar to match joint positions, if I walk closer or move farther away. 

Can anyone give me any pointers on how to do this?  Links to examples, suggestions, approaches, whatever.

Thank you!  

 
New Post
12/12/2011 11:01 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Transforming Kinect coordinates to Character Model? 

Hello and welcome!

We have worked on a Kinect project for a client, so we have bit of experience using Kinect. I have read several requests by now about using Kinect to animate a character in real-time - and I am interested in it myself. (I do not not need it for a specific project, but I like the challenge. ;-)
I hope to find the time to create a sample for this (but in 2011 there is not enough time left).

Here are some general thoughts:

Input data:
Joint positions (delivered by Kinect)
Joint contraints (defined manually)
Character skeleton (defined manually)

Output data:
The bone orientations for the skeleton (= SkeletonPose in DR terms), obeying the joint constraints.

Notes:
We could also control the position of the root bone using the Kinect data, which is a simpler task and I will ignore this for now.
In general, the Kinect input should always be validated and very bad input data should be filtered (e.g. impossible positions of limbs or sudden changes in the input data.)
I haven't searched the web, but we have internally discussed a few approaches.

Approach A: Manual mapping of bone orientations.
The character skeleton should have the same (or a very similar) bone hierarchy as the Kinect skeleton. (You can use the SkeletonMapper later to map the pose to different skeletons.)
Then for each bone:
Compute the direction vector of the bind pose of the bone using the start and end joints.
Also compute the direction vector using the kinect joint positions.
Create a rotation that rotates the bone from the two direction vectors (using QuaternionF.Create()).
Apply this orientation to the bone (using SkeletonHelper.RotateBoneAbsolute).

For the constraints:
Manually check if each bone orientation is in an allowed range. If necessary reduce the bone rotation before applying.
Or to get a smoother solution: After you have the unconstrained skeleton pose, iterate over all bones of the skeleton and if a bone rotation is invalid, correct the rotation by rotating the child bone AND the parent bone a bit. (Use weight factor to rotate parent bones and large bones less). Do this several times for the all skeleton and hope that it converges.

Approach B: Using IK-Solvers
Use only specific joint positions from the Kinect data (e.g. hand, head, feet) and use the IKSolvers to let the skeleton reach for those posititions. Some IKSolver support limits (using delegate functions in which you apply a manual correction).

Approach C: Using Radoll to solve contraints
Compute an unconstrained skeleton pose using one of the above methods.
Create a Ragdoll (including joint limits).
Use ragdoll motors to drive ragdoll to the unconstrained skeleton pose. The contraint solver in the physics simulation will take care of the constraints.
Then use the ragdoll to update the final skeleton (using Ragdoll.UpdateSkeletonFromBodies).

Approach D: Ragdoll with position contraints (The "Marionette" Approach)
Create a Ragdoll (including joint limits).
Add additional physics contraints (e.g. soft BallJoints) that pull important body parts to the Kinect joint positions.
Then use the ragdoll to update the final skeleton (using Ragdoll.UpdateSkeletonFromBodies).

Those are just some ideas we have been throwing around. I am sure there are other ideas out there.

 
New Post
12/12/2011 6:38 PM
 
nicros
No Ranking

Joined: 12/11/2011
Posts: 6
Re: Transforming Kinect coordinates to Character Model? 

Sounds like choices C and D are the most reasonable... will definitely give it a shot!

Also, just to throw it out there... I don't know how closely DR follows kinect development, but my company and I follow it very closely.  It might be interesting to you to know that one of the major components missing from the Kinect SDK as opposed to the XBox XDK is the integration of data driven avatars.

If DR provided a module or package that allowed integration of kinect data to drive characters of avatars, this would, I think be very, very popular.  Might make you guys some good money :)

But in the meantime, Ill see what I can do on my own.  Cheers!

 
New Post
12/13/2011 8:36 AM
 
MartinG
7th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 448
Re: Transforming Kinect coordinates to Character Model? 
nicros wrote:

Also, just to throw it out there... I don't know how closely DR follows kinect development, but my company and I follow it very closely.  It might be interesting to you to know that one of the major components missing from the Kinect SDK as opposed to the XBox XDK is the integration of data driven avatars.

If DR provided a module or package that allowed integration of kinect data to drive characters of avatars, this would, I think be very, very popular.  Might make you guys some good money :)

Interesting... we will see what we can do. Thanks for that tip.

 
New Post
12/21/2011 7:22 AM
 
nicros
No Ranking

Joined: 12/11/2011
Posts: 6
Re: Transforming Kinect coordinates to Character Model? 

Hello!  So I have been working on this and have made some interesting progress.  I went with the Ragdoll model, using Balljoints and ragdoll motors to try and pull 'The Dude' character to the kinect data- this is what you described as the Marionette method (a good description).  A couple of things maybe you could help me with...

1.  The avatar is too bouncy.  The ragdoll drops to the ground and then when the kinect data events start firing he springs to the correct location.  And then kind of bounces and jiggles around.  I have played with the Damping, Gravity and Constraints, but so far I haven't figured out how to stabilize the model.  The avatar truly looks like a puppet, kind of bouncing around and moving in odd ways.  While this works, it doesn't look like YOU, the kinect driving character.  Any suggestions on how to proceed?

2. The data points from the kinect are not quite the same as from the model.  The kinect centers at its current position- so if it is 1m off the floor, and you are 2m away, the center position for the kinect (0,0,2 in x,y,z) is in the real world 0,1,2... if that makes sense.  The Dude character appears to be about 2.1m high, and his feet are at y=0.  I thought to just offset y by 1.0f or 1.5f to compensate, but then he has odd behaviors with arms stretching too far when away from the body, and his hands not going all the way down when I put my hands to my sides.

So... considering this, I'm not convinced the marionette approach will work the best.  Too much bounce, too much artificial shoving The Dude around.  From the kinect data, you have 21 joints; e.g. elbow, knee, wrist, hand, shoulder, foot, etc.  I'm considering creating a SkeletonPose to represent the kinect data and then asking The Dude to move to that position.

Does this sound reasonable?  I don't know how to convert the kinect x,y,z data into an SrtTransform... any suggestions?  Or maybe just ways to control the bounciness of The Dude?

Regardless, I'm having great fun with this stuff!!

 
New Post
12/22/2011 3:44 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Transforming Kinect coordinates to Character Model? 

Making the ragdoll stable under such complex conditions can be tricky. Here are some random tips:

  • Start with an empty Simulation without force effects (no damping, no gravity). In the simulation setttings: Set the fixed time step size to a very small value (maybe 5ms or even 1ms) and increase the MaxNumberOfSteps. Increase the number of constraint iterations in the simulaton settings (maybe to 20 or higher). Now we have higher quality simulation conditions. If we can get it stable with these settings, we can optimize it later. If we cannot get it stable under these simulation conditions, we are doomed anyway ;-)
  • Always try to visualize the  constraint targets to be sure the inputs for the constraints are in a valid range and are not scaled or offset in strange ways.
  • Create the ragdoll step by step. Do not start with the full ragdoll. Start with one body (e.g. the pelvis). Make it follow the Kinect data. When this is stable, add the next body and constraint. Do everything step by step, on constraint/motor/body/limit after the other.
  • The parameters that need very careful tweaking are:
    spring and damping of a motor,
    error reduction and softness of the constraints, 
    (Sidenote: spring+damping can be converted to error reduction+softness using the ConstraintHelper class.)
    and the MaxForce of constraints (the max force of marionette attachment joints must be limited so that they are weaker than the ragdoll joints and limits).

 

To compute SrtTransforms from the Kinect data:
Separate translation and rotation. At first I would only concentrate on rotations. Compute the rotations of the SrtTranform rotations from the bone directions as described for approach A in my previous post.

 
New Post
12/22/2011 7:15 PM
 
nicros
No Ranking

Joined: 12/11/2011
Posts: 6
Re: Transforming Kinect coordinates to Character Model?  Modified By nicros  on 12/22/2011 8:15:37 PM

Great!  Thanks for the tips... updating as you mentioned improved things, but still not satisfactory.  So Im going to go with method A.  One thing is you say:

"Compute the direction vector of the bind pose of the bone using the start and end joints."

From the SkeletonPose, I see the SrtTransform with its Scale, Rotation and Translation- to get the direction vector I need the start and end points for this bone, but I'm not sure how to get that from the SrtTransform data.  Sorry, I'm pretty new to this stuff so learning as I go.

Thanks! 

 
New Post
12/23/2011 12:13 PM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Transforming Kinect coordinates to Character Model? 

No problem. A single SrtTransform does not give you enough information to know about the direction of a bone.
Have a look at the DrawBones() code in the BindPoseSample.cs (in the CharacterAnimationSample). This method draws lines that represent the bones. Here is a code snippet from it:

// Data of bone i:
SrtTransform bonePose = skeletonPose.GetBonePoseAbsolute(i);
var translation = (Vector3)bonePose.Translation;
  
// Draw line to parent joint representing the parent bone.
int parentIndex = skeleton.GetParent(i);
if (parentIndex >= 0)
{
  SrtTransform parentPose = skeletonPose.GetBonePoseAbsolute(parentIndex);
  vertices.Add(new VertexPositionColor(translation, color));
  vertices.Add(new VertexPositionColor((Vector3)parentPose.Translation, color));
}

 

To know the direction of a bone you get the absolute bone poses - which describes the scale, rotation and translation in the local space of the model. The translations describes the positions of the joints (= the start positions of the bones). If you subtract (and then normalize) the translation of a bone from its parent bone, then you have the direction of the parent bone.

This implies that, in general, you cannot know the direction of the last bones in the skeleton.

In some cases the 3D artist that created the skeleton has followed a certain rule, for example: The bone direction is in the direction of the local x axis of the bone. In this case you could compute the bone direction from the SrtTransform alone:
  Vector3F.UnitX  is the direction in the local space of the bone.
  absoluteBonePose.Rotation.Rotate(Vector3F.UnitX) is the direction of the bone in model space.

But in general, you can only compute the bone directions as the differences of joint positions.

 
New Post
12/29/2011 8:09 AM
 
nicros
No Ranking

Joined: 12/11/2011
Posts: 6
Re: Transforming Kinect coordinates to Character Model? 

Great!  This is extremely helpful... I think with this I should be in good shape.  

One last question- with this approach, I am creating a skeleton pose and asking for a move to that position... is there any way to have the joint constraints that get applied during ragdoll generation be in play here?   Or to move the ragdoll to the skeleton pose?

Im not sure that will make things work better, but I want to make sure I understand what the options are.  Thanks again for your help and happy new year!

 
New Post
12/29/2011 9:50 AM
 
HelmutG
6th Level Poster

www.digitalrune.com
Joined: 10/15/2006
Posts: 565
Re: Transforming Kinect coordinates to Character Model? 
The samples in the CharacterAnimationSample project show how to move a ragdoll to a target SkeletonPose (see CollisionDetectionOnlyRagdollSample and/or KinematicRagdollSample). When used like this, the ragdoll limits are not applied. Ragdoll limits were designed for the case where the animation is driven by physics (as in the PassiveRagdollSample or the Marionette approach).
 
 Page 1 of 6
123...6Next 
Previous
 
Next
HomeHomeDigitalRune Sof...DigitalRune Sof...Game EngineGame EngineTransforming Kinect coordinates to Character Model?Transforming Kinect coordinates to Character Model?


DigitalRune is a trademark of Garstenauer Information Technology OG.

Garstenauer Information Technology OG
Weingartenstrasse 35, 4452 Ternberg
Austria (EUROPE)
office@digitalrune.com

Home Products Downloads Buy Support About Us
Game Engine Particles Windows Forms Professional Blog Services
Base Animation Docking Windows Indie Forum Contact Us
Mathematics Graphics Text Editor Control Non-Commercial License FAQ Press (News)
Geometry Game Documentation Legal Terms
Physics Game UI Imprint
Impressum
Copyright © 2006-2012 Garstenauer Information Technology OG Terms Of UsePrivacy Statement