|
@@ -15,10 +15,12 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
private Contour<Point> contour;
|
|
|
private Contour<Point> innerContour;
|
|
|
private Contour<Point> outerContour;
|
|
|
+ private Vector2D fittedDirection;
|
|
|
private bool lineSegmentUpToDate;
|
|
|
private bool contourUpToDate;
|
|
|
private bool innerContourUpToDate;
|
|
|
private bool outerContourUpToDate;
|
|
|
+ private bool fittedDirectionUpToDate;
|
|
|
|
|
|
public List<FingerSlice> Slices { get; private set; }
|
|
|
public FingerSlice StartSlice { get { return Slices[0]; } }
|
|
@@ -30,6 +32,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
public Contour<Point> Contour { get { if (!contourUpToDate) updateContour(); return contour; } }
|
|
|
public Contour<Point> InnerContour { get { if (!innerContourUpToDate) updateInnerContour(); return innerContour; } }
|
|
|
public Contour<Point> OuterContour { get { if (!outerContourUpToDate) updateOuterContour(); return outerContour; } }
|
|
|
+ public Vector2D FittedDirection { get { if (!fittedDirectionUpToDate) updateFittedDirection(); return fittedDirection; } }
|
|
|
|
|
|
public FingerSliceTrail(FingerSlice slice)
|
|
|
{
|
|
@@ -37,6 +40,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
addSlice(slice);
|
|
|
lineSegmentUpToDate = false;
|
|
|
contourUpToDate = false;
|
|
|
+ fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public void addSlice(FingerSlice slice)
|
|
@@ -44,6 +48,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Slices.Add(slice);
|
|
|
lineSegmentUpToDate = false;
|
|
|
contourUpToDate = false;
|
|
|
+ fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public Vector2D getStartDirection()
|
|
@@ -63,6 +68,7 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Slices.RemoveRange(0, numSlices);
|
|
|
lineSegmentUpToDate = false;
|
|
|
contourUpToDate = false;
|
|
|
+ fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public void reverse()
|
|
@@ -70,14 +76,33 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
Slices.Reverse();
|
|
|
lineSegmentUpToDate = false;
|
|
|
contourUpToDate = false;
|
|
|
+ fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
private void updateLineSegment()
|
|
|
{
|
|
|
- lineSegment = new LineSegment2D(EndSlice.Mid, StartSlice.Mid);
|
|
|
+ //lineSegment = new LineSegment2D(EndSlice.Mid, StartSlice.Mid);
|
|
|
+ float length_2 = 0.5f * (EndSlice.Mid.getDistanceTo(StartSlice.Mid));
|
|
|
+ Vector2D p1 = MidSlice.Mid + length_2 * FittedDirection;
|
|
|
+ Vector2D p2 = MidSlice.Mid - length_2 * FittedDirection;
|
|
|
+ lineSegment = new LineSegment2D(p1, p2);
|
|
|
+
|
|
|
lineSegmentUpToDate = true;
|
|
|
}
|
|
|
|
|
|
+ private void updateFittedDirection()
|
|
|
+ {
|
|
|
+ List<PointF> midPoints = new List<PointF>();
|
|
|
+ foreach (FingerSlice slice in Slices)
|
|
|
+ midPoints.Add(slice.Mid);
|
|
|
+
|
|
|
+ PointF pointOnLine, direction;
|
|
|
+ PointCollection.Line2DFitting(midPoints.ToArray(), Emgu.CV.CvEnum.DIST_TYPE.CV_DIST_FAIR, out direction, out pointOnLine);
|
|
|
+ fittedDirection = new Vector2D(direction).normalize().getInverse();
|
|
|
+
|
|
|
+ fittedDirectionUpToDate = true;
|
|
|
+ }
|
|
|
+
|
|
|
private void updateContour()
|
|
|
{
|
|
|
List<Point> pointsA = new List<Point>();
|