|
@@ -12,35 +12,32 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
class FingerSliceTrail
|
|
|
{
|
|
|
private List<FingerSlice> slices;
|
|
|
- private List<Point> pointsA;
|
|
|
- private List<Point> pointsB;
|
|
|
+ private LineSegment2D lineSegment;
|
|
|
+ private Contour<Point> contour;
|
|
|
+ private bool lineSegmentUpToDate;
|
|
|
+ private bool contourUpToDate;
|
|
|
+
|
|
|
public FingerSlice StartSlice { get { return slices[0]; } }
|
|
|
public FingerSlice MidSlice { get { return slices[NumSlices / 2]; } }
|
|
|
public FingerSlice EndSlice { get { return slices[slices.Count - 1]; } }
|
|
|
public FingerSlice this[int index] { get { return slices[index]; } }
|
|
|
public int NumSlices { get { return slices.Count; } }
|
|
|
- public LineSegment2D LineSegment { get; private set; }
|
|
|
+ public LineSegment2D LineSegment { get { if (!lineSegmentUpToDate) updateLineSegment(); return lineSegment; } }
|
|
|
+ public Contour<Point> Contour { get { if (!contourUpToDate) updateContour(); return contour; } }
|
|
|
|
|
|
public FingerSliceTrail(FingerSlice slice)
|
|
|
{
|
|
|
slices = new List<FingerSlice>();
|
|
|
- pointsA = new List<Point>();
|
|
|
- pointsB = new List<Point>();
|
|
|
addSlice(slice);
|
|
|
+ lineSegmentUpToDate = false;
|
|
|
+ contourUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public void addSlice(FingerSlice slice)
|
|
|
{
|
|
|
slices.Add(slice);
|
|
|
- pointsA.Add(slice.Start + Constants.FingerContourMargin * slice.Direction.getInverse());
|
|
|
- pointsB.Add(slice.End + Constants.FingerContourMargin * slice.Direction);
|
|
|
- pointsA.Add(slice.Start);
|
|
|
- createLineSegment();
|
|
|
- }
|
|
|
-
|
|
|
- private void createLineSegment()
|
|
|
- {
|
|
|
- LineSegment = new LineSegment2D(EndSlice.Mid, StartSlice.Mid);
|
|
|
+ lineSegmentUpToDate = false;
|
|
|
+ contourUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public Vector2D getStartDirection()
|
|
@@ -58,40 +55,41 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
public void removeFirstSlices(int numSlices)
|
|
|
{
|
|
|
slices.RemoveRange(0, numSlices);
|
|
|
- pointsA.RemoveRange(0, numSlices);
|
|
|
- pointsB.RemoveRange(0, numSlices);
|
|
|
- createLineSegment();
|
|
|
+ lineSegmentUpToDate = false;
|
|
|
+ contourUpToDate = false;
|
|
|
}
|
|
|
|
|
|
public void reverse()
|
|
|
{
|
|
|
slices.Reverse();
|
|
|
- pointsA.Reverse();
|
|
|
- pointsB.Reverse();
|
|
|
-
|
|
|
- List<Point> dummy = pointsA;
|
|
|
- pointsA = pointsB;
|
|
|
- pointsB = dummy;
|
|
|
+ lineSegmentUpToDate = false;
|
|
|
+ contourUpToDate = false;
|
|
|
+ }
|
|
|
|
|
|
- createLineSegment();
|
|
|
+ private void updateLineSegment()
|
|
|
+ {
|
|
|
+ lineSegment = new LineSegment2D(EndSlice.Mid, StartSlice.Mid);
|
|
|
}
|
|
|
|
|
|
+ private void updateContour()
|
|
|
+ {
|
|
|
+ List<Point> pointsA = new List<Point>();
|
|
|
+ List<Point> pointsB = new List<Point>();
|
|
|
|
|
|
+ foreach (FingerSlice slice in slices)
|
|
|
+ {
|
|
|
+ pointsA.Add(slice.Start + Constants.FingerContourMargin * slice.Direction.getInverse());
|
|
|
+ pointsB.Add(slice.End + Constants.FingerContourMargin * slice.Direction);
|
|
|
+ }
|
|
|
|
|
|
- public Contour<Point> getContour()
|
|
|
- {
|
|
|
- pointsA.Reverse();
|
|
|
- List<Point> points = new List<Point>();
|
|
|
- points.AddRange(pointsA);
|
|
|
- points.AddRange(pointsB);
|
|
|
pointsA.Reverse();
|
|
|
+ pointsA.AddRange(pointsB);
|
|
|
|
|
|
- Contour<Point> contour = new Contour<Point>(new MemStorage());
|
|
|
- foreach (Point p in points)
|
|
|
+ contour = new Contour<Point>(new MemStorage());
|
|
|
+ foreach (Point p in pointsA)
|
|
|
{
|
|
|
contour.Push(p);
|
|
|
}
|
|
|
- return contour;
|
|
|
}
|
|
|
}
|
|
|
}
|