This commit is contained in:
MarcEricMartel
2023-05-03 11:57:03 -04:00
parent 0388e18999
commit 241d2a6ffb
3 changed files with 190 additions and 32 deletions

View File

@@ -9,7 +9,7 @@ using System.Windows;
namespace JeuHoy_WPF_Natif.Model {
public class Squelette {
static private JointType[] _joints = new JointType[CstApplication.SKELETONCOUNT] {
static public readonly JointType[] Joints = new JointType[CstApplication.SKELETONCOUNT] {
JointType.HandLeft,
JointType.HandRight,
JointType.ElbowLeft,
@@ -29,38 +29,9 @@ namespace JeuHoy_WPF_Natif.Model {
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;
}
if (reponse.Length == 1)
_rep = reponse;
}
public Squelette(double[] body, string reponse) {
_sque = body;
_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);
}
}
}
}