Reputation: 8079
I'm using the Kinect SDK to read data in from a Kinect. At the minute I have an application which simply saves an image from the stream every few seconds and starts recording audio, however I only want this to execute code when movement is sensed (think security camera that starts recording when when movement is detected). I can't see any event which is raised in the code samples if movement is detected, the only thing even close being nui_SkeletonFrameReady which I could use (if I am correct) if a persons body is detected. Is there a simple way to go about this?
Upvotes: 0
Views: 168
Reputation: 8079
Currently there is no event raised in this scenario. What I did was subscribed to the image ready event which comes with the API and compared the previous image to the current image using the libraries at AForge.net.
Upvotes: 1
Reputation: 536
You can initialize the Kinect runtime with the RuntimeOptions.UseSkeletalTracking flag to receive skeletal tracking data from the device:
var runtime = new Runtime();
runtime.Initialize(RuntimeOptions.UseSkeletalTracking| RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseColor);
Then subscribe to the SkeletonFrameReady event:
runtime.SkeletonFrameReady += nui_SkeletonFrameReady;
This event will fire continuously and you will need to iterate through the collection of six possible skeletons in the SkeletonFrame collection to determine if any are being tracked.
void nui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
SkeletonFrame allSkeletons = e.SkeletonFrame;
//get the first tracked skeleton
SkeletonData skeleton = (from s in allSkeletons.Skeletons
where s.TrackingState == SkeletonTrackingState.Tracked
select s).FirstOrDefault();
if skeleton != null
{
// Start recording audio, etc
}
}
More details and examples are found in this Channel 9 video:
Skeletal Tracking Fundamentals
Upvotes: 0