Commit f6e6b17f authored by Alexander Krause's avatar Alexander Krause

overhaul of rotation

parent 2c3f9c4b
......@@ -37,6 +37,7 @@ namespace ExplorVizGestureControl.Gestures
private Dictionary<string, double> dynamicValues = new Dictionary<string, double>();
private float rightHandAnchorLength;
private float leftHandAnchorY;
private int selectionStatus = 0;
#endregion
......@@ -52,7 +53,7 @@ namespace ExplorVizGestureControl.Gestures
dynamicValues.Add("zoomVelocity", 250);
dynamicValues.Add("rotationVelocityX", 2000);
dynamicValues.Add("rotationVelocityY", 1000);
dynamicValues.Add("rotationYActivation", 0.12);
dynamicValues.Add("rotationYActivation", 0.04);
scrollTimer = new GestureTimer(dynamicValues["zoomVelocity"]);
delayTimer = new GestureTimer(2000);
......@@ -91,72 +92,33 @@ namespace ExplorVizGestureControl.Gestures
if (key.Equals("zoomVelocity")) scrollTimer.changeTimerCycle(value);
}
float oldZZ;
float oldYY;
private void HandleRotation()
{
//if (gripActive) return;
if (!rotationActive)
{
//if (GestureDatabase.ActivateRotation(2.0f))
if (GestureDatabase.HandsAboveSpineBase(1))
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
rotationActive = true;
}
else { return; }
}
if (gripActive) return;
if (GestureDatabase.LeftHandClosed())
{
/*if (rotationActive && !GestureDatabase.HandsAboveSpineBase(1, 0.1f))
if (!rotationActive)
{
rotationActive = false;
mouse_event(MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0);
return;
}*/
double distanceZ = 0;
double distanceY = 0;
/*double distanceZHands = GestureDatabase.Joints[(int)JointType.HandLeft].Z - GestureDatabase.Joints[(int)JointType.HandRight].Z;
double distanceYHands = GestureDatabase.Joints[(int)JointType.HandLeft].Y - GestureDatabase.Joints[(int)JointType.HandRight].Y;
int yDetection = 0;
float handsAbsDistanceY = Math.Abs(Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y) - Math.Abs(GestureDatabase.Joints[(int)JointType.HandRight].Y));
if (handsAbsDistanceY > dynamicValues["rotationYActivation"]) yDetection = (int)dynamicValues["rotationVelocityY"];
distanceZ = distanceZHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Z - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Z);
distanceY = distanceYHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Y);
int moveX = (int)(distanceZ * dynamicValues["rotationVelocityX"]);
int moveY = (int)(distanceY * yDetection);*/
if (GestureDatabase.HandsAboveSpineBase("left"))
{
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
leftHandAnchorY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
rotationActive = true;
}
else { return; }
}
float distanceZHands = GestureDatabase.Joints[(int)JointType.HandLeft].X - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].X;
float distanceXHands = GestureDatabase.Joints[(int)JointType.HandLeft].X - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].X;
float distanceYHands = GestureDatabase.Joints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y;
int yDetection = 0;
//float handsAbsDistanceY = Math.Abs(Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y) - Math.Abs(GestureDatabase.Joints[(int)JointType.HandRight].Y));
//if (handsAbsDistanceY > dynamicValues["rotationYActivation"]) yDetection = (int)dynamicValues["rotationVelocityY"];
yDetection = (int)dynamicValues["rotationVelocityY"];
//distanceZ = distanceZHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Z - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Z);
//distanceY = distanceYHands - (GestureDatabase.PreviousFrameJoints[(int)JointType.HandLeft].Y - GestureDatabase.PreviousFrameJoints[(int)JointType.HandRight].Y);
//distanceZ = distanceZHands;
// distanceY = distanceYHands;
float currentlyHandLeftY = Math.Abs(GestureDatabase.Joints[(int)JointType.HandLeft].Y);
//oldZZ = distanceZHands;
//oldYY = distanceYHands;
if (Math.Abs(currentlyHandLeftY - leftHandAnchorY) > (float)dynamicValues["rotationYActivation"]) yDetection = (int)dynamicValues["rotationVelocityY"];
int moveX = (int)(distanceZHands * dynamicValues["rotationVelocityX"]);
int moveX = (int)(distanceXHands * dynamicValues["rotationVelocityX"]);
int moveY = (int)(distanceYHands * yDetection);
Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y) + new Size(moveX, -moveY);
......
......@@ -197,23 +197,29 @@ namespace ExplorVizGestureControl.Gestures
joints[(int)JointType.HandLeft].Y >= joints[(int)JointType.Head].Y;
}
public static Boolean HandsAboveSpineBase(int cases = 2, float spineBaseOffset = 0.0f)
public static Boolean HandsAboveSpineBase(String cases = "both", float spineBaseOffset = 0.0f)
{
if (cases == 1) return joints[(int)JointType.HandLeft].Y >
if (cases.Equals("at_least_one")) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset ||
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases == 2) return joints[(int)JointType.HandLeft].Y >
if (cases.Equals("both")) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset &&
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases == 3) return joints[(int)JointType.HandLeft].Y >
if (cases.Equals("only_one")) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset ^
joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases.Equals("left")) return joints[(int)JointType.HandLeft].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
if (cases.Equals("right")) return joints[(int)JointType.HandRight].Y >
joints[(int)JointType.SpineBase].Y + spineBaseOffset;
return false;
}
......@@ -272,17 +278,6 @@ namespace ExplorVizGestureControl.Gestures
return LeftHandBelowLeftShoulder() && LeftHandClosed() && RightHandClosed();
}
public static Boolean ActivateRotation(float maxDistanceX = 1.0f)
{
return (Math.Abs(Math.Abs(joints[(int)JointType.HandRight].X) - Math.Abs(joints[(int)JointType.HandLeft].X)) < maxDistanceX &&
Math.Abs(Math.Abs(joints[(int)JointType.HandRight].Y) - Math.Abs(joints[(int)JointType.HandLeft].Y)) < 0.05f &&
Math.Abs(Math.Abs(joints[(int)JointType.HandRight].Z) - Math.Abs(joints[(int)JointType.HandLeft].Z)) < 0.05f) &&
HandsAboveSpineBase() &&
RightHandBelowRightShoulder() &&
LeftHandBelowLeftShoulder() &&
HandsHaveMinDistance(0.05f);
}
public static Boolean StartOrReset()
{
Boolean[] confidenceArray = new Boolean[maxCapacity];
......
......@@ -134,14 +134,14 @@
<TextBox
Style="{StaticResource DynamicValues}"
Name="rotationYActivation"
Text="0.12"
Text="0.04"
KeyDown="OnKeyDownHandler">
<TextBox.ToolTip>
<ToolTip>
<StackPanel>
<Label FontWeight="Bold" Content="Distance (in cm) for y-axis activation"/>
<Label FontWeight="Bold" Content="Distance (in cm) for y-axis activation (rotation)"/>
<Label FontWeight="Thin" Content="Smaller values lead to fast-response detection."/>
<Label Content="Standard value: 500"/>
<Label Content="Standard value: 0.04"/>
</StackPanel>
</ToolTip>
</TextBox.ToolTip>
......
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2981D8CCF2323F86346A1F0B30824AC0"
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "9A4B827C61A655BE277A868D4DBD1233"
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
......
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "2981D8CCF2323F86346A1F0B30824AC0"
#pragma checksum "..\..\MainWindow.xaml" "{406ea660-64cf-4c82-b6f0-42d48172a799}" "9A4B827C61A655BE277A868D4DBD1233"
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
......
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