I have a Skeleton skeleton
which comes from the SkeletonFrameReady
event. And I have a function to draw skeletons on the windows,
void DrawSkeleton(Skeleton s),
which takes the Skeleton as the input and draws 2D image of skeleton to my window.
Now, I want to change, for example, x and y value of the right hand and draw it on the window using the same function, void DrawSkeleton(Skeleton s)
.
However, when I try to do something like:
skeleton.Joints[JointType.HandRight].Position.X = 3;
It doesn't allow me to do that:
Cannot modify the return value of 'Microsoft.Kinect.Joint.Position' because it is not a variable.
which is probably because Position
is not a variable, is a property.
Question:
How can I duplicate a Skeleton
object and change the Position
values of Joint
s on that object.
Yes you can.
You simply make a new Position object and overwrite the Position you like.
var movedPosition = new SkeletonPoint
{
X = (float)(mouseJoint.Position.X - 0.4),
Y = (float)(mouseJoint.Position.Y - 0.3)
};
var movedJoint = new Joint
{
Position = movedPosition
};
This is an example from an actual project where we wanted to correct the position of the hand to adjust the mouse without actually modifying the skeleton
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With