Commit 52e43b77 authored by Alexander Krause's avatar Alexander Krause

fixed bug in jump recognition

parent b4cc24ac
......@@ -19,7 +19,7 @@ namespace ExplorVizGestureControl.Gestures
{
[DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
#region Variables
private GestureTimer timerForNextGesture;
public Boolean detectContinousGestures = false;
......@@ -28,7 +28,7 @@ namespace ExplorVizGestureControl.Gestures
private const int KEYEVENTF_EXTENDEDKEY = 0x0001; //Key down flag
private const int KEYEVENTF_KEYUP = 0x0002; //Key up flag
private const int UP = 0x26;
private const int UP = 0x26;
#endregion
#region Initialization
......@@ -54,17 +54,12 @@ namespace ExplorVizGestureControl.Gestures
{
case "Start_Reset":
if (contDetStartReset.busy) return;
contDetStartReset.startTimer();
contDetStartReset.startTimer();
Console.WriteLine("key sent");
try
{
keybd_event(UP, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(UP, 0, KEYEVENTF_KEYUP, 0);
}
catch (System.InvalidOperationException ex)
{
Console.WriteLine(ex.ToString());
}
keybd_event(UP, 0, KEYEVENTF_EXTENDEDKEY, 0);
keybd_event(UP, 0, KEYEVENTF_KEYUP, 0);
ContinuousGestureDetector.delayTimer.startTimer();
detectContinousGestures = true;
......
......@@ -30,9 +30,9 @@ namespace ExplorVizGestureControl.Gestures
private Vector3D elbowLeft;
private Vector3D elbowRight;
public Vector3D handLeft;
public Vector3D handRight;
public Vector3D handRight;
private Vector3D shoulderLeft;
public Vector3D shoulderRight;
public Vector3D shoulderRight;
public Vector3D wristRight;
public Vector3D wristLeft;
public Vector3D spineMid;
......@@ -47,11 +47,11 @@ namespace ExplorVizGestureControl.Gestures
private int maxCapacity;
private int newestOldHead = 0;
private Vector3D[] oldHeads;
private Vector3D[] headsStack;
private int[] gesturesProgress;
#endregion
......@@ -71,7 +71,7 @@ namespace ExplorVizGestureControl.Gestures
phiz = new PhIZ();
maxCapacity = 10;
oldHeads = new Vector3D[maxCapacity];
headsStack = new Vector3D[maxCapacity];
}
#endregion
......@@ -105,7 +105,7 @@ namespace ExplorVizGestureControl.Gestures
spineMid = new Vector3D(filteredJoints[jtSpineMid].X, filteredJoints[jtSpineMid].Y, filteredJoints[jtSpineMid].Z);
spineBase = new Vector3D(filteredJoints[jtSpineBase].X, filteredJoints[jtSpineBase].Y, filteredJoints[jtSpineBase].Z);
head = new Vector3D(filteredJoints[jtHead].X, filteredJoints[jtHead].Y, filteredJoints[jtHead].Z);
phiz.center = new Point(shoulderRight.X + 0.3, shoulderRight.Y);
phiz.topRightCorner = new Point(phiz.center.X + 0.2, phiz.center.Y + 0.3);
phiz.botRightCorner = new Point(phiz.center.X + 0.2, phiz.center.Y - 0.1);
......@@ -116,8 +116,11 @@ namespace ExplorVizGestureControl.Gestures
handLeftState = left;
handRightState = right;
oldHeads[newestOldHead] = head;
newestOldHead = ++newestOldHead % maxCapacity;
headsStack[newestOldHead] = head;
newestOldHead = ++newestOldHead % maxCapacity;
// newestOldHead == 0 <=> one circle <=> full array
if (newestOldHead == 0) gesturesProgress[0] = 1;
}
#endregion
......@@ -229,7 +232,7 @@ namespace ExplorVizGestureControl.Gestures
if (axis.Equals('z')) return Math.Abs(Math.Abs(handLeft.Z) - Math.Abs(handRight.Z)) <= Math.Abs(Math.Abs(shoulderLeft.Z) - Math.Abs(shoulderRight.Z)) + offset;
return false;
}
#endregion
......@@ -250,19 +253,16 @@ namespace ExplorVizGestureControl.Gestures
{
int gestureIndex = 0;
// only continue if array is full (= at least on circle)
if (newestOldHead == 9) gesturesProgress[gestureIndex] = 1;
if (gesturesProgress[gestureIndex] == 0) return false;
foreach (Vector3D oldHead in oldHeads)
{
if (head.Y > oldHead.Y + 0.2)
if (gesturesProgress[gestureIndex] == 0) return false;
foreach (Vector3D oldHead in headsStack)
{
if (head.Y > oldHead.Y + 0.1)
{
return true;
}
}
return false;
}
......
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