|
@@ -9,22 +9,78 @@ using Emgu.CV;
|
|
|
|
|
|
namespace bbiwarg.Recognition.FingerRecognition
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public class FingerSliceTrail
|
|
|
{
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private LineSegment2D lineSegment;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private Vector2D fittedDirection;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private bool lineSegmentUpToDate;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private bool fittedDirectionUpToDate;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public List<FingerSlice> Slices { get; private set; }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
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 { if (!lineSegmentUpToDate) updateLineSegment(); return lineSegment; } }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Vector2D FittedDirection { get { if (!fittedDirectionUpToDate) updateFittedDirection(); return fittedDirection; } }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public FingerSliceTrail(FingerSlice slice)
|
|
|
{
|
|
|
Slices = new List<FingerSlice>();
|
|
@@ -33,6 +89,10 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void addSlice(FingerSlice slice)
|
|
|
{
|
|
|
Slices.Add(slice);
|
|
@@ -40,18 +100,30 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Vector2D getStartDirection()
|
|
|
{
|
|
|
int innerStartIndex = Math.Min(NumSlices - 1, Parameters.FingerNumSlicesForRelativeDirection);
|
|
|
return (StartSlice.Mid - Slices[innerStartIndex].Mid).normalize();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Vector2D getEndDirection()
|
|
|
{
|
|
|
int innerEndIndex = Math.Max(0, NumSlices - Parameters.FingerNumSlicesForRelativeDirection);
|
|
|
return (EndSlice.Mid - Slices[innerEndIndex].Mid).normalize();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void removeFirstSlices(int numSlices)
|
|
|
{
|
|
|
Slices.RemoveRange(0, numSlices);
|
|
@@ -59,13 +131,25 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
fittedDirectionUpToDate = false;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public void reverse()
|
|
|
{
|
|
|
Slices.Reverse();
|
|
|
- lineSegmentUpToDate = false;
|
|
|
- fittedDirectionUpToDate = false;
|
|
|
+
|
|
|
+ if(lineSegmentUpToDate)
|
|
|
+ lineSegment = new LineSegment2D(lineSegment.P2, lineSegment.P1);
|
|
|
+
|
|
|
+ if (fittedDirectionUpToDate)
|
|
|
+ fittedDirection = fittedDirection.getInverse();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
public Contour<Point> getContour(float margin)
|
|
|
{
|
|
|
List<Point> pointsA = new List<Point>();
|
|
@@ -86,12 +170,18 @@ namespace bbiwarg.Recognition.FingerRecognition
|
|
|
return contour;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void updateLineSegment()
|
|
|
{
|
|
|
lineSegment = new LineSegment2D(EndSlice.Mid, StartSlice.Mid);
|
|
|
lineSegmentUpToDate = true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
private void updateFittedDirection()
|
|
|
{
|
|
|
List<PointF> midPoints = new List<PointF>();
|