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

SNAGHTML28bd6d0a

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:

Tags:

Follow the Discussion

Comments Closed

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.