Skip to content

Instantly share code, notes, and snippets.

@elbruno
Created June 10, 2014 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elbruno/c045f98f9c0d7b140831 to your computer and use it in GitHub Desktop.
Save elbruno/c045f98f9c0d7b140831 to your computer and use it in GitHub Desktop.
KinectSdk V2, be sure of lifecycle of objects
static void _bodyFrameReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
{
var frame = e.FrameReference.AcquireFrame();
if (null == frame) return;
using (frame)
{
frame.GetAndRefreshBodyData(_bodies);
foreach (var body in _bodies)
{
if (null != body && body.IsTracked)
{
var msg = "Left:" + body.HandLeftState + " Right:" + body.HandRightState;
Console.WriteLine(msg);
}
}
}
}
static void _bodyFrameReader_FrameArrived(object sender, BodyFrameArrivedEventArgs e)
{
var frame = e.FrameReference.AcquireFrame();
if (null == frame) return;
frame.GetAndRefreshBodyData(_bodies);
foreach (var body in _bodies)
{
if (null != body && body.IsTracked)
{
var msg = "Left:" + body.HandLeftState + " Right:" + body.HandRightState;
Console.WriteLine(msg);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment