|
@@ -63,8 +63,8 @@ namespace bbiwarg.Detectors.Palm
|
|
|
findLongestPalmContour();
|
|
|
if (palmContour != null)
|
|
|
{
|
|
|
- findConvexityDefactsSortedByDepth();
|
|
|
- removeConvexityDefectsNearFingerTips();
|
|
|
+ findConvexityDefectsSortedByDepth();
|
|
|
+ removeConvexityDefectsCausedByFingers();
|
|
|
|
|
|
findHandPoints();
|
|
|
|
|
@@ -208,7 +208,7 @@ namespace bbiwarg.Detectors.Palm
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void findConvexityDefactsSortedByDepth()
|
|
|
+ private void findConvexityDefectsSortedByDepth()
|
|
|
{
|
|
|
convexityDefects = new List<MCvConvexityDefect>(palmContour.GetConvexityDefacts(new MemStorage(), Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE));
|
|
|
convexityDefects.Sort(delegate(MCvConvexityDefect d1, MCvConvexityDefect d2)
|
|
@@ -221,19 +221,22 @@ namespace bbiwarg.Detectors.Palm
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- private void removeConvexityDefectsNearFingerTips()
|
|
|
+ private void removeConvexityDefectsCausedByFingers()
|
|
|
{
|
|
|
List<MCvConvexityDefect> newDefects = new List<MCvConvexityDefect>();
|
|
|
foreach (MCvConvexityDefect d in convexityDefects)
|
|
|
{
|
|
|
- float minFingerTipDist = float.MaxValue;
|
|
|
+ float minFingerLineDist = float.MaxValue;
|
|
|
foreach (Finger f in fingers)
|
|
|
{
|
|
|
- float dist = f.Tip.getDistanceTo(new Vector2D(d.DepthPoint));
|
|
|
- if (dist < minFingerTipDist)
|
|
|
- minFingerTipDist = dist;
|
|
|
+ Vector2D mid = (new Vector2D(d.StartPoint) + new Vector2D(d.EndPoint)) / 2.0f;
|
|
|
+
|
|
|
+ float dist = f.LineSegment.getDistanceTo(mid);
|
|
|
+ if (dist < minFingerLineDist)
|
|
|
+ minFingerLineDist = dist;
|
|
|
}
|
|
|
- if (minFingerTipDist > 10)
|
|
|
+
|
|
|
+ if (minFingerLineDist >= Constants.PalmMinDefectMidFingerLineDistance)
|
|
|
newDefects.Add(d);
|
|
|
}
|
|
|
convexityDefects = newDefects;
|