|
@@ -119,36 +119,17 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
- private void fillFingerSlices(Image<Gray, Byte> image, byte val)
|
|
|
+ private void fillFirstFingerSlices(Image<Gray, Byte> image, byte val)
|
|
|
{
|
|
|
foreach (Finger f in fingers)
|
|
|
{
|
|
|
- //foreach (FingerSlice s in f.SliceTrail.Slices)
|
|
|
- {
|
|
|
image.Draw(new LineSegment2DF(f.SliceTrail.Slices[0].Start, f.SliceTrail.Slices[0].End), new Gray(val), 1);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Finger getLongestFinger()
|
|
|
- {
|
|
|
- float maxLength = 0;
|
|
|
- Finger longest = null;
|
|
|
- foreach (Finger f in fingers)
|
|
|
- {
|
|
|
-
|
|
|
- if (f.LineSegment.Length > maxLength)
|
|
|
- {
|
|
|
- maxLength = f.LineSegment.Length;
|
|
|
- longest = f;
|
|
|
- }
|
|
|
}
|
|
|
- return longest;
|
|
|
}
|
|
|
|
|
|
private Point getPointInPointingHand()
|
|
|
{
|
|
|
- Finger finger = getLongestFinger();
|
|
|
+ Finger finger = fingers[0];
|
|
|
if (finger == null)
|
|
|
return new Point(0, 0);
|
|
|
Vector2D direction = (finger.Hand - finger.Tip).normalize();
|
|
@@ -174,7 +155,7 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
pointingHandMask = pointingHandMask.Dilate(2);
|
|
|
i2.Image[0] = i2.Image[1] = i2.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
- fillFingerSlices(pointingHandMask, 1);
|
|
|
+ fillFirstFingerSlices(pointingHandMask, 1);
|
|
|
i3.Image[0] = i3.Image[1] = i3.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
//pointingHandMask = pointingHandMask.Dilate(1);
|
|
@@ -191,7 +172,7 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
pointingHandMask = pointingHandMask.Erode(6);
|
|
|
i6.Image[0] = i6.Image[1] = i6.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
- fillFingerSlices(pointingHandMask, 0);
|
|
|
+ fillFirstFingerSlices(pointingHandMask, 0);
|
|
|
i7.Image[0] = i7.Image[1] = i7.Image[2] = 255 * pointingHandMask;
|
|
|
|
|
|
pointingHandMask = pointingHandMask.Erode(2);
|
|
@@ -268,13 +249,19 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
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);
|
|
|
|
|
|
- if (angle <= Constants.PalmMaxThumbDefectAngle)
|
|
|
+ if (angle <= Constants.PalmMaxThumbDefectAngle &&
|
|
|
+ lengthQuotient >= Constants.PalmMinThumbDefectLengthQuotient && lengthQuotient <= Constants.PalmMaxThumbDefectLengthQuotient)
|
|
|
{
|
|
|
return d;
|
|
|
}
|
|
|
}
|
|
|
+ Console.WriteLine("no palm defect found");
|
|
|
return null;
|
|
|
}
|
|
|
|