## 3 Materials and Methods
### The TFTH Architecture
Some recent mobile devices (table PCs and smartphones) do have specialized hardware for face recognition and tracking that might be used for eye tracking, but such a feature is not yet available on the most common and more affordable mobile devices. External (USB) eye trackers available on the market usually require proprietary drivers that do not provide sufficient support for handheld devices. Similar issues affect most commercially available software solutions. For this reason, in [39], we developed a software solution for eye gaze tracking designed to work in both natural and near-infrared light. The proposed solution does not rely on special hardware or head-mounted devices, as in [40, 41, 42] or in some commercial solutions [43]. Gaze trackers are, in most cases, based on conventional IR pupil or corneal reflection [44] or more complex computer vision algorithms (depending on the available hardware) [45, 46, 47]. The approach adopted in TFTH was directly derived from [39] and optimized to best meet the needs of mobile device users. In particular, the screen size is between 5 and 11 inches, and the orientation is usually vertical (portrait). Furthermore, other specific issues had to be addressed, such as the low resolution of the input eye image, the non uniform illumination and the dependency of the eye gaze direction on both the head and camera orientations. Figure 2 provides a visualization of the intermediate results of the eye tracker for testing and debugging purposes. The 7-inch display of a Linux-based netbook is shown, where three separate windows show the orientation of the face and of the left and the right eyes. In addition, a small blue circle shows where the eye gaze of the user is actually pointing. In the figure, the eye images are horizontally flipped, so the user was looking approximately to the right of the screen. The gaze tracker is intended to work on an average mobile CPU and does not require the support of a powerful GPU or specialized hardware for deep learning computation. To this end, it uses the face detector from the OpenCV library [37] and the face pose estimator and face parts detector from the Dlib library [38]. Figure 3 illustrates the very simple algorithm adopted. Once the pose of the head is estimated and the eyes are detected, each eye region undergoes histogram equalization and gray level filtering to improve the image quality. Then, a correlation-matching filter is applied which produces an image where the points that have a higher probability of being the centers of the eye pupil have higher brightness. This likelihood image is then weighted by a 2D Gaussian mask determined for each frame and each eye according to the size and shape of the eye image in that frame. Such a mask represents a \"prior\" that constrains the position of the pupil in the eye according to its size and shape. Finally, the point that features the maximum a posteriori (MAP) probability of being the center of the pupil is selected. The orientation angles of the two pupils are then averaged to obtain a more reliable estimate of the direction of the gaze of the eye. A five-fixed-point calibration procedure is applied to map the averaged gaze vectors of the two eyes on the device screen. The resolution obtained, by no means comparable to that of modern hardware-based gaze trackers, is sufficient for our purposes, as described in Section 3.2.