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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Leave a comment