|
@@ -152,7 +152,7 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
pointingHandMask = pointingHandMask.Or(edgeImage.Image);
|
|
|
i1.Image[0] = i1.Image[1] = i1.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
- pointingHandMask = pointingHandMask.Dilate(2);
|
|
|
+ pointingHandMask = pointingHandMask.Dilate(1);
|
|
|
i2.Image[0] = i2.Image[1] = i2.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
fillFirstFingerSlices(pointingHandMask, 1);
|
|
@@ -217,7 +217,7 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
List<MCvConvexityDefect> newDefects = new List<MCvConvexityDefect>();
|
|
|
foreach (MCvConvexityDefect d in convexityDefects)
|
|
|
{
|
|
|
- bool remove = false;
|
|
|
+ bool fingerIntersectsStartEnd = false;
|
|
|
float minFingerLineDist = float.MaxValue;
|
|
|
foreach (Finger f in fingers)
|
|
|
{
|
|
@@ -225,7 +225,7 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
Vector2D intersection = defectLine.Line.getIntersection(f.LineSegment.Line);
|
|
|
if (intersection.isInBox(defectLine.P1, defectLine.P2) && intersection.isInBox(f.LineSegment.P1, f.LineSegment.P2))
|
|
|
{
|
|
|
- remove = true;
|
|
|
+ fingerIntersectsStartEnd = true;
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -235,12 +235,13 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
minFingerLineDist = dist;
|
|
|
}
|
|
|
|
|
|
- if (minFingerLineDist >= Constants.PalmMinDefectMidFingerLineDistance && !remove)
|
|
|
+ if (minFingerLineDist >= Constants.PalmMinDefectMidFingerLineDistance && !fingerIntersectsStartEnd)
|
|
|
newDefects.Add(d);
|
|
|
}
|
|
|
convexityDefects = newDefects;
|
|
|
}
|
|
|
|
|
|
+ private int i = 0;
|
|
|
private MCvConvexityDefect? findThumbDefect()
|
|
|
{
|
|
|
foreach (MCvConvexityDefect d in convexityDefects)
|
|
@@ -261,7 +262,25 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
return d;
|
|
|
}
|
|
|
}
|
|
|
- Console.WriteLine("no palm defect found");
|
|
|
+
|
|
|
+
|
|
|
+ /*Console.WriteLine("no palm defect found (" + i + ")");
|
|
|
+ foreach (MCvConvexityDefect d in convexityDefects)
|
|
|
+ {
|
|
|
+ Vector2D depth = new Vector2D(d.DepthPoint);
|
|
|
+ Vector2D start = new Vector2D(d.StartPoint);
|
|
|
+ Vector2D end = new Vector2D(d.EndPoint);
|
|
|
+
|
|
|
+ float l1 = (depth - start).Length;
|
|
|
+ float l2 = (depth - end).Length;
|
|
|
+ float lengthQuotient = Math.Max(l1, l2) / Math.Min(l1, l2);
|
|
|
+
|
|
|
+ float angle = (float)((depth - start).getAngleBetween(depth - end) * 180 / Math.PI);
|
|
|
+
|
|
|
+ Console.WriteLine("angle: " + angle + " quotient: " + lengthQuotient);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ ++i;
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -321,8 +340,6 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
|
|
|
private void draw()
|
|
|
{
|
|
|
-
|
|
|
-
|
|
|
if (palmContour != null && palmContour.Count<Point>() > 0) {
|
|
|
outputImage.drawContour(palmContour, Constants.PalmConturColor);
|
|
|
outputImage.drawPoints(palmContour.GetConvexHull(Emgu.CV.CvEnum.ORIENTATION.CV_CLOCKWISE), Constants.PalmConvexHullColor);
|