|
@@ -19,8 +19,8 @@ namespace bbiwarg.DataSource
|
|
|
* handIndex: which hand's forefinger's position
|
|
|
*/
|
|
|
|
|
|
- public const int TOLERANCE_Z = 5;
|
|
|
- public const int TOLERANCE_2D = 7;
|
|
|
+ public const int TOLERANCE_Z = 3;
|
|
|
+ public const int TOLERANCE_2D = 3;
|
|
|
|
|
|
private IInputProvider inputProvider;
|
|
|
private IVideoHandle videoHandle;
|
|
@@ -30,8 +30,6 @@ namespace bbiwarg.DataSource
|
|
|
private Vector palmPosition;
|
|
|
private Vector foreFingerPosition;
|
|
|
private float foreFingerDistance;
|
|
|
- private float lowestY;
|
|
|
- private float highestZ;
|
|
|
|
|
|
|
|
|
public ForeFingerDetection(IInputProvider inputProvider, IVideoHandle videoHandle)
|
|
@@ -52,8 +50,6 @@ namespace bbiwarg.DataSource
|
|
|
seenPoints = new HashSet<Vector>();
|
|
|
foreFingerPosition = palmPosition;
|
|
|
foreFingerDistance = 0;
|
|
|
- lowestY = palmPosition[1];
|
|
|
- highestZ = palmPosition[2];
|
|
|
|
|
|
points.Add(palmPosition);
|
|
|
seenPoints.Add(palmPosition);
|
|
@@ -68,35 +64,16 @@ namespace bbiwarg.DataSource
|
|
|
|
|
|
private void checkPoint(Vector point)
|
|
|
{
|
|
|
- bool isLowestY = point[1] <= lowestY;
|
|
|
- bool isHighestZ = point[2] >= highestZ;
|
|
|
- if (isLowestY || isHighestZ)
|
|
|
- {
|
|
|
- if (isLowestY)
|
|
|
- {
|
|
|
- if (lowestY == foreFingerPosition[1])
|
|
|
- foreFingerDistance = 0;
|
|
|
- lowestY = point[1];
|
|
|
- }
|
|
|
- if (isHighestZ)
|
|
|
- {
|
|
|
- if (highestZ == foreFingerPosition[2])
|
|
|
- foreFingerDistance = 0;
|
|
|
- highestZ = point[2];
|
|
|
- }
|
|
|
-
|
|
|
- Vector distanceVector = new DenseVector(3);
|
|
|
- videoHandle.pixel2VertexPosition(palmPosition).Subtract(videoHandle.pixel2VertexPosition(point), distanceVector);
|
|
|
- //palmPosition.Subtract(point, distanceVector);
|
|
|
+ Vector distanceVector = new DenseVector(3);
|
|
|
+ videoHandle.pixel2VertexPosition(palmPosition).Subtract(videoHandle.pixel2VertexPosition(point), distanceVector);
|
|
|
|
|
|
- float currentPointDistance = distanceVector.Norm(2);
|
|
|
- if (currentPointDistance >= foreFingerDistance)
|
|
|
- {
|
|
|
- foreFingerPosition = point;
|
|
|
- foreFingerDistance = currentPointDistance;
|
|
|
- addNeighbours(point);
|
|
|
- }
|
|
|
+ float currentPointDistance = distanceVector.Norm(2);
|
|
|
+ if (currentPointDistance >= foreFingerDistance)
|
|
|
+ {
|
|
|
+ foreFingerPosition = point;
|
|
|
+ foreFingerDistance = currentPointDistance;
|
|
|
}
|
|
|
+ addNeighbours(point);
|
|
|
}
|
|
|
|
|
|
private void addNeighbours(Vector point)
|
|
@@ -110,7 +87,7 @@ namespace bbiwarg.DataSource
|
|
|
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 && !seenPoints.Contains(currentPoint))
|
|
|
+ if (Math.Abs(currentPoint[2] - point[2]) <= TOLERANCE_Z && point[1] <= palmPosition[1] && !seenPoints.Contains(currentPoint))
|
|
|
{
|
|
|
points.Add(currentPoint);
|
|
|
seenPoints.Add(currentPoint);
|
|
@@ -118,5 +95,10 @@ namespace bbiwarg.DataSource
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public List<Vector> getHandPoints()
|
|
|
+ {
|
|
|
+ return points;
|
|
|
+ }
|
|
|
}
|
|
|
}
|