|
@@ -42,16 +42,6 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
|
foreach (Hand palmHand in palmHands)
|
|
|
{
|
|
|
ConvexityDefect thumbDefect = palmHand.ThumbDefect;
|
|
|
- /*
|
|
|
- Vector2D handLength = 1.5f * thumbDefect.VectorLong;
|
|
|
- Vector2D handWidth = 0.45f * handLength.getOrthogonal(palmHand.Side == HandSide.Right);
|
|
|
-
|
|
|
- Vector2D fingersUpperOld = thumbDefect.Inner + 0.8f * handLength;
|
|
|
- Vector2D wristUpperOld = thumbDefect.Inner - 0.2f * handLength;
|
|
|
- Vector2D wristLowerOld = wristUpperOld + handWidth;
|
|
|
- Vector2D fingersLowerOld = wristLowerOld + 0.75f * handLength - 0.3f * handWidth;
|
|
|
- */
|
|
|
-
|
|
|
Vector2D directionWristFinger = thumbDefect.VectorLong.normalize();
|
|
|
Vector2D directionFingerWrist = directionWristFinger.getInverse();
|
|
|
Vector2D directionUpperLower = directionWristFinger.getOrthogonal(palmHand.Side == HandSide.Right);
|
|
@@ -59,7 +49,7 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
|
|
|
|
//handLength
|
|
|
Vector2D handLength = 1.5f * thumbDefect.VectorLong;
|
|
|
-
|
|
|
+
|
|
|
//fingersUpper
|
|
|
Vector2D fingersUpper = thumbDefect.OuterLong;
|
|
|
bool handBelow = true;
|
|
@@ -68,7 +58,7 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
|
fingersUpper += directionWristFinger;
|
|
|
Vector2D below = fingersUpper.copy();
|
|
|
bool handBelowFound = false;
|
|
|
- while (!handBelowFound && below.getDistanceTo(fingersUpper) < 2*Parameters.FingerMaxWidth && below.isInBound())
|
|
|
+ while (!handBelowFound && below.getDistanceTo(fingersUpper) < 2 * Parameters.FingerMaxWidth && below.isInBound())
|
|
|
{
|
|
|
below += directionUpperLower;
|
|
|
handBelowFound = palmHand.isInside(below);
|
|
@@ -77,15 +67,12 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
|
}
|
|
|
|
|
|
//wristUpper
|
|
|
- Vector2D wristUpper = thumbDefect.Inner + 5*directionFingerWrist;
|
|
|
+ Vector2D wristUpper = thumbDefect.Inner + 5 * directionFingerWrist;
|
|
|
while (wristUpper.isInBound() && palmHand.isInside(wristUpper))
|
|
|
wristUpper += directionFingerWrist;
|
|
|
|
|
|
//handWidth
|
|
|
- Vector2D lower = thumbDefect.Inner + 10 * directionUpperLower;
|
|
|
- while (lower.isInBound() && palmHand.isInside(lower))
|
|
|
- lower += directionUpperLower;
|
|
|
- Vector2D handWidth = (lower - thumbDefect.Inner);
|
|
|
+ Vector2D handWidth = getHandWidth(palmHand, directionUpperLower);
|
|
|
|
|
|
//wristLower
|
|
|
Vector2D wristLower = wristUpper + handWidth;
|
|
@@ -100,5 +87,32 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
|
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private Vector2D getHandWidth(Hand palmHand, Vector2D directionUpperLower)
|
|
|
+ {
|
|
|
+ Vector2D lineStart = palmHand.ThumbDefect.Inner;
|
|
|
+ Vector2D lineEnd = palmHand.ThumbDefect.OuterLong;
|
|
|
+ Vector2D step = (lineEnd - lineStart) / Parameters.PalmNumPositionsForHandWidth;
|
|
|
+ Vector2D currentStart = lineStart;
|
|
|
+
|
|
|
+ Vector2D maxWidth = null;
|
|
|
+ float maxWidthLength = float.MinValue;
|
|
|
+
|
|
|
+ for (int i = 0; i < Parameters.PalmNumPositionsForHandWidth; i++)
|
|
|
+ {
|
|
|
+ Vector2D lower = currentStart + 10 * directionUpperLower;
|
|
|
+ while (lower.isInBound() && palmHand.isInside(lower))
|
|
|
+ lower += directionUpperLower;
|
|
|
+ Vector2D width = (lower - currentStart);
|
|
|
+ float length = width.Length;
|
|
|
+ if (length > maxWidthLength)
|
|
|
+ {
|
|
|
+ maxWidth = width;
|
|
|
+ maxWidthLength = length;
|
|
|
+ }
|
|
|
+ currentStart += step;
|
|
|
+ }
|
|
|
+ return maxWidth;
|
|
|
+ }
|
|
|
}
|
|
|
}
|