none
Trying to save an image when Skeleton is detected. RRS feed

  • Question

  • Hi all,I've been using the KinectExplore demo to learn about the Kinect, and have modified some code to notify me when a skeleton is detected, this in turn, sends a message to various XBMC installations I have dotted around the house.

    I'd like to be able to save the frame at that point as an image, but am coming up blank....literally.

    I changed the canvas object in [] to include a name, then I passed it through the following method:

    [code]

    public static void SaveCanvasToFile(Canvas surface, string filename)
        {
            Size size = new Size(surface.Width, surface.Height);

            surface.Measure(size);
            surface.Arrange(new Rect(size));

            // Create a render bitmap and push the surface to it
            RenderTargetBitmap renderBitmap =
              new RenderTargetBitmap(
                (int)size.Width,
                (int)size.Height,
                96d,
                96d,
                PixelFormats.Pbgra32);
            renderBitmap.Render(surface);

            // Create a file stream for saving image
            using (FileStream outStream = new FileStream(filename, FileMode.Create))
            {               
                BmpBitmapEncoder encoder = new BmpBitmapEncoder();
                // push the rendered bitmap to it
                encoder.Frames.Add(BitmapFrame.Create(renderBitmap));
                // save the data to the stream
                encoder.Save(outStream);
            }}
    [/code]

    ...but all I seem to save is a transparent PNG.

    Can someone kindly point me in the right direction, I'm banging me head against the wall!

    Regards,

    Dave.

    Monday, October 22, 2012 1:52 PM