|
@@ -42,7 +42,12 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
{
|
|
|
this.outputImage = outputImage;
|
|
|
|
|
|
- if (hands.Count == 2)
|
|
|
+ if (hands.Count == 1 && hands[0].Fingers.Count == 1)
|
|
|
+ {
|
|
|
+ palmHand = hands[0];
|
|
|
+ pointingHand = null;
|
|
|
+ }
|
|
|
+ else if (hands.Count == 2)
|
|
|
{
|
|
|
if (hands[0].Fingers.Count > 1)
|
|
|
{
|
|
@@ -64,10 +69,14 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
pointingHand = hands[1];
|
|
|
palmHand = hands[0];
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
+ if ((hands.Count == 1 && hands[0].Fingers.Count == 1) || hands.Count == 2)
|
|
|
+ {
|
|
|
findLongestPalmContour();
|
|
|
findConvexityDefectsSortedByDepth();
|
|
|
- removeConvexityDefectsCausedByFingers();
|
|
|
+ if (pointingHand != null)
|
|
|
+ removeConvexityDefectsCausedByFingers();
|
|
|
findHandPoints();
|
|
|
}
|
|
|
|
|
@@ -153,15 +162,19 @@ namespace bbiwarg.Detectors.PalmDetection
|
|
|
Vector2D start = new Vector2D(d.StartPoint);
|
|
|
Vector2D end = new Vector2D(d.EndPoint);
|
|
|
|
|
|
+ float angle = (float)((depth - start).getAngleBetween(depth - end) * 180 / Math.PI);
|
|
|
+
|
|
|
float l1 = (depth - start).Length;
|
|
|
float l2 = (depth - end).Length;
|
|
|
- float lengthQuotient = Math.Max(l1, l2) / Math.Min(l1, l2);
|
|
|
+ float startEndLengthQuotient = Math.Max(l1, l2) / Math.Min(l1, l2);
|
|
|
|
|
|
- float angle = (float) ((depth - start).getAngleBetween(depth - end) * 180 / Math.PI);
|
|
|
+ float depthThumbLengthQuotient = d.Depth / palmHand.Fingers[0].LineSegment.Length;
|
|
|
|
|
|
if (angle <= Constants.PalmMaxThumbDefectAngle &&
|
|
|
- lengthQuotient >= Constants.PalmMinThumbDefectLengthQuotient && lengthQuotient <= Constants.PalmMaxThumbDefectLengthQuotient &&
|
|
|
- d.Depth >= Constants.PalmMinTumbDefectDepth)
|
|
|
+ startEndLengthQuotient >= Constants.PalmMinThumbDefectStartEndLengthQuotient &&
|
|
|
+ startEndLengthQuotient <= Constants.PalmMaxThumbDefectStartEndLengthQuotient &&
|
|
|
+ depthThumbLengthQuotient >= Constants.PalmMinTumbDefectDepthThumbLengthQuotient &&
|
|
|
+ depthThumbLengthQuotient <= Constants.PalmMaxTumbDefectDepthThumbLengthQuotient)
|
|
|
{
|
|
|
return d;
|
|
|
}
|