我正在使用kinect,我想在屏幕上打印一个关节。该示例执行此操作:
foreach (Joint joint in skeleton.Joints){
Brush drawBrush = null;
drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(joint.Position),JointThickness,JointThickness)
}
绘制所有关节,目前我希望能够只绘制我感兴趣的关节。这就是我一直在做的事情:
Joint Cadera = skeleton.Joints[0];
Brush drawBrush = null;
if (drawBrush != null)
{
drawingContext.DrawEllipse(drawBrush, null, this.SkeletonPointToScreen(Cadera.Position), JointThickness, JointThickness);
}
但是当我改变骨架时。将[0]添加到skeleton.Joint [1]我收到以下错误:
cannot convert from 'int' to 'Microsoft.Kinect.JointType'
使用0时不会发生。因为我是新手c#程序员,我想知道如何访问集合的特定元素。我看了一下JointCollection类,它显示了这个:
namespace Microsoft.Kinect
{
// Summary:
// This class contains a collection of joints returned for a given skeleton.
[Serializable]
public class JointCollection : IEnumerable<Joint>, IEnumerable
{
// Summary:
// Gets the number of joints available.
public int Count { get; }
// Summary:
// Accesses the requested joint.
//
// Parameters:
// jointType:
// The JointType being requested.
//
// Returns:
// The requested joint.
public Joint this[JointType jointType] { get; set; }
// Summary:
// This method is used to enumerate the list of joints.
//
// Returns:
// The related enumerator.
public IEnumerator GetEnumerator();
}
}
所以,我相信我需要使用Joint,但我不知道怎么做。在此先感谢您的任何帮助
答案 0 :(得分:1)
您正在使用int作为Skeleton.Joints[]
的索引。
您应该使用Skeleton.Joints[]
引用JointType
。例如:
Joint hand = skeleton.Joints[JointType.HandLeft];
这将创建Skeleton左手关节的副本。有关枚举中的值,请参阅JointType
参考。