in Tools/Positioning/MainPage.xaml.cs [48:116]
private void GazeInputSourcePreview_GazeMoved(GazeInputSourcePreview sender, GazeMovedPreviewEventArgs args)
{
var sb = new StringBuilder();
sb.Append(" GazePos (");
if (args.CurrentPoint.EyeGazePosition != null)
{
Canvas.SetLeft(GazePositionEllipse, args.CurrentPoint.EyeGazePosition.Value.X);
Canvas.SetTop(GazePositionEllipse, args.CurrentPoint.EyeGazePosition.Value.Y);
sb.Append($"{args.CurrentPoint.EyeGazePosition.Value.X,6}px, {args.CurrentPoint.EyeGazePosition.Value.Y,6}px");
if (showGaze)
{
GazePositionEllipse.Visibility = Visibility.Visible;
}
else
{
GazePositionEllipse.Visibility = Visibility.Collapsed;
}
}
else
{
GazePositionEllipse.Visibility = Visibility.Collapsed;
}
sb.AppendLine(")");
if (args.CurrentPoint.HidInputReport != null)
{
var hidReport = args.CurrentPoint.HidInputReport;
var sourceDevice = args.CurrentPoint.SourceDevice;
if (gazeHidPositionsParser == null)
{
gazeHidPositionsParser = new GazeHidPositionsParser(sourceDevice);
}
var positions = gazeHidPositionsParser.GetGazeHidPositions(hidReport);
// The return values for the left and right eye are in micrometers by default
// They are references such that X and Y origin are the top left hand corner
// of the calibrated display. The Z origin is the centerpoint of the display
// (not the tracker). As such, there is a minor difference between the actual
// sensor-to-eye distance vs the reported distance for left/right eye position.
UpdateEyeData("Left", positions.LeftEyePosition, LeftEyePositionEllipse, sb);
UpdateEyeData("Right", positions.RightEyePosition, RightEyePositionEllipse, sb);
if (positions.RightEyePosition != null && positions.LeftEyePosition != null)
{
// calculate IPD in mm
var interPupilaryDistance = (positions.RightEyePosition.X - positions.LeftEyePosition.X) / 1000.0;
sb.AppendLine($" IPD ({interPupilaryDistance,6:F2}mm)");
}
if (positions.HeadPosition != null)
{
sb.AppendLine($"HeadPosition ({positions.HeadPosition.X,8:F2}, {positions.HeadPosition.Y,8:F2}, {positions.HeadPosition.Z,8:F2})");
}
if (positions.HeadRotation != null)
{
sb.AppendLine($"HeadRotation ({positions.HeadRotation.X,8:F2}, {positions.HeadRotation.Y,8:F2}, {positions.HeadRotation.Z,8:F2})");
}
}
StatusTextBlock.Text = sb.ToString();
}