保存骨架和深度摄像机数据。 [英] Saving skeletal and Depth camera data.

查看:58
本文介绍了保存骨架和深度摄像机数据。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。如果之前已经100%回答,我很抱歉发帖。我看了其他主题,但我还没有完全理解,可能是因为我对c#很新。

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#.

我正在使用Microsoft sdk和visual studio c#2010

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

我正在开展一个涉及骨架和深度图像同时确定患者的体型。我正在尝试使用kinect拍摄两张图像,然后形成一个2D身体遮罩(基本上只需要获取深度数据并让它看起来很漂亮)。我已经有了获取深度和骨架数据的代码。具体如下:

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




我想知道我怎么会能够添加一种方法来将骨架和深度图像保存为png或值矩阵。



如果这看起来超级小,我很抱歉。就像我说我是新来的... ...


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...

推荐答案

您提供的代码包括选择Kinect传感器。 

The code you presented covers choosing a Kinect sensor. 

根据您的既定目标,我建议您查看Depth Basics SDK示例代码。 如果您感兴趣的是2D图像,则显示"形状"。对于播放器/用户,那么你应该启用深度和骨架流,但是你不需要
来处理骨架帧事件。 只需处理深度帧事件(如Depth Basics SDK示例中所示),然后查看玩家编号。  (要从深度流中获取玩家编号数据,必须启用骨架流,即使您实际上从未
查看骨架帧数据。) 如果玩家编号非零,则表示Kinect认为此时有人。 

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. 

在Depth Basics示例中,代码将深度值转换为灰度值并将其放入位掩码中以供显示。 在您的情况下,您将改为查看玩家的号码,设置具有非零玩家
数字的积分到您选择的颜色。  (如果框架中有多个玩家,您可能希望为每个玩家编号使用不同的颜色,这样您就可以在图像中区分它们。) 在您查看了帧中的所有点后,位图中的
着色点包含非零玩家数字,您将拥有一个显示"形状"的2D图像。播放器。

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.


这篇关于保存骨架和深度摄像机数据。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆