Home Forums Software Development Finding Screen Size and units

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #350
    Thomas Sjöholm
    Participant

    Hi!

    I want to do some cool math, but need the size of the screen in order to do it. I can’t find a way to access the screen size in any way. I think that it should be possible as the Eye Tracker needs to know that in order to do the math to find where on the screen I am looking…

    How do I access screen size?
    Is it possible to find height and width separately?
    What unit is the screen size given in?
    Is the unit received from “EyePositionDataEventParams” on the Left/Right-Eye-X/Y/Z millimeters?

    BTW, documentation á la
    http://docs.oracle.com/javase/7/docs/api/
    http://slick.ninjacave.com/javadoc/
    http://lwjgl.org/javadoc/
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/
    https://docs.unity3d.com/Documentation/ScriptReference/
    is very much requested 🙂

    #352
    Robert [Tobii]
    Participant

    Hi Thomas,

    I recall that you are working with Unity. In that case you can use Screen.currentResolution to get the screen size in pixels.
    http://docs.unity3d.com/Documentation/ScriptReference/Screen-currentResolution.html

    The EyePositionData is indeed in millimeters, with the origin in the center of the screen, Z axis facing outwards.

    Thank you for your feedback regarding API docs. We have thought about using Doxygen or some other tool to auto-generate the docs from the C API header files, but have not prioritized it yet. Add it as a Feature Request and we’ll see how many others who want it urgently.

    #367
    Thomas Sjöholm
    Participant

    It is correct that I currently work in Unity. What I actually want is the real world size of the screen. It should be accessible as the ET needs it in order to know where the screen is.

    #397
    Thomas Sjöholm
    Participant

    It appears that I only need the (real world) width of the screen (preferably in millimeters) for my current purpose. Is it possible to access in any way?

    #398
    Robert [Tobii]
    Participant

    Hi Thomas,

    I was not sure this value was exposed through the API, but there is a way (although a bit cumbersome)

    1) In the EyeXHost class, add a connection changed listener (to make sure you are connected). In there, call GetSettingsAsync method on the Interaction Context:

                _context.ConnectionStateChanged += (sender, e) => 
                {
                    if (e.State == ConnectionState.Connected)
                    {
                        _context.GetSettingsAsync(SettingsPaths.EyeTracking, OnDisplaySizeSettingEvent);
                    }
                };

    2) Use this code to extract the width and height in millimeters

        private void OnDisplaySizeSettingEvent(SettingsBag settings)
        {
            Size2 displaySize;       
            PropertyBag data = (PropertyBag)settings.Data;
            
            InteractionProperty eyetrackingProperty;
            data.TryGetProperty(SettingsPaths.EyeTracking, out eyetrackingProperty);
            
            InteractionProperty displaySizeProperty;
            ((PropertyBag)eyetrackingProperty.Value).TryGetProperty(SettingsPaths.DisplaySize, out displaySizeProperty);
            
            displaySize = (Size2)displaySizeProperty.GetValueAs(typeof(Size2));
            
            print("Display size: " + displaySize.Width + " x " + displaySize.Height + " mm");
        }

    Not the easiest way as I said, but it works for me

    #447
    Thomas Sjöholm
    Participant

    Forgot to say thanks! Just what I wanted 🙂

    #527
    Robert [Tobii]
    Participant

    Update: If you are using the latest Unity SDK package (version 0.14 or later), you only need these lines in OnDisplaySizeSettingEvent

        private void OnDisplaySizeSettingEvent(SettingsBag settings)
        {
            Size2 displaySize;       
            settings.TryGetSettingValue(out displaySize, SettingsPaths.EyeTracking, SettingsPaths.DisplaySize);
    
            print("Display size: " + displaySize.Width + " x " + displaySize.Height + " mm");
        }
    #6215
    Jason Walker
    Participant

    @Robert [Tobii]

    Are these examples still valid for the latest sdk ( tobii 4C) ideally i would like to know pixel size of calibrated display that the 4c is working with ….

    Cheers
    Jay

    #6230
    Grant [Tobii]
    Keymaster

    Hi @jaymonkey, the samples should still work fine with the latest SDK.. did you have some issues running the samples yourself?

    #6232
    Jason Walker
    Participant

    I have all the samples included in the SDK building and running fine (both x86 & x64) i’ve got my middle ware running great but im currently getting screen resolution via two keys from a .ini file … these two keys are the x and y dimensions (in pixels) of the screen that the 4C is being used with … was just wondering if there is a function in the SDK that will do this … the examples in this thread return the dimensions in mm ??? so is there similar for pixels … ??

    if so any chance you could post a quick example ??

    Cheers
    Jay

    #6272
    Grant [Tobii]
    Keymaster

    Hi Jason, it seems like Unity exposes Screen size in their own API

    Screen.width
    public static int width;

    As specified in their online documentation, did you manage to find this already?
    Thanks for the update.

Viewing 11 posts - 1 through 11 (of 11 total)
  • You must be logged in to reply to this topic.