//A debe estar a la altura de B private bool sameHeightAB(BodyPartCoords A, BodyPartCoords B) { bool same = false; double max, min; max = B.y + 10; min = B.y - 10; if (A.y > min && A.y < max) same = true; return same; }
private bool touchAB(BodyPartCoords A, BodyPartCoords B) { bool tocado = false; double distancia = 0; distancia = (A.x - B.x) + (A.y - B.y); if (Math.Abs(distancia) > 1.20f) tocado = false; else tocado = true; return tocado; }
/// <summary> /// Método que devuelve true si la mano derecha esta tocando la cadera(por la parte derecha) y false en caso contrario. /// </summary> /// <returns></returns> private bool RightHandOnHip() { double distance = 0; BodyPartCoords RHand = new BodyPartCoords(jointPoints[JointType.HandRight].X, jointPoints[JointType.HandRight].Y, 0.0); BodyPartCoords Hip = new BodyPartCoords(jointPoints[JointType.HipRight].X, jointPoints[JointType.HipRight].Y, 0.0); distance = (RHand.x - Hip.x) + (RHand.y - Hip.y); if (Math.Abs(distance) > 0.25f) return false; else return true; }
private bool PosturaStart() { BodyPartCoords LeftHand = new BodyPartCoords(jointPoints[JointType.HandLeft].X, jointPoints[JointType.HandLeft].Y, 0.0); BodyPartCoords Ball = new BodyPartCoords(jointPoints[JointType.Head].X, (jointPoints[JointType.Head].Y) - 35.0, 0.0); BodyPartCoords RightHand = new BodyPartCoords(jointPoints[JointType.HandRight].X, jointPoints[JointType.HandRight].Y, 0.0); bool aux1 = false; aux1 = touchAB(LeftHand, Ball); if (!aux1) aux1 = touchAB(RightHand, Ball); return aux1; }
private bool PosturaFinal() { bool done = false; BodyPartCoords LeftHand = new BodyPartCoords(jointPoints[JointType.HandLeft].X, jointPoints[JointType.HandLeft].Y, 0.0); BodyPartCoords RightHand = new BodyPartCoords(jointPoints[JointType.HandRight].X, jointPoints[JointType.HandRight].Y, 0.0); BodyPartCoords Hip = new BodyPartCoords(jointPoints[JointType.SpineBase].X, jointPoints[JointType.SpineBase].Y, 0.0); if (touchAB(LeftHand, RightHand) && sameHeightAB(RightHand, Hip)) done = true; return done; }
private bool Postura2() { bool detectado = false; //Partes necesitadas BodyPartCoords RightFoot = new BodyPartCoords(jointPoints[JointType.FootRight].X, jointPoints[JointType.FootRight].Y, 0.0); BodyPartCoords RightHip = new BodyPartCoords(jointPoints[JointType.HipRight].X, jointPoints[JointType.HipRight].Y, 0.0); BodyPartCoords RightKnee = new BodyPartCoords(jointPoints[JointType.KneeRight].X, jointPoints[JointType.KneeRight].Y, 0.0); BodyPartCoords RightAnkle = new BodyPartCoords(jointPoints[JointType.AnkleRight].X, jointPoints[JointType.AnkleRight].Y, 0.0); BodyPartCoords RightHand = new BodyPartCoords(jointPoints[JointType.HandRight].X, jointPoints[JointType.HandRight].Y, 0.0); BodyPartCoords Hip = new BodyPartCoords(jointPoints[JointType.SpineBase].X, jointPoints[JointType.SpineBase].Y, 0.0); BodyPartCoords RightElbow = new BodyPartCoords(jointPoints[JointType.ElbowRight].X, jointPoints[JointType.ElbowRight].Y, 0.0); BodyPartCoords LeftElbow = new BodyPartCoords(jointPoints[JointType.ElbowLeft].X, jointPoints[JointType.ElbowLeft].Y, 0.0); BodyPartCoords MediaEspalda = new BodyPartCoords(jointPoints[JointType.SpineMid].X, jointPoints[JointType.SpineMid].Y - 10, 0.0); /* //Variables para los ángulos de la pose double rodillaIzq = 0; double brazoIzq = 0; double brazoDer = 0; //Ángulos //private double GetAngulo(double[] v1, double[] v2) //private double[] GetVector(double p1_x, double p1_y, double p2_x, double p2_y) //Vector rodilla-cadera double[] vknee_hip = GetVector(RightKnee.x, RightKnee.y, RightHip.x,RightHip.y ); double[] vknee_ankle = GetVector(RightKnee.x, RightKnee.y, RightAnkle.x, RightAnkle.y); double knee_hip_ankle_degree = GetAngulo(vknee_hip, vknee_ankle); if (knee_hip_ankle_degree > 80 && knee_hip_ankle_degree < 110) //if(knee_hip_ankle_degree == 90) detectado = true; */ if (sameHeightAB(RightKnee, Hip) && sameHeightAB(LeftElbow, RightElbow)) detectado = true; return detectado; }
/// <summary> /// Método que devuelve true si la mano izquierda esta tocando la cabeza y false en caso contrario. /// </summary> private bool LeftHandOnHead() { double distance = 0; BodyPartCoords LHand = new BodyPartCoords(jointPoints[JointType.HandLeft].X, jointPoints[JointType.HandLeft].Y, 0.0); BodyPartCoords Head = new BodyPartCoords(jointPoints[JointType.Head].X, jointPoints[JointType.Head].Y, 0.0); distance = (LHand.x - Head.x) + (LHand.y - Head.y); if (Math.Abs(distance) > 0.25f) return false; else return true; }