|
@@ -22,7 +22,8 @@ namespace bbiwarg.DataSource
|
|
|
public const int TOLERANCE_Z = 5;
|
|
|
public const int TOLERANCE_2D = 7;
|
|
|
|
|
|
- private IVideoHandle source;
|
|
|
+ private IInputProvider inputProvider;
|
|
|
+ private IVideoHandle videoHandle;
|
|
|
|
|
|
private List<Vector> points;
|
|
|
private HashSet<Vector> seenPoints;
|
|
@@ -33,18 +34,19 @@ namespace bbiwarg.DataSource
|
|
|
private float highestZ;
|
|
|
|
|
|
|
|
|
- public ForeFingerDetection(IVideoHandle source)
|
|
|
+ public ForeFingerDetection(IInputProvider inputProvider, IVideoHandle videoHandle)
|
|
|
{
|
|
|
- this.source = source;
|
|
|
+ this.inputProvider = inputProvider;
|
|
|
+ this.videoHandle = videoHandle;
|
|
|
}
|
|
|
|
|
|
public Vector getForeFingerPosition3D(uint handIndex)
|
|
|
{
|
|
|
- Vector palmPosition2D = source.getPalmPosition2D(handIndex);
|
|
|
+ Vector palmPosition2D = inputProvider.getPalmPosition2D(handIndex);
|
|
|
palmPosition = new DenseVector(3);
|
|
|
palmPosition[0] = palmPosition2D[0];
|
|
|
palmPosition[1] = palmPosition2D[1];
|
|
|
- palmPosition[2] = source.getDepth((int)palmPosition[0], (int)palmPosition[1]);
|
|
|
+ palmPosition[2] = videoHandle.getDepth((int)palmPosition[0], (int)palmPosition[1]);
|
|
|
|
|
|
points = new List<Vector>();
|
|
|
seenPoints = new HashSet<Vector>();
|
|
@@ -60,7 +62,7 @@ namespace bbiwarg.DataSource
|
|
|
checkPoint(points[i]);
|
|
|
}
|
|
|
|
|
|
- return foreFingerPosition;
|
|
|
+ return videoHandle.pixel2VertexPosition(foreFingerPosition);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -84,7 +86,7 @@ namespace bbiwarg.DataSource
|
|
|
}
|
|
|
|
|
|
Vector distanceVector = new DenseVector(3);
|
|
|
- source.pixel2VertexPosition(palmPosition).Subtract(source.pixel2VertexPosition(point), distanceVector);
|
|
|
+ videoHandle.pixel2VertexPosition(palmPosition).Subtract(videoHandle.pixel2VertexPosition(point), distanceVector);
|
|
|
//palmPosition.Subtract(point, distanceVector);
|
|
|
|
|
|
float currentPointDistance = distanceVector.Norm(2);
|
|
@@ -100,14 +102,14 @@ 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 < source.getHeight(); y++)
|
|
|
+ for (int y = -(int)Math.Min(TOLERANCE_2D, point[1]); y <= TOLERANCE_2D && point[1] + y < videoHandle.getHeight(); y++)
|
|
|
{
|
|
|
- for (int x = -(int)Math.Min(TOLERANCE_2D, point[0]); x <= TOLERANCE_2D && point[0] + x < source.getWidth(); x++)
|
|
|
+ for (int x = -(int)Math.Min(TOLERANCE_2D, point[0]); x <= TOLERANCE_2D && point[0] + x < videoHandle.getWidth(); x++)
|
|
|
{
|
|
|
currentPoint = new DenseVector(3);
|
|
|
currentPoint[0] = point[0] + x;
|
|
|
currentPoint[1] = point[1] + y;
|
|
|
- currentPoint[2] = source.getDepth((int)currentPoint[0], (int)currentPoint[1]);
|
|
|
+ currentPoint[2] = videoHandle.getDepth((int)currentPoint[0], (int)currentPoint[1]);
|
|
|
if (Math.Abs(currentPoint[2] - point[2]) <= TOLERANCE_Z && !seenPoints.Contains(currentPoint))
|
|
|
{
|
|
|
points.Add(currentPoint);
|