I am using the Kinect Toolbox, so I have a list of ReplaySkeletonFrames
in my hand.
I am iterating over this list, getting the first tracked skeleton and modifying some properties.
As we know, when we change an object we also change the original object.
I need to make a copy of an skeleton.
Note: I can't use CopySkeletonDataTo()
because my frame is a ReplaySkeletonFrame
and not the ReplayFrame
of the "normal" Kinect.
I tried to make my own method that copies property by property, but some properties could not be copied. look...
public static Skeleton Clone(this Skeleton actualSkeleton)
{
if (actualSkeleton != null)
{
Skeleton newOne = new Skeleton();
// doesn't work - The property or indexer 'Microsoft.Kinect.SkeletonJoints'
// cannot be used in this context because the set accessor is inaccessible
newOne.Joints = actualSkeleton.Joints;
// doesn't work - The property or indexer 'Microsoft.Kinect.SkeletonJoints'
// cannot be used in this context because the set accessor is inaccessible
JointCollection jc = new JointCollection();
jc = actualSkeleton.Joints;
newOne.Joints = jc;
//...
}
return newOne;
}
How to solve it?
with more search i ended up whit the following solution: Serialize the skeleton to the memory, deserialize to a new object
Here is the code