Page 1 of 1

Windows 8 screen coordinates and the EyeTribe Server

PostPosted: 14 Mar 2014, 09:53
by MastaLomaster
Windows 8 tablet.
It has physical resolution 1920x1080, but logically 1.25 times less: 1536x864

When you ask the TET server about the screen:
Code: Select all
{
    "category": "tracker",
    "request" : "get",
    "values": [ "screenresw", "screenresh" ]
}

..it returns 1536x864. You expect frames to contain coordinates in [0..1535, 0..863] range.

But when it sends frames, they have values with physical resolution! You may get X coordinate like 1900 or more.

Surprisingly the "EyeTribe UI" understatnds (somehow) thet the coordinates recieved should be corrected, and places the cursor in the right position.

In my opinion this TET server's behavior is incorrect. It should return values according to "screenresw", "screenresh".

So far I had to do the following:

Code: Select all
              // Get "virtual screen resolution
   screenX=GetSystemMetrics(SM_CXSCREEN);
   screenY=GetSystemMetrics(SM_CYSCREEN);

   // Get physical resolution
   DEVMODE dm;
   ZeroMemory (&dm, sizeof (dm));
   EnumDisplaySettings (NULL, ENUM_CURRENT_SETTINGS, &dm);

              // correct the mouse pointer position using the scale:
   screen_scale=((double)screenX)/dm.dmPelsWidth;


note: probably it was windows 8.1, not pure 8. Not sure now, already returned the tablet to the owner.

Re: Windows 8 screen coordinates and the EyeTribe Server

PostPosted: 14 Mar 2014, 14:37
by Martin
Correct, this issue is related to DPI scaling which needs to be handled in the application logic.

Our method of handling it uses a transformation matrix, like this:

Code: Select all
public void OnGazeUpdate(GazeData gazeData)
{
    int x = (int)gazeData.SmoothedCoordinates.X;
    int y = (int)gazeData.SmoothedCoordinates.Y;
    Screen winScreen = Screen.FromHandle(new WindowInteropHelper(this).Handle);

    Matrix transfrm = GetTransformationMatrix();
    double screenX = (int)Math.Round((double)x + winScreen.Bounds.Left, 0);
    double screenY = (int)Math.Round((double)y + winScreen.Bounds.Top, 0);
    Point pt = new Point(screenX, screenY);
    pt = transfrm.Transform(pt);
}


And the code for the GetTransformationMatrix() method:
Code: Select all
private Matrix GetTransformationMatrix()
{
     var transMatrix = new Matrix();
     var presentationSource = PresentationSource.FromVisual(this);

     if (presentationSource == null)
          return transMatrix;

     if (presentationSource.CompositionTarget == null)
          return transMatrix;

     return presentationSource.CompositionTarget.TransformFromDevice;
}

Re: Windows 8 screen coordinates and the EyeTribe Server

PostPosted: 14 Mar 2014, 14:59
by MastaLomaster
What I'm talking about is that "screenresw" and "screenresh" are absolutely USELESS now.

They COULD help if they return the range of coordinates returned by the server. I.e. if screenresw returns 1920, then the application knows that gazeData.SmoothedCoordinates.X==1919 means 100% screen width.

In fact, currently there is no reason to ask the server for these values. Anyway you have to decrypt the X and Y values yourself, based on your own understanding of DPI.