63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using JeuHoy_WPF;
|
|
using Microsoft.Kinect;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
|
|
namespace JeuHoy_WPF_Natif.Model {
|
|
public class Squelette {
|
|
static private JointType[] _joints = new JointType[CstApplication.SKELETONCOUNT] {
|
|
JointType.HandLeft,
|
|
JointType.HandRight,
|
|
JointType.ElbowLeft,
|
|
JointType.ElbowRight,
|
|
JointType.FootLeft,
|
|
JointType.FootRight,
|
|
JointType.KneeRight,
|
|
JointType.KneeLeft,
|
|
JointType.SpineBase,
|
|
JointType.Neck
|
|
};
|
|
|
|
private double[] _sque = new double[CstApplication.SKELETONCOUNT * 2];
|
|
private string _rep = "?";
|
|
|
|
public string Reponse { get => _rep; set => _rep = value; }
|
|
|
|
public double[] Points => _sque;
|
|
|
|
public Squelette(KinectSensor kin, Body body, string reponse) {
|
|
Vector trans = (Vector)GetPoint(kin, body.Joints[JointType.Head].Position, new Vector(0,0));
|
|
|
|
for (int i = 0; i < CstApplication.SKELETONCOUNT; ++i) {
|
|
Point po = GetPoint(kin, body.Joints[_joints[i]].Position, trans);
|
|
|
|
_sque[i * 2] = po.X;
|
|
_sque[i * 2 + 1] = po.Y;
|
|
}
|
|
|
|
_rep = reponse;
|
|
}
|
|
|
|
private Point GetPoint(KinectSensor sensor, CameraSpacePoint position, Vector trans) {
|
|
Point point = new System.Windows.Point();
|
|
|
|
DepthSpacePoint depthPoint = sensor.CoordinateMapper.MapCameraPointToDepthSpace(position);
|
|
point.X = float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.X;
|
|
point.Y = float.IsInfinity(depthPoint.Y) ? 0.0 : depthPoint.Y;
|
|
|
|
// La Kinect pour Xbox One utilise également le SDK 2 de Microsoft, et sa résolution de profondeur est de 512x424 pixels.
|
|
//// Ainsi, la résolution de la carte de profondeur pour la Kinect pour Xbox One est également de 512x424 pixels.
|
|
point.X = point.X / 512;
|
|
point.Y = point.Y / 424;
|
|
|
|
return Point.Subtract(point, trans);
|
|
}
|
|
|
|
|
|
}
|
|
}
|