|
@@ -28,10 +28,11 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
this.edgeImageAdapted = edgeImage.copy();
|
|
|
this.outputImage = outputImage;
|
|
|
|
|
|
- findFingers();
|
|
|
+ detectFingers();
|
|
|
+ drawFingers();
|
|
|
}
|
|
|
|
|
|
- private void findFingers()
|
|
|
+ private void detectFingers()
|
|
|
{
|
|
|
int maxX = depthImage.Width - 1;
|
|
|
int maxY = depthImage.Height - 1;
|
|
@@ -252,15 +253,31 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
Finger finger = new Finger(trail);
|
|
|
|
|
|
//add finger
|
|
|
- Fingers.Add(finger);
|
|
|
-
|
|
|
- //draw finger
|
|
|
- drawDetectedFinger(finger);
|
|
|
+ if (!isCrippleFinger(finger))
|
|
|
+ Fingers.Add(finger);
|
|
|
|
|
|
//remove edges around detected finger to improve performance
|
|
|
edgeImageAdapted.removeEdgesInsidePolygon(finger.getContour().ToArray());
|
|
|
}
|
|
|
|
|
|
+ private bool isCrippleFinger(Finger finger)
|
|
|
+ {
|
|
|
+ int maxX = depthImage.Width - 1;
|
|
|
+ int maxY = depthImage.Height - 1;
|
|
|
+
|
|
|
+ FingerSlice midSlice = finger.SliceTrail.Slices[finger.SliceTrail.NumSlices / 2];
|
|
|
+ Vector2D direction = midSlice.LineSegment.Line.Direction;
|
|
|
+ Vector2D out1 = (midSlice.Start - Constants.FingerCrippleOutFactor * direction).moveInBound(0, 0, maxX, maxY);
|
|
|
+ Vector2D out2 = (midSlice.End + Constants.FingerCrippleOutFactor * direction).moveInBound(0, 0, maxX, maxY);
|
|
|
+
|
|
|
+ Int16 depthAtFinger = depthImage.getDepthAt(midSlice.Mid);
|
|
|
+ Int16 depthAtOut1 = depthImage.getDepthAt(out1);
|
|
|
+ Int16 depthAtOut2 = depthImage.getDepthAt(out2);
|
|
|
+ int minDepthDifference = Math.Min(Math.Abs(depthAtFinger - depthAtOut1), Math.Abs(depthAtFinger - depthAtOut2));
|
|
|
+
|
|
|
+ return (minDepthDifference < Constants.FingerCrippleOutMinDifference);
|
|
|
+ }
|
|
|
+
|
|
|
private FingerSlice findOutSlice(Vector2D start, Vector2D direction)
|
|
|
{
|
|
|
int maxX = depthImage.Width - 1;
|
|
@@ -315,7 +332,15 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
return trail;
|
|
|
}
|
|
|
|
|
|
- private void drawDetectedFinger(Finger finger)
|
|
|
+ private void drawFingers()
|
|
|
+ {
|
|
|
+ foreach (Finger finger in Fingers)
|
|
|
+ {
|
|
|
+ drawFinger(finger);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void drawFinger(Finger finger)
|
|
|
{
|
|
|
FingerSliceTrail trail = finger.SliceTrail;
|
|
|
for (int i = 0; i < trail.NumSlices; i++)
|
|
@@ -323,7 +348,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
outputImage.drawLineSegment(trail.Slices[i].LineSegment, Constants.FingerSliceColor);
|
|
|
}
|
|
|
outputImage.drawLineSegment(finger.LineSegment, Constants.FingerDetectedColor);
|
|
|
- outputImage.drawContour(finger.getContour(), Color.Red, 1);
|
|
|
+ outputImage.drawContour(finger.getContour(), Constants.FingerContourColor, 1);
|
|
|
}
|
|
|
}
|
|
|
}
|