Hello!

Some time ago I wrote a post about the importance of properly destroy the objects of the KinectSdk when you close an app. The lesson today is similar, but bounded to work with a Frame.

For example, the following piece of code shows 2 ways of processing a FRAME with KinectSDK V2


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);
}
}
}

The function between lines 1 and 19, used the frame within a using() and 2nd option does not. The strange thing is that the 2nd option does not give an error or anything. However when not destroyed the dmard, it never returns to process a new frame with what the Kinect information process is stopped for this application.

Lesson learned live!

Saludos @ Home

El Bruno

image image image Google

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading