using Microsoft.Kinect; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace LibMyGesturesBank { public class PostureHandsOnHead : Posture { protected override bool TestPosture(Body body) { // Condition pour la main droite proche de la tête bool rightHandNearHead = IsHandNearHead(body.Joints[JointType.HandRight], body.Joints[JointType.Head]); // Condition pour la main gauche proche de la tête bool leftHandNearHead = IsHandNearHead(body.Joints[JointType.HandLeft], body.Joints[JointType.Head]); return rightHandNearHead && leftHandNearHead; } private bool IsHandNearHead(Joint hand, Joint head) { // Exemple de condition : la main est à moins de 30 cm de la tête return Math.Sqrt( Math.Pow(hand.Position.X - head.Position.X, 2) + Math.Pow(hand.Position.Y - head.Position.Y, 2) + Math.Pow(hand.Position.Z - head.Position.Z, 2)) < 0.3; } public override string GestureName => "Hands On Head"; } }