Page 1 of 1

Strange x / y shift in WPF application.

PostPosted: 07 Jul 2015, 14:26
by albert
I have strange x and y coordinates shift in the WPF application (please see the screen shot: http://s8.postimg.org/l3etopwl1/Capture.jpg).
Small white ellipse (on the bottom right of the red square) is the gaze pointer that shows outputs from eye tracker while watching red square in the middle.

The snippet below shows the way I’m setting position of the gaze pointer (following code runs in WPF application).
Code: Select all
var x = Screen.PrimaryScreen.Bounds.X;
var y = Screen.PrimaryScreen.Bounds.Y;
         
var screenX = (int)Math.Round(x + gazeData.SmoothedCoordinates.X, 0);
var screenY = (int)Math.Round(y + gazeData.SmoothedCoordinates.Y, 0);

I’m using TheEyeTribeSDK-0.9.56-x86 with TETCSharpClient 0.9.56. I’m calibrating tracker via EyeTribe UI and then run the application. It was tested on several persons with same results, tracker was in proper position calibrated with best rank. Does anyone have an idea what might causing it? Please assume that application’s surrounding doesn’t affect the output position of the gaze pointer.

Thank you for your support!

Re: Strange x / y shift in WPF application.

PostPosted: 07 Jul 2015, 16:09
by lichter
You probably need to convert to/from device-independent pixels (DIP).

Code: Select all
    public partial class MyPage : IGazeListener
    {
        private readonly double _logicalDpi;
        private readonly double _rawDpi;

        public MyPage()
        {
            InitializeComponent();

            // Get pixel density information
            var display = DisplayInformation.GetForCurrentView();
            _logicalDpi = display.LogicalDpi;
            _rawDpi = display.RawDpiX;
            Debug.WriteLine("Logical DPI: " + _logicalDpi);
            Debug.WriteLine("Raw DPI: " + _rawDpi);
        }

        public async void OnGazeUpdate(GazeData gazeData)
        {
            await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate()
            {
                try
                {
                    // Calculate the gaze location in logical (display independent, layout) pixels
                    double logicalX = gazeData.SmoothedCoordinates.X * 96.0 / _logicalDpi;
                    double logicalY = gazeData.SmoothedCoordinates.Y * 96.0 / _logicalDpi;

                    // Draw indicator at (logicalX, logicalY)
                    // ....
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    Debug.WriteLine(ex.StackTrace);
                }
            });
        }
    }

Re: Strange x / y shift in WPF application.

PostPosted: 14 Jul 2015, 21:35
by chithiravelus
Hi Friend, sorry to disturb you in between your query.

I had downloaded the TET client master. please tell me how to call TET client program into our application for eye click event. thank you

share me the code please if you have done alreadyh

Re: Strange x / y shift in WPF application.

PostPosted: 25 Oct 2015, 22:48
by albert
Hi again

This fix works great for Win 8/8.1 Store and Win10 Universal apps. However for WPF applications, this below worked for me:

Code: Select all
var dpiXProperty = typeof(SystemParameters).GetProperty("DpiX", BindingFlags.NonPublic | BindingFlags.Static);
var dpiYProperty = typeof(SystemParameters).GetProperty("Dpi", BindingFlags.NonPublic | BindingFlags.Static);

var dpiX = (int)dpiXProperty.GetValue(null, null);
var dpiY = (int)dpiYProperty.GetValue(null, null);