Determining the exact size of the eyes

In the Cardboard app for Android, I want to display an overlay in every eye that is centered. Simple LinearLayout creation with two centered views is pretty simple and works for most phones, as the eyes are attractive for the best fit:

Video in CarboardView

If this is not so, then it becomes something worthwhile in every eye. This is most clearly illustrated when using a tablet:

Centering Eye CardboardView

I am trying to get the message "Buffering, 0% ..." concentrated inside each kind of eye.

The size of the rendering fields for the eyes has a fixed size (of course, since the distance between the eyes of a person has a fairly fixed size). Unfortunately, CardboardView does not provide information about the exact size and / or position of the eyes.

I looked at getting the left and right eyes through cardboardView.getCurrentEyeParams() (strangely undocumented), for which each Eye contains a Viewport . This seems to give size and position, but its values ​​are not directly related to the size and placement on the screen.

On the LG G2 with a screen resolution of 1920 and 1080, Viewports:

 Viewport left: { x: 0, y: 0, width: 1150, height: 1177, } Viewport right: { x: 1150, y: 0, width: 1150, height: 1177, } 

In Nexus 9 with a screen resolution of 2048 and 1536, viewports:

 Viewport left: { x: 0, y: 0, width: 802, height: 802, } Viewport right: { x: 802, y: 0, width: 802, height: 802, } 

Both of these sizes (if they are in pixels) are much larger than the actual image, and in the case of the LG G2, the width and height are really larger than the screen size of 1080 pixels.

Having looked at some decompiled SDK Cardboard code, it seems that the vignetting square around the eyes is drawn through the inner class DistortionMesh, and displayed through a somewhat complex code . (Note that some logic seems to be missing through decompilation, such as lines 195 and 199.)

Creating a Viewport assumes that the values ​​are really pixels (offset in meters times pixels per meter). Is it possible that the DistortionMesh or EyeView matrix is applied to the Viewport before rendering? In any case, I feel that I am not looking in the right place.

I also looked at getting ScreenParams , as it also provides width and height. Unfortunately, this returns the entire screen size on both devices, and also does not seem relevant.

My current superimposed approach is a custom ViewGroup that centers two children, calling child.layout() , using the height of the ScreenParams and half its width.

How can I understand how big the eyes are in the StereoRenderer? Can I find another way to center another view in my eyes?

+6
source share

All Articles