Answered by:
Extract Kinect skeleton coordinates values

Question
-
Hello
I would like to know how to extract the values of the skeleton coordinates in vpl
example: hand left - (coord x)
- Edited by konnect rob Friday, January 27, 2012 8:28 PM
Friday, January 27, 2012 8:11 PM
Answers
-
Use the "UpdateControl" message from the Calculate activity.
If you want to get continuous updates from the Kinect you can use a timer like this.
I set the timer to 250ms initially and then reset it to 250ms after the dialog update is successful.Once the Kinect has recognized a skeleton, the dialog will update the assigned field with the new data every 250 ms
- Proposed as answer by Gershon Parent Tuesday, March 27, 2012 12:34 AM
- Marked as answer by Harshavardhana KikkeriModerator Friday, April 6, 2012 9:46 PM
Tuesday, March 27, 2012 12:34 AM
All replies
-
i'd like to know that too... any help would be greatly appreciated :)
- Proposed as answer by Gershon Parent Thursday, March 15, 2012 12:32 AM
- Unproposed as answer by Gershon Parent Thursday, March 15, 2012 12:32 AM
Friday, February 3, 2012 9:11 PM -
- You must be using the final release of RDS4 and final release of Kinect for Windows 1.0
- Instead of looking at the "Notifications" you must instead perform a "QueryRawFrame" and respond to the "Success" message
- The data you seek is in the RawFrames object...
RawFrames.RawSkeletonFrameData.SkeletonData[0].Joints[JointType.HandLeft].Position.X
- Proposed as answer by Gershon Parent Thursday, March 15, 2012 12:32 AM
Thursday, March 15, 2012 12:32 AM -
Great - After this, is it possible to display the extracted values of the skeleton coordinates in vpl in a Dialog or something so that I can see it? I hope that my questions is clear.
Like this...Thursday, March 22, 2012 5:11 AM -
Use the "UpdateControl" message from the Calculate activity.
If you want to get continuous updates from the Kinect you can use a timer like this.
I set the timer to 250ms initially and then reset it to 250ms after the dialog update is successful.Once the Kinect has recognized a skeleton, the dialog will update the assigned field with the new data every 250 ms
- Proposed as answer by Gershon Parent Tuesday, March 27, 2012 12:34 AM
- Marked as answer by Harshavardhana KikkeriModerator Friday, April 6, 2012 9:46 PM
Tuesday, March 27, 2012 12:34 AM -
I'm having some issues getting this example to work properly in VPL. What are your data connection parameters for the Kinect box and the Flexible Dialog box? Thanks!Tuesday, April 10, 2012 4:52 AM
-
I'm still unable to get this VPL code outlined above to function. Can you provide a sample file?Friday, April 20, 2012 3:41 AM
-
please find the code in which we can get the co ordinates of each joint . I would like to know how to save the co-ordinates value in file . You will find the depth , skeleton , and skeleton with ellipses . you will also find the X Y Z coordinates in out . Please note I am still trying to confiugre so please bear wtih the output.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Kinect;
using Coding4Fun.Kinect.Wpf;
using System.Diagnostics;
namespace Play_v_6
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
kinectSensorChooser1.KinectSensorChanged += new DependencyPropertyChangedEventHandler(kinectSensorChooser1_KinectSensorChanged);
}
void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e)
{
KinectSensor oldsensor = (KinectSensor)e.OldValue;
StopKinect(oldsensor);
KinectSensor newsensor = (KinectSensor)e.NewValue;
newsensor.DepthStream.Enable();
newsensor.SkeletonStream.Enable();
newsensor.SkeletonFrameReady += new EventHandler<SkeletonFrameReadyEventArgs>(newsensor_SkeletonFrameReady);
//newsensor.AllFramesReady += new EventHandler<AllFramesReadyEventArgs>(newsensor_AllFramesReady);
newsensor.Start();
//throw new NotImplementedException();
}
public void SetEllipsePosition(Ellipse ellipse, Joint joint)
{
Canvas.SetLeft(ellipse, (320 * joint.Position.X) + 320);
Canvas.SetTop(ellipse, (240 * -joint.Position.Y) + 240);
}
Skeleton[] skeletons = null;
void newsensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame != null)
{
if (this.skeletons == null)
{
this.skeletons = new Skeleton[skeletonFrame.SkeletonArrayLength];
}
skeletonFrame.CopySkeletonDataTo(this.skeletons);
Skeleton skeleton = this.skeletons.Where(s => s.TrackingState == SkeletonTrackingState.Tracked).FirstOrDefault();
/*if (skeleton != null)
{
// Calculate height.
// double height = Math.Round(skeleton.Height(), 2);
}*/
if (skeleton != null)
{
SetEllipsePosition(HipCenter, skeleton.Joints[JointType.HipCenter]);
SetEllipsePosition(Spine, skeleton.Joints[JointType.Spine]);
SetEllipsePosition(ShoulderCenter, skeleton.Joints[JointType.ShoulderCenter]);
SetEllipsePosition(Head, skeleton.Joints[JointType.Head]);
SetEllipsePosition(ShoulderLeft, skeleton.Joints[JointType.ShoulderLeft]);
SetEllipsePosition(ElbowLeft, skeleton.Joints[JointType.ElbowLeft]);
SetEllipsePosition(WristLeft, skeleton.Joints[JointType.WristLeft]);
SetEllipsePosition(HandLeft, skeleton.Joints[JointType.HandLeft]);
SetEllipsePosition(ShoulderRight, skeleton.Joints[JointType.ShoulderRight]);
SetEllipsePosition(ElbowRight, skeleton.Joints[JointType.ElbowRight]);
SetEllipsePosition(WristRight, skeleton.Joints[JointType.WristRight]);
SetEllipsePosition(HandRight, skeleton.Joints[JointType.HandRight]);
SetEllipsePosition(HipLeft, skeleton.Joints[JointType.HipLeft]);
SetEllipsePosition(KneeLeft, skeleton.Joints[JointType.KneeLeft]);
SetEllipsePosition(AnkleLeft, skeleton.Joints[JointType.AnkleLeft]);
SetEllipsePosition(FootLeft, skeleton.Joints[JointType.FootLeft]);
SetEllipsePosition(HipRight, skeleton.Joints[JointType.HipRight]);
SetEllipsePosition(KneeRight, skeleton.Joints[JointType.KneeRight]);
SetEllipsePosition(AnkleRight, skeleton.Joints[JointType.AnkleRight]);
SetEllipsePosition(FootRight, skeleton.Joints[JointType.FootRight]);
}
if(skeleton !=null)
{
Joint j = skeleton.Joints[JointType.Head];
if (j.TrackingState == JointTrackingState.Tracked)
{
Console.WriteLine("The output of X Y Z coordinates");
Debug.WriteLine("Head: X AXIS" + j.Position.X + ",Y AXIS \t " + j.Position.Y + ",Z AXIS\t " + j.Position.Z);
}
}
if (skeleton != null)
{
Joint j = skeleton.Joints[JointType.KneeLeft];
if (j.TrackingState == JointTrackingState.Tracked)
{
Console.WriteLine("The output of X Y Z coordinates");
Console.WriteLine("Head: X AXIS" + j.Position.X + ",Y AXIS \t " + j.Position.Y + ",Z AXIS\t " + j.Position.Z);
}
}
}
}
}
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
StopKinect(kinectSensorChooser1.Kinect);
}
void StopKinect(KinectSensor sensor)
{
if (sensor != null)
{
sensor.Stop();
}
}
}
}
XML code
<Window x:Class="Play_v_6.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="923" Loaded="Window_Loaded" Closing="Window_Closing" xmlns:my="clr-namespace:Microsoft.Samples.Kinect.WpfViewers;assembly=Microsoft.Samples.Kinect.WpfViewers">
<Grid>
<Canvas>
<my:KinectDepthViewer HorizontalAlignment="Left" Margin="12,12,0,0" Name="kinectDepthViewer1" VerticalAlignment="Top" Height="218" Width="384" Kinect="{Binding ElementName=kinectSensorChooser1, Path=Kinect}" />
<my:KinectSensorChooser HorizontalAlignment="Left" Margin="326,179,0,0" Name="kinectSensorChooser1" VerticalAlignment="Top" Width="328" />
<my:KinectSkeletonViewer HorizontalAlignment="Left" Margin="499,12,0,0" Name="kinectSkeletonViewer1" VerticalAlignment="Top" Height="229" Width="373" Kinect="{Binding ElementName=kinectSensorChooser1, Path=Kinect}" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="HipCenter"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="Spine"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="ShoulderCenter"/>
<Ellipse Height="25" Width="15" Fill="yellow" Name="Head" Canvas.Left="113" Canvas.Top="12" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="ShoulderLeft"/>
<Ellipse Height="10" Width="10" Fill="Magenta" Name="ElbowLeft"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="WristLeft"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="HandLeft"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="ShoulderRight"/>
<Ellipse Height="10" Width="10" Fill="Magenta" Name="ElbowRight"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="WristRight"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="HandRight"/>
<Ellipse Height="10" Width="10" Fill="Blue" Name="HipLeft"/>
<Ellipse Height="15" Width="10" Fill="Red" Name="KneeLeft" Canvas.Left="28" Canvas.Top="86" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="AnkleLeft" Canvas.Left="70" Canvas.Top="42" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="FootLeft" Canvas.Left="12" Canvas.Top="99" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="HipRight" Canvas.Left="118" Canvas.Top="74" />
<Ellipse Height="15" Width="10" Fill="Red" Name="KneeRight" Canvas.Left="246" Canvas.Top="20" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="AnkleRight" Canvas.Left="416" Canvas.Top="12" />
<Ellipse Height="10" Width="10" Fill="Blue" Name="FootRight" Canvas.Left="454" Canvas.Top="12" />
</Canvas>
</Grid>
</Window>- Edited by KhanAfzal Thursday, September 26, 2013 9:44 PM to get notification when someone responds to this post
Thursday, September 26, 2013 9:34 PM