0

I would get some data stream about 3d position(in fixed world coordinate system) of a human's 20 skeletons.

I want to use the skeletons data to drive a human model with fixed bone like the demo video.

In Kinect SDK v1.8,i could get each skeleton's local rotation by NUI_SKELETON_BONE_ORIENTATION.hierarchicalRotation.

I want to implement some function like that.But the Kinect's SDK isn't open source.

I've found that the function xnGetSkeletonJointOrientation could get skeleton's rotation like that in OpenNI.But i haven't found the implement function about that.I don't know where am i wrong.

Any idea is appreciated.Thanks!

EDIT

I have found a similar question.

Here is the code he used finally.

Point3d Controller::calRelativeToParent(int parentID,Point3d point,int frameID){
if(parentID == 0){
    QUATERNION temp = calChangeAxis(-1,parentID,frameID);
    return getVect(multiplyTwoQuats(multiplyTwoQuats(temp,getQuat(point)),getConj(temp)));
}else{
    Point3d ref = calRelativeToParent(originalRelativePointMap[parentID].parentID,point,frameID);
    QUATERNION temp = calChangeAxis(originalRelativePointMap[parentID].parentID,parentID,frameID);  
    return getVect(multiplyTwoQuats(multiplyTwoQuats(temp,getQuat(ref)),getConj(temp)));
}}
QUATERNION Controller::calChangeAxis(int parentID,int qtcId,int frameID){ //currentid = id of the position of the orientation to be changed
if(parentID == -1){
    QUATERNION out = multiplyTwoQuats(quatOrigin.toChange,originalRelativePointMap[qtcId].orientation);
    return out;
}
else{
    //QUATERNION temp = calChangeAxis(originalRelativePointMap[parentID].parentID,qtcId,frameID);
    //return multiplyTwoQuats(finalQuatMap[frameID][parentID].toChange,temp);
    return multiplyTwoQuats(finalQuatMap[frameID][parentID].toChange,originalRelativePointMap[qtcId].orientation);  
}}

But i still have some question about that.

What does the variables quatOrigin.toChange and originalRelativePointMap stand for?

And in my opinion,the parameter Point3d point of the function Controller::calRelativeToParent should be a vector with euler angle.In this way,how to call the Controller::calRelativeToParent API in the main program.Because we know the root's rotation only.

zdczdcc
  • 119
  • 2
  • 14

1 Answers1

0

The skeleton class has a "Joints" member that contains all the 3d position data for each tracked joint on the skeleton. I would look at the joint position data directly to drive your model rather than angles. Take one point to be your base (head or otherwise) then generate vectors in tree form between pairs of connected skeletal points. Scale those vectors and apply them to your model.

Sneaky Polar Bear
  • 1,611
  • 2
  • 17
  • 29
  • Sorry for the late.My "Joints" member was got from some device like kinect without high accuracy joint position.So i can't drive my model by the joint position and i want to drive it by the hierarchical orientation. – zdczdcc Aug 28 '17 at 08:58
  • Yes, I am just suggesting you derive your own hierarchical orientation as I don're recall if you can pull that directly from the kinect. If you are worried about noise, apply a low pass filter to each point. But to clarify, I am suggesting you take each joint and group them into sequential pairs and use those directional vectors to create your hierarchical orientation. – Sneaky Polar Bear Aug 28 '17 at 12:04
  • I could get 20 joints for each frame and save them to disk for having some test offline.The key is i don't know how to derive hierarchical orientation.And i want to get some sample project for having a learning.So i downloaded the `OpenNI` and `libfreenect`.But i haven't found the relative code in these two projects. – zdczdcc Aug 29 '17 at 05:31
  • Now i define each joint's orientation by the global 3d position.For example,as the right elbow's rotation(mark as `elbow_r`,`hand_r`).In frame1,i get the position of `hand_r` and `elbow_r` and make these two points as a 3d vector(`elbow_r` is the initial point,`hand_r` is the end point),and normalize the vector(mark as `vec1`).In frame2,i also get the normalized vector by new joints' position(mark as `vec2`).The i calculate the quaternion between `vec1` and `vec2` as the rotation of the joint `elbow_r`.I think it's wrong to drive a human model.But i don't know how to do with hierarchical rot. – zdczdcc Aug 29 '17 at 06:02
  • @Polar Bear,please give me some help.Thanks a lot! – zdczdcc Aug 30 '17 at 10:33
  • If I get some time over the weekend, I will fire up my kinect and try to do what I am suggesting/ what you are trying to do. – Sneaky Polar Bear Aug 30 '17 at 13:13
  • Thank you!May i have your email?My email is `zdxever@sina.com`. – zdczdcc Aug 31 '17 at 02:39
  • @Polar Bear,i've appended some code for this question.Please give me some help. – zdczdcc Sep 06 '17 at 10:14
  • Sorry, I haven't gotten around to setting this up yet. – Sneaky Polar Bear Sep 06 '17 at 10:16
  • It doesn't matter.I've do some test about that base on the official project.But i was failed all the time.And i've create a github repo for you to [clone](https://github.com/zdczdcc/Avateering-XNA) the official project.Please give me some help if you have some time to try to do that.Thanks a lot! – zdczdcc Sep 06 '17 at 10:54