Pupil Geometry

I’ve been trying to reduce the number of free variables in the mapping between the position of the pupil in a eye-camera image and the point of gaze on a screen, given the head location of a person. Previously I was just fitting an ellipse to the pupil and using the location of its centre. This method did not use all of the information I’d just obtained about the ellipse. In this post I explore one theoretical method of using the ellipse parameters.


We can approximate the eyeball as a sphere with a circle on which corresponds to the pupil. We’ll describe the size of the pupil by the radius of the sphere r and the angle rho between the lines from the centre of the sphere to the centre of the pupil and to any point on the edge of the pupil, see figure 1.

Figure 1 – The major axis

If the eye is looking directly into the camera the pupil will appear to be circular (assuming minimal or corrected camera lens distortion). We will define the center of the pupil in the image plane in this case to be (x_o, y_o). Since the pupil will appear to be a circle all its axes are equal. The red and the blue lines in figure 1 have the same length. This length a can be calculated by:

a = 2 \sin(\rho) .

Figure 2 – The rotated eye

As the eye turns away for the camera the pupil image will become elliptical. Consider the eye following some line on the image plane which passes through (x_o, y_o) by rotating the eye through an angle \tau in the plane defined by our line and the center of rotation of the eye. The pupil will now appear to be an ellipse with its major axis the same length as before (the red line) but with a shorter minor axis.

The length of the minor axis b can be calculated from the internal angles of the quadrilateral to calculate the angle \lambda. Note that \lambda is the angle BED and is equal to the angle BFC

2 \pi = \frac{\pi}{2} + \frac{\pi}{2} + \tau +\frac{\pi}{2} + \lambda
\lambda = \frac{\pi}{2} - \tau

so we have

b = 2sin(\rho) sin(\lambda)

We consider it in 3D by just rotating orthogonally to the plane of rotation of \tau .

Figure 3 – Blow up of the angles from Figure 2 and  rotation by the second angle

These two rotations can move to pupil to any place on our model eyeball. There are two nice properties of this circle on a sphere. Firstly the line passing through the minor axis of the ellipse in the image passes through the centre of the eye in the image (x_o, y_o). This fact means that the center of the eye can be determined from two images of the pupil in different positions by finding the intercept of the two lines defined by the minor axis.

This property allows us to calculate the angle \gamma from the angle of the minor axis and the position of the pupil relative to (x_o, y_o)

The second useful property is that can calculate gamma from the ratio of the minor axis.
We can will consider the ratio of the major and minor axes. This measure will be invariant as the pupil size varies.

\frac{a}{b} = \frac{2 sin(\rho)}{2sin(\rho) sin(\lambda)} = \frac{1}{sin(\lambda)}

From this we can directly calculate \tau as follows:

\tau = \frac{\pi}{2} - sin^{-1}(\frac{b}{a})

If we have at least two images of the eye we can describe the rotation of the eye by (\tau, \gamma). These angles can be used to generate the unit vector g' where

g' = \left( \begin{array}{c} cos(\gamma) sin(\tau) \\ sin(\gamma) sin(\tau) \\ cos(\tau) \end{array} \right)

These unit vectors then have to be rotated to align with the real world. The rotation matrix can be described by three scalars.

Further work

In this analysis we assume that the eye is a sphere, rotating about it center: a fixed point relative to the camera and that we are able to accurately extract the ellipse describing the pupil. We do not consider the effects of noise, error or perspective. I’ve also assumed that the edge of the pupil is always on the edge of the sphere – when in fact it is more like a circle on a plane cutting through the eye (ouch). I have a feeling that this is not a problem as it is equivalent to the eyeball changing size as the pupil changes size.

Leave a Reply