由于骨骼坐标空间与深度空间不同,我希望能够将骨骼数据转换为深度图像数据,以便能够使用这些坐标为我的 3D 模型制作动画。. 我一直在看的教程真的很老而且没有帮助。我正在使用根本不涉及 NUI 编程的 Kinect v1.5。. 任何帮助将不胜感激......这是我到目前为止所得到的。.
void newSensor_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
using (SkeletonFrame skeletalFrame = e.OpenSkeletonFrame())
using(ColorImageFrame colorFrame = e.OpenColorImageFrame())
using(DepthImageFrame depthFrame = e.OpenDepthImageFrame())
{
if (skeletalFrame != null)
{
Skeleton[] skeletonData = new Skeleton[skeletalFrame.SkeletonArrayLength];
skeletalFrame.CopySkeletonDataTo(skeletonData);
Skeleton playerSkeleton = (from s in skeletonData where s.TrackingState == SkeletonTrackingState.Tracked select s).FirstOrDefault();
if (playerSkeleton != null)
{
Joint rightHand = playerSkeleton.Joints[JointType.HandRight];
var rightHandX = rightHand.Position.X;
var rightHandY = rightHand.Position.Y;
var rightHandZ = rightHand.Position.Z
Console.SetOut(writer);
Console.SetOut(oldOut);
writer.WriteLine(rightHandX + "," + rightHandY + "," + rightHandZ);
//Pattern.Add(new Point(rightHandX, rightHandY));
}
if (colorFrame != null)
{
int stride = colorFrame.Width * 4;
pixels = new byte[colorFrame.Width*colorFrame.Height*4];
colorFrame.CopyPixelDataTo(pixels);
}
}
if (Keyboard.IsKeyDown(Key.Escape))
{
Stopkinect(kinectSensorChooser1.Kinect);
Application.Current.Shutdown();
}
// Pattern_Coordinates();
// Print_Pattern();
}
}