|
@@ -23,6 +23,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
public FingerDetector(DepthImage depthImage, EdgeImage edgeImage, OutputImage outputImage)
|
|
|
{
|
|
|
+ Console.WriteLine("---");
|
|
|
this.depthImage = depthImage;
|
|
|
this.edgeImageOriginal = edgeImage;
|
|
|
this.edgeImageAdapted = edgeImage.copy();
|
|
@@ -100,10 +101,10 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
if (trail.NumSlices > Constants.FingerMinNumSlices / 2)
|
|
|
{
|
|
|
- trail.Slices.RemoveRange(0, Constants.FingerRemoveNumSlicesForCorrection);
|
|
|
- trail.Slices.Reverse();
|
|
|
+ trail.removeFirstSlices(Constants.FingerRemoveNumSlicesForCorrection);
|
|
|
+ trail.reverse();
|
|
|
trail = expandTrail(trail, true);
|
|
|
- trail.Slices.Reverse();
|
|
|
+ trail.reverse();
|
|
|
return trail;
|
|
|
}
|
|
|
}
|
|
@@ -119,12 +120,12 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
int maxY = depthImage.Height - 1;
|
|
|
|
|
|
Vector2D currentDirection = trail.getEndDirection();
|
|
|
- Vector2D currentPosition = trail.End.Mid + Constants.FingerStepSize * currentDirection;
|
|
|
+ Vector2D currentPosition = trail.EndSlice.Mid + Constants.FingerStepSize * currentDirection;
|
|
|
|
|
|
int gapCounter = 0;
|
|
|
int numSlices = trail.NumSlices;
|
|
|
|
|
|
- FingerSlice lastSlice = trail.End;
|
|
|
+ FingerSlice lastSlice = trail.EndSlice;
|
|
|
FingerSlice nextSlice;
|
|
|
|
|
|
while (currentPosition.isWithin(0, 0, maxX, maxY) && gapCounter <= Math.Min(numSlices, Constants.FingerMaxGapCounter))
|
|
@@ -255,9 +256,11 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
if (!isCrippleFinger(finger))
|
|
|
Fingers.Add(finger);
|
|
|
+ else
|
|
|
+ Console.WriteLine("cripple");
|
|
|
|
|
|
|
|
|
- edgeImageAdapted.removeEdgesInsidePolygon(finger.getContour().ToArray());
|
|
|
+ edgeImageAdapted.removeEdgesInsidePolygon(finger.Contour.ToArray());
|
|
|
}
|
|
|
|
|
|
private bool isCrippleFinger(Finger finger)
|
|
@@ -265,8 +268,8 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
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;
|
|
|
+ FingerSlice midSlice = finger.SliceTrail.MidSlice;
|
|
|
+ Vector2D direction = midSlice.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);
|
|
|
|
|
@@ -300,8 +303,8 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
int maxX = depthImage.Width - 2;
|
|
|
int maxY = depthImage.Height - 2;
|
|
|
|
|
|
- FingerSlice start = trail.Start;
|
|
|
- FingerSlice end = trail.End;
|
|
|
+ FingerSlice start = trail.StartSlice;
|
|
|
+ FingerSlice end = trail.EndSlice;
|
|
|
|
|
|
Vector2D direction = (end.Mid - start.Mid).normalize();
|
|
|
|
|
@@ -319,7 +322,7 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
|
|
|
if (startOutLength <= endOutLength)
|
|
|
{
|
|
|
- trail.Slices.Reverse();
|
|
|
+ trail.reverse();
|
|
|
outputImage.drawLineSegment(startOutSlice.LineSegment, Constants.FingerHandOutSliceColor);
|
|
|
outputImage.drawLineSegment(endOutSlice.LineSegment, Constants.FingerTipOutSliceColor);
|
|
|
}
|
|
@@ -345,10 +348,10 @@ namespace bbiwarg.Detectors.FingerDetection
|
|
|
FingerSliceTrail trail = finger.SliceTrail;
|
|
|
for (int i = 0; i < trail.NumSlices; i++)
|
|
|
{
|
|
|
- outputImage.drawLineSegment(trail.Slices[i].LineSegment, Constants.FingerSliceColor);
|
|
|
+ outputImage.drawLineSegment(trail[i].LineSegment, Constants.FingerSliceColor);
|
|
|
}
|
|
|
outputImage.drawLineSegment(finger.LineSegment, Constants.FingerDetectedColor);
|
|
|
- outputImage.drawContour(finger.getContour(), Constants.FingerContourColor, 1);
|
|
|
+ outputImage.drawContour(finger.Contour, Constants.FingerContourColor, 1);
|
|
|
}
|
|
|
}
|
|
|
}
|