You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
using KinectUtils;
|
|
using Microsoft.Kinect;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace LibMyGesturesBank
|
|
{
|
|
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.1f && 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";
|
|
}
|
|
|
|
}
|