Home › Forums › Software Development › Finding Screen Size and units
Tagged: c++, screen height, screen size, screen width, unit
- This topic has 10 replies, 4 voices, and was last updated 7 years, 9 months ago by Grant [Tobii].
- AuthorPosts
- 04/02/2014 at 12:03 #350Thomas SjöholmParticipant
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 🙂04/02/2014 at 16:30 #352Robert [Tobii]ParticipantHi 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.htmlThe 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.
05/02/2014 at 13:03 #367Thomas SjöholmParticipantIt 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.
06/02/2014 at 14:54 #397Thomas SjöholmParticipantIt 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?
06/02/2014 at 15:37 #398Robert [Tobii]ParticipantHi 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
12/02/2014 at 14:40 #447Thomas SjöholmParticipantForgot to say thanks! Just what I wanted 🙂
27/02/2014 at 15:59 #527Robert [Tobii]ParticipantUpdate: 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"); }
12/01/2017 at 18:45 #6215Jason WalkerParticipant@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
Jay15/01/2017 at 21:04 #6230Grant [Tobii]KeymasterHi @jaymonkey, the samples should still work fine with the latest SDK.. did you have some issues running the samples yourself?
16/01/2017 at 01:43 #6232Jason WalkerParticipantI 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
Jay25/01/2017 at 22:25 #6272Grant [Tobii]KeymasterHi 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. - AuthorPosts
- You must be logged in to reply to this topic.