|
@@ -38,7 +38,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
Fingers = new List<Finger>();
|
|
|
|
|
|
- for (int y = 1; y < maxY; y += 5) //y++ for 100% coverage, but y+=5 for 99% coverage and 3 times better perfomance
|
|
|
+ for (int y = 1; y < maxY; y += 5)
|
|
|
{
|
|
|
for (int x = 1; x < maxX; x++)
|
|
|
{
|
|
@@ -57,7 +57,9 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
{
|
|
|
FingerSliceTrail trail = findFingerSliceTrail(slice, edgeDirection);
|
|
|
if (trail != null && trail.NumSlices > Constants.FingerMinNumSlices)
|
|
|
+ {
|
|
|
createFingerFromTrail(trail);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -95,7 +97,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
trail.addSlice(nextSlice);
|
|
|
trail = expandTrail(trail);
|
|
|
|
|
|
- if (trail.NumSlices > Constants.FingerMinNumSlices)
|
|
|
+ if (trail.NumSlices > Constants.FingerMinNumSlices / 2)
|
|
|
{
|
|
|
trail.Slices.RemoveRange(0, Constants.FingerRemoveNumSlicesForCorrection);
|
|
|
trail.Slices.Reverse();
|
|
@@ -126,7 +128,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
while (currentPosition.isWithin(0, 0, maxX, maxY) && gapCounter <= Math.Min(numSlices, Constants.FingerMaxGapCounter))
|
|
|
{
|
|
|
- if(reversed)
|
|
|
+ if (reversed)
|
|
|
nextSlice = findFingerSliceFromMid(currentPosition, currentDirection.getInverse());
|
|
|
else
|
|
|
nextSlice = findFingerSliceFromMid(currentPosition, currentDirection);
|
|
@@ -168,7 +170,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
}
|
|
|
private FingerSlice findFingerSliceFromStartEdge(Vector2D start, Vector2D direction)
|
|
|
{
|
|
|
- Vector2D end = findNextEdge(start+3*direction, direction);
|
|
|
+ Vector2D end = findNextEdge(start + Constants.FingerSliceOverlapFactor * direction, direction);
|
|
|
if (end == null) return null;
|
|
|
|
|
|
return getFingerSlice(start, end);
|
|
@@ -223,8 +225,8 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
int maxY = depthImage.Height - 1;
|
|
|
|
|
|
Vector2D direction = (end - start).normalize();
|
|
|
- Vector2D beforeStart = (start - direction).moveInBound(0, 0, maxX, maxY);
|
|
|
- Vector2D behindEnd = (end + direction).moveInBound(0, 0, maxY, maxY);
|
|
|
+ Vector2D beforeStart = (start - Constants.FingerSliceOverlapFactor * direction).moveInBound(0, 0, maxX, maxY);
|
|
|
+ Vector2D behindEnd = (end + Constants.FingerSliceOverlapFactor * direction).moveInBound(0, 0, maxY, maxY);
|
|
|
|
|
|
FingerSlice slice = new FingerSlice(beforeStart, behindEnd);
|
|
|
if (slice.Length >= Constants.FingerMinSize && slice.Length <= Constants.FingerMaxSize && fingerSliceDepthTest(slice))
|
|
@@ -267,7 +269,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
Vector2D dirOrth1 = direction.getOrthogonal(true);
|
|
|
Vector2D dirOrth2 = direction.getOrthogonal(false);
|
|
|
|
|
|
- Vector2D outPoint = (start + Constants.FingerOutSliceFactor * Constants.FingerStepSize * direction).moveInBound(0, 0, maxX, maxY);
|
|
|
+ Vector2D outPoint = (start + Constants.FingerOutSliceFactor * direction).moveInBound(0, 0, maxX, maxY);
|
|
|
Vector2D p1 = findNextEdge(outPoint, dirOrth1, false, false, true);
|
|
|
Vector2D p2 = findNextEdge(outPoint, dirOrth2, false, false, true);
|
|
|
|
|
@@ -288,7 +290,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
Vector2D direction = (end.Mid - start.Mid).normalize();
|
|
|
|
|
|
- FingerSlice startOutSlice = findOutSlice(start.Mid, -1 * direction);
|
|
|
+ FingerSlice startOutSlice = findOutSlice(start.Mid, direction.getInverse());
|
|
|
FingerSlice endOutSlice = findOutSlice(end.Mid, direction);
|
|
|
|
|
|
float startOutLength = float.MaxValue;
|
|
@@ -313,7 +315,6 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
{
|
|
|
outputImage.drawLineSegment(trail.Slices[i].LineSegment, Constants.FingerSliceColor);
|
|
|
}
|
|
|
- //outputImage.drawPolygon(finger.getBoundingPolygon(), 0);
|
|
|
outputImage.drawLineSegment(finger.LineSegment, Constants.FingerDetectedColor);
|
|
|
outputImage.drawContour(finger.getContour(), Color.Red, 1);
|
|
|
}
|