using KinectUtils; using Microsoft.Kinect; using System; using System.Collections.Generic; using System.Linq; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; namespace MyGesturesBank { public class ClapHands : Gesture { protected override bool TestInitialConditions(Body body) { // Les conditions initiales ne sont pas strictes pour un clap, on commence donc directement avec TestPosture et TestRunningGesture return true; } protected override bool TestPosture(Body body) { var handRight = body.Joints[JointType.HandRight].Position; var handLeft = body.Joints[JointType.HandLeft].Position; // Vérifie si les mains sont à une hauteur similaire et devant le corps return Math.Abs(handRight.Y - handLeft.Y) < 0.5f && handRight.Z < 0.5f && handLeft.Z < 0.5f; } protected override bool TestRunningGesture(Body body) { var handRight = body.Joints[JointType.HandRight].Position; var handLeft = body.Joints[JointType.HandLeft].Position; // Vérifie si les mains se sont rencontrées au centre return Math.Abs(handRight.X - handLeft.X) < 0.1f; } protected override bool TestEndConditions(Body body) { // Le clap est un geste instantané, donc si les conditions sont remplies une fois, le geste est considéré comme terminé return true; } public override string GestureName => "Clap Hands"; } }