A little Video Magic with Grax ARK


I thought this an interesting project which shows off some of the things that you can do with the Kinect Depth and video...

Grax ARK (Augmented Reality with Kinect)

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

            DepthImageFrame depthFrame = e.OpenDepthImageFrame();

            if (depthFrame != null)
                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.UpdateImage(colorInputImage, depthInputImage, currentFrame);
            videoMerge.UpdateOutputImage(colorOutputImage, depthOutputImage);

            videoMerge.UpdateImage(depthVideoOverlayImage, depthVideoOverlayImage2, KinectVideoMerge.LayerName.Main);
            videoMerge.UpdateImage(otherInputImage, null, currentFrameDepthStyle);