|
@@ -25,10 +25,12 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
private List<MCvConvexityDefect> convexityDefects;
|
|
private List<MCvConvexityDefect> convexityDefects;
|
|
private Vector2D thumbDefectStart;
|
|
private Vector2D thumbDefectStart;
|
|
private Vector2D thumbDefectEnd;
|
|
private Vector2D thumbDefectEnd;
|
|
- public Vector2D thumbDefectDepth, lastThumbDefectDepth;
|
|
|
|
|
|
+ public Vector2D thumbDefectDepth;
|
|
|
|
|
|
private Kalman2DPositionFilter thumbDefectDepthFilter, thumbDefectStartFilter, thumbDefectEndFilter;
|
|
private Kalman2DPositionFilter thumbDefectDepthFilter, thumbDefectStartFilter, thumbDefectEndFilter;
|
|
|
|
|
|
|
|
+ private int numFramesNoHandFound;
|
|
|
|
+
|
|
public Quadrangle PalmQuad { get; private set; }
|
|
public Quadrangle PalmQuad { get; private set; }
|
|
|
|
|
|
public PalmDetector()
|
|
public PalmDetector()
|
|
@@ -80,9 +82,16 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
findConvexityDefectsSortedByDepth();
|
|
findConvexityDefectsSortedByDepth();
|
|
if (pointingHand != null)
|
|
if (pointingHand != null)
|
|
removeConvexityDefectsCausedByFingers();
|
|
removeConvexityDefectsCausedByFingers();
|
|
- findHandPoints();
|
|
|
|
|
|
+ findHandPoints(hands.Count);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+ if (hands.Count == 0)
|
|
|
|
+ {
|
|
|
|
+ ++numFramesNoHandFound;
|
|
|
|
+ if (numFramesNoHandFound == Constants.PalmNumFramesNoHandReset)
|
|
|
|
+ reset();
|
|
|
|
+ }
|
|
|
|
+
|
|
draw();
|
|
draw();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -91,9 +100,9 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
thumbDefectDepthFilter.reset();
|
|
thumbDefectDepthFilter.reset();
|
|
thumbDefectStartFilter.reset();
|
|
thumbDefectStartFilter.reset();
|
|
thumbDefectEndFilter.reset();
|
|
thumbDefectEndFilter.reset();
|
|
- lastThumbDefectDepth = null;
|
|
|
|
palmContour = null;
|
|
palmContour = null;
|
|
PalmQuad = null;
|
|
PalmQuad = null;
|
|
|
|
+ numFramesNoHandFound = 0;
|
|
}
|
|
}
|
|
|
|
|
|
private void findLongestPalmContour()
|
|
private void findLongestPalmContour()
|
|
@@ -186,7 +195,7 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
|
|
- private void findHandPoints()
|
|
|
|
|
|
+ private void findHandPoints(int numHands)
|
|
{
|
|
{
|
|
MCvConvexityDefect? thumbDefect = findThumbDefect();
|
|
MCvConvexityDefect? thumbDefect = findThumbDefect();
|
|
|
|
|
|
@@ -195,7 +204,7 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
thumbDefectDepth = new Vector2D(thumbDefect.Value.DepthPoint);
|
|
thumbDefectDepth = new Vector2D(thumbDefect.Value.DepthPoint);
|
|
thumbDefectStart = new Vector2D(thumbDefect.Value.StartPoint);
|
|
thumbDefectStart = new Vector2D(thumbDefect.Value.StartPoint);
|
|
thumbDefectEnd = new Vector2D(thumbDefect.Value.EndPoint);
|
|
thumbDefectEnd = new Vector2D(thumbDefect.Value.EndPoint);
|
|
-
|
|
|
|
|
|
+
|
|
if (!thumbDefectDepthFilter.Initialized)
|
|
if (!thumbDefectDepthFilter.Initialized)
|
|
{
|
|
{
|
|
thumbDefectDepthFilter.setInitialPosition(thumbDefectDepth);
|
|
thumbDefectDepthFilter.setInitialPosition(thumbDefectDepth);
|
|
@@ -209,8 +218,6 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
thumbDefectEnd = thumbDefectEndFilter.getCorrectedPosition(thumbDefectEnd);
|
|
thumbDefectEnd = thumbDefectEndFilter.getCorrectedPosition(thumbDefectEnd);
|
|
}
|
|
}
|
|
|
|
|
|
- lastThumbDefectDepth = thumbDefectDepth;
|
|
|
|
-
|
|
|
|
Vector2D handLength, handWidth, longestLineEndpoint, topLeft, bottomLeft, bottomRight, topRight;
|
|
Vector2D handLength, handWidth, longestLineEndpoint, topLeft, bottomLeft, bottomRight, topRight;
|
|
|
|
|
|
Vector2D startDepth = thumbDefectStart - thumbDefectDepth;
|
|
Vector2D startDepth = thumbDefectStart - thumbDefectDepth;
|
|
@@ -231,7 +238,7 @@ namespace bbiwarg.Recognition.PalmRecognition
|
|
handWidth = 0.85f * new Vector2D(-handLength.Y, handLength.X);
|
|
handWidth = 0.85f * new Vector2D(-handLength.Y, handLength.X);
|
|
else
|
|
else
|
|
handWidth = 0.85f * new Vector2D(handLength.Y, -handLength.X);
|
|
handWidth = 0.85f * new Vector2D(handLength.Y, -handLength.X);
|
|
-
|
|
|
|
|
|
+
|
|
topLeft = longestLineEndpoint + 0.15f * handLength;
|
|
topLeft = longestLineEndpoint + 0.15f * handLength;
|
|
bottomLeft = thumbDefectDepth - 0.4f * handLength;
|
|
bottomLeft = thumbDefectDepth - 0.4f * handLength;
|
|
bottomRight = bottomLeft + handWidth;
|
|
bottomRight = bottomLeft + handWidth;
|