Commit e0739219 authored by Alexander Krause's avatar Alexander Krause

GestureDatabase = static class

parent 6342d294
......@@ -11,7 +11,7 @@ using System.Linq;
namespace ExplorVizGestureControl.Gestures
{
public class GestureDatabase
public static class GestureDatabase
{
#region Variables
......@@ -26,35 +26,35 @@ namespace ExplorVizGestureControl.Gestures
}
private IReadOnlyDictionary<string, Func<bool>> gestureDictionary;
private static IReadOnlyDictionary<string, Func<bool>> gestureDictionary;
private Vector3D elbowLeft;
private Vector3D elbowRight;
public Vector3D handLeft;
public Vector3D handRight;
private Vector3D shoulderLeft;
public Vector3D shoulderRight;
public Vector3D wristRight;
public Vector3D wristLeft;
public Vector3D spineMid;
public Vector3D spineBase;
public Vector3D head;
public Vector3D oldSpineBase;
private static Vector3D elbowLeft;
private static Vector3D elbowRight;
public static Vector3D handLeft;
public static Vector3D handRight;
private static Vector3D shoulderLeft;
public static Vector3D shoulderRight;
public static Vector3D wristRight;
public static Vector3D wristLeft;
public static Vector3D spineMid;
public static Vector3D spineBase;
public static Vector3D head;
public static Vector3D oldSpineBase;
public Vector3D handRightTip;
public Vector3D handLeftTip;
public static Vector3D handRightTip;
public static Vector3D handLeftTip;
public PhIZ phiz;
public CameraSpacePoint[] filteredJoints;
public static PhIZ phiz;
public static CameraSpacePoint[] filteredJoints;
public HandState handRightState;
public HandState handLeftState;
public static HandState handRightState;
public static HandState handLeftState;
private int maxCapacity;
private int newestOldHead = 0;
private Vector3D[] headsStack;
private static int maxCapacity;
private static int newestOldHead = 0;
private static Vector3D[] headsStack;
private int[] gesturesProgress;
private static int[] gesturesProgress;
......@@ -62,7 +62,7 @@ namespace ExplorVizGestureControl.Gestures
#region Initialization
public GestureDatabase()
static GestureDatabase()
{
Dictionary<string, Func<bool>> tempGestureDictionary = new Dictionary<string, Func<bool>>();
tempGestureDictionary.Add("Start_Reset", StartOrReset);
......@@ -83,9 +83,9 @@ namespace ExplorVizGestureControl.Gestures
#region Update Database
public void refreshJoints(CameraSpacePoint[] filteredJoints, Vector3D[] accumulatedJoint, HandState right, HandState left)
public static void refreshJoints(CameraSpacePoint[] filteredJoints, Vector3D[] accumulatedJoint, HandState right, HandState left)
{
this.filteredJoints = filteredJoints;
GestureDatabase.filteredJoints = filteredJoints;
int jtElbowLeft = (int)JointType.ElbowLeft;
int jtElbowRight = (int)JointType.ElbowRight;
......@@ -139,102 +139,89 @@ namespace ExplorVizGestureControl.Gestures
#region States
// Hand states
public bool RightHandClosed()
public static bool RightHandClosed()
{
if (this.handRightState == HandState.Closed)
{
return true;
}
else
{
return false;
}
return handRightState == HandState.Closed ? true : false;
}
public bool LeftHandClosed()
public static bool LeftHandClosed()
{
if (this.handLeftState == HandState.Closed)
{
return true;
}
else
{
return false;
}
return handLeftState == HandState.Closed ? true : false;
}
#endregion
#region Joint comparison
public Boolean RightElbowBelowRightHand()
public static Boolean RightElbowBelowRightHand()
{
return this.elbowRight.Y < this.handRight.Y;
return elbowRight.Y < handRight.Y;
}
public Boolean RightHandBelowRightShoulder()
public static Boolean RightHandBelowRightShoulder()
{
return this.handRight.Y < this.shoulderRight.Y;
return handRight.Y < shoulderRight.Y;
}
public Boolean RightHandMoreToTheRightThanRightElbow()
public static Boolean RightHandMoreToTheRightThanRightElbow()
{
return this.handRight.X > this.elbowRight.X;
return handRight.X > elbowRight.X;
}
public Boolean RightShoulderBelowRightElbow()
public static Boolean RightShoulderBelowRightElbow()
{
return this.elbowRight.Y > this.shoulderRight.Y;
return elbowRight.Y > shoulderRight.Y;
}
public Boolean LeftElbowBelowLeftHand()
public static Boolean LeftElbowBelowLeftHand()
{
return this.elbowLeft.Y < this.handLeft.Y;
return elbowLeft.Y < handLeft.Y;
}
public Boolean LeftHandBelowLeftShoulder()
public static Boolean LeftHandBelowLeftShoulder()
{
return this.handLeft.Y < this.shoulderLeft.Y;
return handLeft.Y < shoulderLeft.Y;
}
public Boolean LeftHandMoreToTheLeftThanLeftElbow()
public static Boolean LeftHandMoreToTheLeftThanLeftElbow()
{
return this.handLeft.X < this.elbowLeft.X;
return handLeft.X < elbowLeft.X;
}
public Boolean LeftShoulderBelowLeftElbow()
public static Boolean LeftShoulderBelowLeftElbow()
{
return this.elbowLeft.Y > this.shoulderLeft.Y;
return elbowLeft.Y > shoulderLeft.Y;
}
public Boolean BothHandsOpen()
public static Boolean BothHandsOpen()
{
return !LeftHandClosed() && !RightHandClosed();
}
public Boolean BothHandsClosed()
public static Boolean BothHandsClosed()
{
return LeftHandClosed() && RightHandClosed();
}
public Boolean BothHandsParallel(double maxDistanceInX)
public static Boolean BothHandsParallel(double maxDistanceInX)
{
return (Math.Abs(handRight.X - handLeft.X) < maxDistanceInX &&
Math.Abs(Math.Abs(handRight.Y) - Math.Abs(handLeft.Y)) < 0.3 &&
Math.Abs(handRight.Z - handLeft.Z) < 0.3);
}
public Boolean BothHandsAboveHead()
public static Boolean BothHandsAboveHead()
{
return handRight.Y >= head.Y && handLeft.Y >= head.Y;
}
public Boolean BothHandsAboveSpineBase()
public static Boolean BothHandsAboveSpineBase()
{
return handLeft.Y > spineBase.Y && handRight.Y > spineBase.Y;
}
public Boolean HandsHaveAcceptableDistance(double offset = 0.0, char axis = 'x')
public static Boolean HandsHaveAcceptableDistance(double offset = 0.0, char axis = 'x')
{
if (axis.Equals('x')) return Math.Abs(Math.Abs(handLeft.X) - Math.Abs(handRight.X)) <= Math.Abs(Math.Abs(shoulderLeft.X) - Math.Abs(shoulderRight.X)) + offset;
......@@ -250,17 +237,17 @@ namespace ExplorVizGestureControl.Gestures
#region Gestures
public Boolean DragObject()
public static Boolean DragObject()
{
return RightHandClosed();
}
public Boolean OpenObject()
public static Boolean OpenObject()
{
return LeftHandBelowLeftShoulder() && LeftHandClosed() && RightHandClosed();
}
public Boolean StartOrReset()
public static Boolean StartOrReset()
{
Boolean[] confidenceArray = new Boolean[maxCapacity];
......@@ -288,15 +275,15 @@ namespace ExplorVizGestureControl.Gestures
#region Getters & Setters
public IReadOnlyDictionary<string, Func<bool>> GestureDictionary
public static IReadOnlyDictionary<string, Func<bool>> GestureDictionary
{
get
{
return this.gestureDictionary;
return gestureDictionary;
}
set
{
this.gestureDictionary = value;
gestureDictionary = value;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment