wouterverweirder / kinect-azure

Nodejs library to access the azure kinect data from the official SDK
MIT License
76 stars 23 forks source link

Wrong order of joints #18

Closed eikaramba closed 4 years ago

eikaramba commented 4 years ago

I don't know why exactly, but somehow the order of the joints is wrong. See the following comparison

joint           index in kinect-azure      index according to documentation
right ear                           0                                   31
pelvis                              1                                    0
spine naval                         2                                    1
.....
left eye                           29                                   28
left ear                           30                                   29
right eye                          31                                   30

I observed this because i wanted to simply paint the pelvis green in the Body Tracking 2D example:

body.skeleton.joints.forEach((joint,index) => {
        if(index==KinectAzure.K4ABT_JOINT_PELVIS){
                      outputCtx.fillStyle = 'green';
        }else{
                      outputCtx.fillStyle = 'red';
        }
        outputCtx.fillRect(joint.colorX, joint.colorY, 10, 10);
});

But this code was not working, so now I'm using a helper method to fix the order

        function fixOrder(index){
          if(index==0){
            return 31;
          }else{
            return index-1;
          }
        }

I also looked at the kinect_azure.cc file, however at a first glance it looks okay.

wouterverweirder commented 4 years ago

Good catch - got the same behavior. Will investigate.

wouterverweirder commented 4 years ago

Looks like it's the 2D transformed points that are linked to the wrong joints, the 3D coords are correct.

wouterverweirder commented 4 years ago

Looks like it had to do with rendering joints in color space while there isn't a color feed open. My demo was a bit confusing.