本文档为个人博客文档系统的备份版本、作者:小游、作者博客:点击访问
下面我们来一个比较复杂的,bodybasic的显示。这个就是显示骨骼数据。
这里我就只做备注,不自己写demo了
//------------------------------------------------------------------------------
// <copyright file="MainWindow.xaml.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace Microsoft.Samples.Kinect.BodyBasics
{
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Microsoft.Kinect;
/// <summary>
/// Interaction logic for MainWindow
/// </summary>
public partial class MainWindow : Window, INotifyPropertyChanged
{
/// <summary>
/// Radius of drawn hand circles
/// </summary>
///显示手的范围-圆角的尺寸
private const double HandSize = 30;
/// <summary>
/// Thickness of drawn joint lines
/// </summary>
/// 线的粗细
private const double JointThickness = 3;
/// <summary>
/// Thickness of clip edge rectangles
/// </summary>
/// 线的角度
private const double ClipBoundsThickness = 10;
/// <summary>
/// Constant for clamping Z values of camera space points from being negative
/// </summary>
/// z轴的位置
private const float InferredZPositionClamp = 0.1f;
/// <summary>
/// Brush used for drawing hands that are currently tracked as closed
/// </summary>
/// 当手闭合时的颜色
private readonly Brush handClosedBrush = new SolidColorBrush(Color.FromArgb(128, 255, 0, 0));
/// <summary>
/// Brush used for drawing hands that are currently tracked as opened
/// </summary>
/// 手张开时的颜色
private readonly Brush handOpenBrush = new SolidColorBrush(Color.FromArgb(128, 0, 255, 0));
/// <summary>
/// Brush used for drawing hands that are currently tracked as in lasso (pointer) position
/// </summary>
/// 链接点的颜色
private readonly Brush handLassoBrush = new SolidColorBrush(Color.FromArgb(128, 0, 0, 255));
/// <summary>
/// Brush used for drawing joints that are currently tracked
/// </summary>
/// 骨骼的颜色
private readonly Brush trackedJointBrush = new SolidColorBrush(Color.FromArgb(255, 68, 192, 68));
/// <summary>
/// Brush used for drawing joints that are currently inferred
/// </summary>
/// 当前推断出的用于绘制关节的画笔
private readonly Brush inferredJointBrush = Brushes.Yellow;
/// <summary>
/// Pen used for drawing bones that are currently inferred
/// </summary>
/// 用于绘制当前推断的骨骼的笔
private readonly Pen inferredBonePen = new Pen(Brushes.Gray, 1);
/// <summary>
/// Drawing group for body rendering output
/// </summary>
/// drawinggroup对象
private DrawingGroup drawingGroup;
/// <summary>
/// Drawing image that we will display
/// </summary>
/// image对象
private DrawingImage imageSource;
/// <summary>
/// Active Kinect sensor
/// </summary>
/// 传感器对象
private KinectSensor kinectSensor = null;
/// <summary>
/// Coordinate mapper to map one type of point to another
/// </summary>
/// 坐标映射器将一种类型的点映射到另一种类型
private CoordinateMapper coordinateMapper = null;
/// <summary>
/// Reader for body frames
/// </summary>
/// 身体结构的对象
private BodyFrameReader bodyFrameReader = null;
/// <summary>
/// Array for the bodies
/// </summary>
/// 身体的数组
private Body[] bodies = null;
/// <summary>
/// definition of bones
/// </summary>
/// 骨头的定义
private List<Tuple<JointType, JointType>> bones;
/// <summary>
/// Width of display (depth space)
/// </summary>
/// 显示的高度
private int displayWidth;
/// <summary>
/// Height of display (depth space)
/// </summary>
/// 显示的宽度
private int displayHeight;
/// <summary>
/// List of colors for each body tracked
/// </summary>
/// 身体的颜色
private List<Pen> bodyColors;
/// <summary>
/// Current status text to display
/// </summary>
private string statusText = null;
/// <summary>
/// Initializes a new instance of the MainWindow class.
/// </summary>
public MainWindow()
{
// one sensor is currently supported 获取传感对象
this.kinectSensor = KinectSensor.GetDefault();
// get the coordinate mapper 获取坐标映射
this.coordinateMapper = this.kinectSensor.CoordinateMapper;
// get the depth (display) extents 获取深度数据
FrameDescription frameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
// get size of joint space 获取
this.displayWidth = frameDescription.Width;
this.displayHeight = frameDescription.Height;
// open the reader for the body frames 获取关节空间的大小
this.bodyFrameReader = this.kinectSensor.BodyFrameSource.OpenReader();
// a bone defined as a line between two joints 新建关节list