123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- using BBIWARG.Recognition.FingerRecognition;
- using Emgu.CV.Structure;
- namespace BBIWARG.Utility
- {
-
-
-
- public class ConvexityDefect
- {
-
-
-
- public float Depth { get; private set; }
-
-
-
- public Vector2D Inner { get; private set; }
-
-
-
- public LineSegment2D OuterLineSegment { get; private set; }
-
-
-
- public Vector2D OuterLong { get; private set; }
-
-
-
- public Vector2D OuterShort { get; private set; }
-
-
-
- public Vector2D VectorLong { get; private set; }
-
-
-
- public Vector2D VectorShort { get; private set; }
-
-
-
-
- public ConvexityDefect(MCvConvexityDefect mcvConvexityDefect)
- {
- Inner = new Vector2D(mcvConvexityDefect.DepthPoint);
- Vector2D p1 = new Vector2D(mcvConvexityDefect.StartPoint);
- Vector2D p2 = new Vector2D(mcvConvexityDefect.EndPoint);
- if ((p1 - Inner).Length > (p2 - Inner).Length)
- {
- OuterLong = p1;
- OuterShort = p2;
- }
- else
- {
- OuterLong = p2;
- OuterShort = p1;
- }
- VectorLong = OuterLong - Inner;
- VectorShort = OuterShort - Inner;
- OuterLineSegment = new LineSegment2D(OuterLong, OuterShort);
- Depth = OuterLineSegment.getDistanceTo(Inner);
- }
-
-
-
-
-
- public bool isCausedByFinger(Finger finger)
- {
- return OuterLineSegment.intersectsWith(finger.LineSegment);
- }
-
-
-
-
-
- public bool isPossibleThumbDefect(Finger thumb)
- {
- float tipDistance = thumb.TipPoint.getDistanceTo(OuterShort);
- float handDistance = thumb.HandPoint.getDistanceTo(Inner);
- float thumbShortLengthRatio = thumb.LineSegment.Length / VectorShort.Length;
- float shortLongLengthRatio = VectorShort.Length / VectorLong.Length;
- return tipDistance <= Parameters.HandThumbDefectMaxDistanceToThumb &&
- handDistance <= Parameters.HandThumbDefectMaxDistanceToThumb &&
- thumbShortLengthRatio <= Parameters.HandThumbDefectMaxThumbShortLengthRatio && thumbShortLengthRatio >= Parameters.HandThumbDefectMinThumbShortLengthRatio &&
- shortLongLengthRatio <= Parameters.HandThumbDefectMaxShortLongLengthRatio && shortLongLengthRatio >= Parameters.HandThumbDefectMinShortLongLengthRatio;
- }
- }
- }
|