|
@@ -12,6 +12,7 @@ namespace bbiwarg.DataSource
|
|
|
{
|
|
|
class ForeFingerDetection
|
|
|
{
|
|
|
+
|
|
|
/*
|
|
|
* Returns the forefinger's position
|
|
|
* all fingers (except der forefinger) have to be inactive
|
|
@@ -31,6 +32,9 @@ namespace bbiwarg.DataSource
|
|
|
private Vector foreFingerPosition;
|
|
|
private float foreFingerDistance;
|
|
|
|
|
|
+ private int pixelWidth;
|
|
|
+ private int pixelHeight;
|
|
|
+
|
|
|
|
|
|
public ForeFingerDetection(IInputProvider inputProvider, IVideoHandle videoHandle)
|
|
|
{
|
|
@@ -40,6 +44,9 @@ namespace bbiwarg.DataSource
|
|
|
|
|
|
public Vector getForeFingerPosition3D(uint handIndex)
|
|
|
{
|
|
|
+ pixelWidth = videoHandle.getWidth();
|
|
|
+ pixelHeight = videoHandle.getHeight();
|
|
|
+
|
|
|
Vector palmPosition2D = inputProvider.getPalmPosition2D(handIndex);
|
|
|
palmPosition = new DenseVector(3);
|
|
|
palmPosition[0] = palmPosition2D[0];
|
|
@@ -58,6 +65,12 @@ namespace bbiwarg.DataSource
|
|
|
checkPoint(points[i]);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ if (points.Count() <= 10)
|
|
|
+ {
|
|
|
+ Console.WriteLine(palmPosition[2]);
|
|
|
+ }
|
|
|
+
|
|
|
return videoHandle.pixel2VertexPosition(foreFingerPosition);
|
|
|
}
|
|
|
|
|
@@ -79,15 +92,16 @@ namespace bbiwarg.DataSource
|
|
|
private void addNeighbours(Vector point)
|
|
|
{
|
|
|
Vector currentPoint;
|
|
|
- for (int y = -(int)Math.Min(TOLERANCE_2D, point[1]); y <= TOLERANCE_2D && point[1] + y < videoHandle.getHeight(); y++)
|
|
|
+ int x_start = -(int)Math.Min(TOLERANCE_2D, point[0]);
|
|
|
+ for (int y = -(int)Math.Min(TOLERANCE_2D, point[1]); y <= TOLERANCE_2D && point[1] + y < pixelHeight; y++)
|
|
|
{
|
|
|
- for (int x = -(int)Math.Min(TOLERANCE_2D, point[0]); x <= TOLERANCE_2D && point[0] + x < videoHandle.getWidth(); x++)
|
|
|
+ for (int x = x_start; x <= TOLERANCE_2D && point[0] + x < pixelWidth; x++)
|
|
|
{
|
|
|
currentPoint = new DenseVector(3);
|
|
|
currentPoint[0] = point[0] + x;
|
|
|
currentPoint[1] = point[1] + y;
|
|
|
currentPoint[2] = videoHandle.getDepth((int)currentPoint[0], (int)currentPoint[1]);
|
|
|
- if (Math.Abs(currentPoint[2] - point[2]) <= TOLERANCE_Z && point[1] <= palmPosition[1] && !seenPoints.Contains(currentPoint))
|
|
|
+ if (point == palmPosition || (Math.Abs(currentPoint[2] - point[2]) <= TOLERANCE_Z && point[1] <= palmPosition[1] && !seenPoints.Contains(currentPoint)))
|
|
|
{
|
|
|
points.Add(currentPoint);
|
|
|
seenPoints.Add(currentPoint);
|