A little Video Magic with Grax ARK
- Posted: Mar 27, 2012 at 6:00 AM
- 4,862 Views
I thought this an interesting project which shows off some of the things that you can do with the Kinect Depth and video...
Library and sample code for building augmented reality Kinect applications.
Sample code is available for WPF and XNA applications. (The WPF code has been committed and the XNA code is coming soon.)A video frame and a depth frame do not correlate directly on pixel location. This code demonstrates how to transform depth to video pixels or video to depth.
Project Information URL: http://graxark.codeplex.com/
Project Download URL: http://graxark.codeplex.com/releases/view/82151 & http://graxark.codeplex.com/releases/view/84267
Project Source URL: http://graxark.codeplex.com/SourceControl/list/changesets
void kinect_ColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
{
if (_ShuttingDown) { return; }
ColorImageFrame colorFrame = e.OpenColorImageFrame();
if (colorFrame != null)
{
colorFrame.CopyPixelDataTo(currentFrame.ColorData);
videoMerge.UpdateMainLayerColor(currentFrame);
kinectTransform.TransformColorToDepthFrame(currentFrame.ColorData, currentFrameDepthStyle.ColorData);
}
if (colorFrame != null) { colorFrame.Dispose(); }
}
void kinect_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
{
if (_ShuttingDown) { return; }
//Stopwatch watch = new Stopwatch();
//watch.Start();
DepthImageFrame depthFrame = e.OpenDepthImageFrame();
if (depthFrame != null)
{
depthFrame.CopyPixelDataTo(currentFrame.DepthData);
kinectTransform.TransformDepthMapForColorFrame(currentFrame.DepthData, videoMerge.MainLayerDepth);
Array.Copy(currentFrame.DepthData, currentFrameDepthStyle.DepthData, currentFrame.DepthData.Length);
}
if (depthFrame != null) { depthFrame.Dispose(); }
//if (watch.ElapsedMilliseconds * .030 > 1)
//{
// Debug.WriteLine("Mapping 30 frames would take " + (watch.ElapsedMilliseconds * .030).ToString());
//}
}
void kinect_AllFramesReady(object sender, AllFramesReadyEventArgs e)
{
if (_ShuttingDown) { return; }
videoMerge.MergeToOutput(kinectTransform);
videoMerge.UpdateImage(colorInputImage, depthInputImage, currentFrame);
videoMerge.UpdateOutputImage(colorOutputImage, depthOutputImage);
videoMerge.UpdateImage(depthVideoOverlayImage, depthVideoOverlayImage2, KinectVideoMerge.LayerName.Main);
videoMerge.UpdateImage(otherInputImage, null, currentFrameDepthStyle);
}Contact:
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation,
please create a new thread in our Forums,
or
Contact Us and let us know.
Follow the Discussion
Oops, something didn't work.
What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in. You need to be signed in to Channel 9 to use this feature.What does this mean?
Following an item on Channel 9 allows you to watch for new content and comments that you are interested in and view them all on your notifications page.sign up for email notifications?