|
@@ -27,9 +27,9 @@ namespace bbiwarg.Output.GlassesOutput
|
|
|
private ImageSize outputSize;
|
|
|
private OutputImage image;
|
|
|
private Projection2DTo2D projection;
|
|
|
- private List<Vector2D> calibrationPoints;
|
|
|
- private int calibrationPointIndex;
|
|
|
+ private Vector2D currentCalibrationPoint;
|
|
|
private bool calibrationImageUpToDate;
|
|
|
+ private Random rand;
|
|
|
|
|
|
public GlassesWindow(InputProvider inputProvider, InputHandler inputHandler, String name, ImageSize outputSize, int updateInterval)
|
|
|
{
|
|
@@ -42,18 +42,9 @@ namespace bbiwarg.Output.GlassesOutput
|
|
|
guiUpToDate = false;
|
|
|
calibrationImageUpToDate = false;
|
|
|
|
|
|
- Random rand = new Random();
|
|
|
- calibrationPoints = new List<Vector2D>();
|
|
|
-
|
|
|
- for (int i = 0; i < 4; i++)
|
|
|
- calibrationPoints.Add(outputSize.getAbsolutePoint(new Vector2D((float)rand.NextDouble(), (float)rand.NextDouble())));
|
|
|
-
|
|
|
-
|
|
|
- calibrationPoints.Add(outputSize.getAbsolutePoint(new Vector2D(0.75f, 0.25f)));
|
|
|
- calibrationPoints.Add(outputSize.getAbsolutePoint(new Vector2D(0.75f, 0.75f)));
|
|
|
- calibrationPoints.Add(outputSize.getAbsolutePoint(new Vector2D(0.25f, 0.75f)));*/
|
|
|
- calibrationPointIndex = 0;
|
|
|
- projection = new Projection2DTo2D(inputSize, outputSize, calibrationPoints.Count);
|
|
|
+ rand = new Random();
|
|
|
+ currentCalibrationPoint = getRandomOutputPoint();
|
|
|
+ projection = new Projection2DTo2D(inputSize, outputSize, Parameters.GlassesWindowNumCalibrationPoints);
|
|
|
|
|
|
Name = name;
|
|
|
Text = name;
|
|
@@ -147,7 +138,7 @@ namespace bbiwarg.Output.GlassesOutput
|
|
|
image.Dispose();
|
|
|
|
|
|
image = new OutputImage(outputSize);
|
|
|
- image.fillCircle(calibrationPoints[calibrationPointIndex], 25, Color.Orange);
|
|
|
+ image.fillCircle(currentCalibrationPoint, 25, Color.Orange);
|
|
|
}
|
|
|
|
|
|
private void updateGUI()
|
|
@@ -169,13 +160,12 @@ namespace bbiwarg.Output.GlassesOutput
|
|
|
{
|
|
|
if (frameData.TrackedFingers.Count == 1)
|
|
|
{
|
|
|
- Vector2D pointOutput = calibrationPoints[calibrationPointIndex];
|
|
|
+ Vector2D pointOutput = currentCalibrationPoint;
|
|
|
Vector2D pointInput = frameData.TrackedFingers[0].TipPoint;
|
|
|
|
|
|
projection.addCalibrationPoints(pointInput, pointOutput);
|
|
|
|
|
|
- calibrationPointIndex = (calibrationPointIndex + 1) % calibrationPoints.Count;
|
|
|
- calibrationImageUpToDate = false;
|
|
|
+ currentCalibrationPoint = getRandomOutputPoint();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -183,9 +173,13 @@ namespace bbiwarg.Output.GlassesOutput
|
|
|
else if (e.KeyCode == Keys.R)
|
|
|
{
|
|
|
projection.reset();
|
|
|
- calibrationImageUpToDate = false;
|
|
|
- calibrationPointIndex = 0;
|
|
|
+ currentCalibrationPoint = getRandomOutputPoint();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private Vector2D getRandomOutputPoint()
|
|
|
+ {
|
|
|
+ return outputSize.getAbsolutePoint(new Vector2D((float)rand.NextDouble(), (float)rand.NextDouble()));
|
|
|
+ }
|
|
|
}
|
|
|
}
|