本文整理汇总了C#中Microsoft.Kinect.Skeleton.ToList方法的典型用法代码示例。如果您正苦于以下问题:C# Skeleton.ToList方法的具体用法?C# Skeleton.ToList怎么用?C# Skeleton.ToList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Kinect.Skeleton
的用法示例。
在下文中一共展示了Skeleton.ToList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: refreshSkeletonPositions
/// <summary>
/// SkeletonFrameReady gets fired every skeleton frame update, and refreshes the LocatedSensor's
/// global and relative skeleton maps
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void refreshSkeletonPositions(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame()) {
if (skeletonFrame != null) {
// First, get the relative skeletons - easy peasy
Skeleton[] skeletonsR = new Skeleton[skeletonFrame.SkeletonArrayLength];
skeletonFrame.CopySkeletonDataTo(skeletonsR);
this.relativeSkeletons = skeletonsR.ToList<Skeleton>();
// Now global skeletons...
// First, clear our global skeletons list.
// We'll be building this back up from scratch here
this.globalSkeletons.Clear();
// Next, iterate through all the skeletons, applying a rotation and translation
// to get us into global coordinates
foreach (Skeleton skel in this.relativeSkeletons) {
// Add a temporary skeleton object to store transformed
// data into
Skeleton tempSkel = skel;
foreach (Joint j in skel.Joints){
// Make a new joint, then put it into our temporary joint
// collection
JointType type = j.JointType;
Joint tempJoint = tempSkel.Joints[type];
// Copy the current joint state
JointTrackingState tracking = j.TrackingState;
tempJoint.TrackingState = tracking;
// However, we transform the position of the joint at least
SkeletonPoint shiftedPoint = new SkeletonPoint();
// Rotate the points
DenseMatrix point = new DenseMatrix(1, 3);
point[0, 0] = j.Position.X;
point[0, 1] = j.Position.Y;
point[0, 2] = j.Position.Z;
var rotatedPoint = point.Multiply(this.rotationMatrix);
// Then shift them by the global coordinates.
shiftedPoint.X = (float)rotatedPoint[0, 0] + this.xOffset;
shiftedPoint.Y = (float)rotatedPoint[0, 1] + this.yOffset;
shiftedPoint.Z = (float)rotatedPoint[0, 2] + this.zOffset;
tempJoint.Position = shiftedPoint;
tempSkel.Joints[type] = tempJoint;
}
// Next, alter the higher-level parameters of our skeleton
SkeletonPoint shiftedPosition = new SkeletonPoint();
// Rotate
DenseMatrix p = new DenseMatrix(1, 3);
p[0, 0] = tempSkel.Position.X;
p[0, 1] = tempSkel.Position.Y;
p[0, 2] = tempSkel.Position.Z;
var rPoint = p.Multiply(this.rotationMatrix);
// Then shift them by the global coordinates.
shiftedPosition.X = (float)rPoint[0, 0] + this.xOffset;
shiftedPosition.Y = (float)rPoint[0, 1] + this.yOffset;
shiftedPosition.Z = (float)rPoint[0, 2] + this.zOffset;
tempSkel.Position = shiftedPosition;
// Now add that skeleton to our global skeleton list
this.globalSkeletons.Add(tempSkel);
}
}
}
}