none
Realtime update of text to display tracked joint RRS feed

  • Question

  • I have an application tracking my right hand. How can I display the x, y, z coordinates of my track hand in real-time. Would I use a text block and update the text? What would the code look like approximately in C#?
    Wednesday, September 21, 2011 7:21 PM

Answers

  • Well, the way you portray the UI is up to how'd you like the experience to be, but for a simple prototype, a text box would work. Just add something like

    <TextBox Name="handPos" Margin="10" Focusable="False"/>

    to your MainWindow.xaml file in a WPF application. Then, in your SkeletonFrameReady event handler (registered as shown in SkeletalViewer sample) you can do:

    void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
    {
        SkeletonFrame skeletonFrame = e.SkeletonFrame;
    
        SkeletonData skeleton = (from s in skeletonFrame.Skeletons
                                         where s.TrackingState == SkeletonTrackingState.Tracked
                                         select s).FirstOrDefault();
    
        if (skeleton == null)
        {
            handPos.Text = "No skeleton tracked";
        }
        else
        {
            Joint rightHand = skeleton.Joints[JointId.HandRight];
            handPos.Text = "{"+rightHand.Position.X+","+rightHand.Position.Y+","+rightHand.Position.Z+"}";
        }

    Hope this helps,
    Eddy


    I'm here to help
    Wednesday, September 21, 2011 10:14 PM