|
@@ -152,10 +152,10 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Vector2D dirStart = direction.getOrthogonal(true);
|
|
|
Vector2D dirEnd = direction.getOrthogonal(false);
|
|
|
|
|
|
- Vector2D start = edgeImageAdapted.findNextEdge(position, dirStart, Constants.FingerMaxSize);
|
|
|
+ Vector2D start = edgeImageAdapted.findNextEdge(position, dirStart, Constants.FingerMaxWidth);
|
|
|
if (start == null) return null;
|
|
|
|
|
|
- Vector2D end = edgeImageAdapted.findNextEdge(position, dirEnd, Constants.FingerMaxSize);
|
|
|
+ Vector2D end = edgeImageAdapted.findNextEdge(position, dirEnd, Constants.FingerMaxWidth);
|
|
|
if (end == null) return null;
|
|
|
|
|
|
return getFingerSlice(start, end);
|
|
@@ -163,7 +163,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
private FingerSlice findFingerSliceFromStartEdge(Vector2D start, Vector2D direction)
|
|
|
{
|
|
|
Vector2D searchStart = start + Constants.FingerSliceOverlapFactor * direction;
|
|
|
- Vector2D end = edgeImageAdapted.findNextEdge(searchStart, direction, Constants.FingerMaxSize);
|
|
|
+ Vector2D end = edgeImageAdapted.findNextEdge(searchStart, direction, Constants.FingerMaxWidth);
|
|
|
if (end == null) return null;
|
|
|
|
|
|
return getFingerSlice(start, end);
|
|
@@ -177,7 +177,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Vector2D behindEnd = (end + Constants.FingerSliceOverlapFactor * direction).moveInBound(Vector2D.Zero, depthImage.BottomRight, directionInv);
|
|
|
|
|
|
FingerSlice slice = new FingerSlice(beforeStart, behindEnd);
|
|
|
- if (slice.Length >= Constants.FingerMinSize && slice.Length <= Constants.FingerMaxSize && fingerSliceDepthTest(slice))
|
|
|
+ if (slice.Length >= Constants.FingerMinWidth && slice.Length <= Constants.FingerMaxWidth && fingerSliceDepthTest(slice))
|
|
|
return slice;
|
|
|
|
|
|
return null;
|
|
@@ -223,54 +223,16 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
return (minDepthDifference < Constants.FingerCrippleOutMinDifference);
|
|
|
}
|
|
|
|
|
|
- private FingerSlice findOutSlice(Vector2D start, Vector2D direction)
|
|
|
- {
|
|
|
- Vector2D dirOrth1 = direction.getOrthogonal(true);
|
|
|
- Vector2D dirOrth2 = direction.getOrthogonal(false);
|
|
|
-
|
|
|
- Vector2D outPoint = (start + Constants.FingerOutSliceFactor * direction).moveInBound(Vector2D.Zero, depthImage.BottomRight, direction.getInverse());
|
|
|
- Vector2D p1 = edgeImageOriginal.findNextEdge(outPoint, dirOrth1, 0, true, false);
|
|
|
- Vector2D p2 = edgeImageOriginal.findNextEdge(outPoint, dirOrth2, 0, true, false);
|
|
|
-
|
|
|
- FingerSlice slice = new FingerSlice(p1, p2);
|
|
|
-
|
|
|
- return slice;
|
|
|
- }
|
|
|
-
|
|
|
+
|
|
|
private FingerSliceTrail orderTrailTipToHand(FingerSliceTrail trail)
|
|
|
{
|
|
|
- FingerSlice start = trail.StartSlice;
|
|
|
- FingerSlice end = trail.EndSlice;
|
|
|
-
|
|
|
- Vector2D direction = (end.Mid - start.Mid).normalize();
|
|
|
-
|
|
|
- FingerSlice startOutSlice = findOutSlice(start.Mid, direction.getInverse());
|
|
|
- FingerSlice endOutSlice = findOutSlice(end.Mid, direction);
|
|
|
-
|
|
|
- float startOutLength = float.MaxValue;
|
|
|
- float endOutLength = float.MaxValue;
|
|
|
-
|
|
|
- if (startOutSlice.Start.isInBound(Vector2D.Zero, depthImage.BottomRight) && startOutSlice.End.isInBound(Vector2D.Zero, depthImage.BottomRight))
|
|
|
- startOutLength = startOutSlice.Length;
|
|
|
-
|
|
|
- if (endOutSlice.Start.isInBound(Vector2D.Zero, depthImage.BottomRight) && endOutSlice.End.isInBound(Vector2D.Zero, depthImage.BottomRight))
|
|
|
- endOutLength = endOutSlice.Length;
|
|
|
-
|
|
|
- if (startOutLength <= endOutLength)
|
|
|
- {
|
|
|
+ //check direction
|
|
|
+ if (trail.StartSlice.Length > trail.EndSlice.Length)
|
|
|
trail.reverse();
|
|
|
- outputImage.drawLineSegment(startOutSlice.LineSegment, Constants.FingerHandOutSliceColor);
|
|
|
- outputImage.drawLineSegment(endOutSlice.LineSegment, Constants.FingerTipOutSliceColor);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- outputImage.drawLineSegment(startOutSlice.LineSegment, Constants.FingerTipOutSliceColor);
|
|
|
- outputImage.drawLineSegment(endOutSlice.LineSegment, Constants.FingerHandOutSliceColor);
|
|
|
- }
|
|
|
|
|
|
return trail;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
private void drawFingers()
|
|
|
{
|
|
|
foreach (Finger finger in Fingers)
|