none
Saving skeletal and Depth camera data. RRS feed

  • Question

  • Hello. I'm sorry to post this if it's been 100% answered before. I looked at other topics but I'm not fully understanding, probably because I'm very new to c#.

    I'm using Microsoft sdk and visual studio c# 2010

    I'm working on a project that involves taking both a skeletal and depth image simultaneously to determine body type of a patient. I'm trying to use the kinect to take both images and then form a 2D body mask (basically just take depth data and make it look nice). I already have the code to take the depth and skeletal data. Which is as follows:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    using Microsoft.Kinect;
    
    namespace WpfApplicationKinectSkeletonTracking
    {
        /// <summary>
        /// Interaction logic for MainWindow.xaml
        /// </summary>
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
    
            private void Window_Loaded(object sender, RoutedEventArgs e)
            {
                kinectSensorChooser1.KinectSensorChanged += new DependencyPropertyChangedEventHandler(kinectSensorChooser1_KinectSensorChanged);
            }
    
            void kinectSensorChooser1_KinectSensorChanged(object sender, DependencyPropertyChangedEventArgs e)
            {
                KinectSensor oldSensor = (KinectSensor)e.OldValue;
                StopKinect(oldSensor);
    
                KinectSensor newSensor = (KinectSensor)e.NewValue;
    
                newSensor.DepthStream.Enable();
                newSensor.SkeletonStream.Enable();
    
                try
                { newSensor.Start(); }
                catch (System.IO.IOException)
                { kinectSensorChooser1.AppConflictOccurred(); }
            }
    
            private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
            {
                StopKinect(kinectSensorChooser1.Kinect);
            }
    
            void StopKinect(KinectSensor sensor)
            {
                if (sensor != null)
                {
                    sensor.Stop();
                    sensor.AudioSource.Stop();
                }
            }
        }
    }
    

    I was wondering how would I be able to add a way to save the both the skeletal and depth image as either png's or a matrix of values.

    I'm sorry if this seems super elementary. Like I said I'm new to this...

    Wednesday, December 5, 2012 7:18 AM

All replies

  • The code you presented covers choosing a Kinect sensor. 

    Based on your stated goal, I suggest that you look at the Depth Basics SDK sample code.  If all you're interested in is a 2D image showing the "shape" of the player/user, then you should enable both depth and skeleton streams, but you don't need to handle skeleton frame events.  Just handle the depth frame events (as in the Depth Basics SDK sample), and look at the player number.  (To get player number data from the depth stream, the skeleton stream must be enabled, even if you never actually look at the skeleton frame data.)  If the player number is non-zero, it means the Kinect believes there is a person at that point. 

    In the Depth Basics sample, the code converts the depth value to a grayscale value and puts that into the bitmask for display.  In your case, you'll instead be looking at the player number, setting points that have non-zero player numbers to a color of your choosing.  (If there is more than one player in the frame, you would probably want to use a different color for each player number, so you can tell them apart in the image.)  After you've looked at all points in the frame, coloring points in your bitmap that contain non-zero player numbers, you'll have a 2D image showing the "shape" of the player.


    • Edited by kengr Sunday, December 9, 2012 8:50 PM fix formatting
    • Proposed as answer by kengr Sunday, December 9, 2012 9:27 PM
    Sunday, December 9, 2012 8:49 PM
  • Try using Gesture Studio (http://gesturestudio.ca) it allows you to save this data in files for later use. 


    Wednesday, December 19, 2012 3:32 PM