## 3 Methodology
### Dlib Facial Landmark Detection and Preprocessing  
A pretrained Dlib-based facial landmark detector was used for this research; this detector is capable of returning 68 facial landmarks of a given human face image (Figure 4a). This detector runs on the server as a service written in C++m and it can detect and record all sixty-eight landmarks under the image name in JavaScript object notation (JSON) format.  
Firstly, in the preprocessing stage, all the landmarks related to detected faces are standardized into 300 px (width) \(\times\) 400 px (height) after finding the size of the bounding box of the face. Therefore, all the face bounding boxes for each face image end up with the same 300 px \(\times\) 400 px size. Using 68 facial landmarks, several Euclidean distances, key landmark points, and a few calculated values are obtained and used as inputs to the SVM models to identify the relevant emotion class and the attention level. The key features are shown in Table 1. This is a novel and very important dimension reduction mechanism due to the fact that it reduces 136 values related to 68 facial landmark points to 11 values without losing needed information for the classification models. This reduces the complexity of the ML models.  
The mean coordinates and the nose point of the facial landmarks give an idea of the face direction, i.e., an ideal indication of the head pose. Left and right mouth corner vector calculations take a few more steps than other calculated features. These are the lengths and direction signs (vectors) of the projections on a point on the vertical line going through the middle of the mouth (Figures 4b and A1). These vectors contain information about the shape of the mouth. All other Euclidean distances also indicate key features of the face such as eye-opening height and mouth-opening height (Figure 5).  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Feature Name** & **Description** \\ \hline \multirow{2}{*}{Mouth opening height} & Euclidean distance from landmark 63 to landmark 67. \\  & Average of Euclidean distance from landmark 38 to landmark 42 and Euclidean distance from landmark 39 to landmark 41. \\  & Average of Euclidean distance from landmark 44 to landmark 48 and Euclidean distance from landmark 45 to landmark 47. \\  & Euclidean distance from mid-point of facial \\  & landmarks 38 and 39 to facial landmark 20. \\  & Euclidean distance from mid-point of facial \\  & landmarks 44 and 45 to facial landmark 25. \\  & Facial landmark 34’s \(X\)-coordinate. \\  & Facial landmark 34’s \(Y\)-coordinate. \\  & Average of the \(X\)-coordinate values of all \\  & facial landmarks. \\  & Average of the \(Y\)-coordinate values of all \\  & facial landmarks. \\  & OS’ vector calculation based on mouth \\  & landmark coordinates (Figures 4b and A1) \\  & OR’ vector calculation based on mouth \\  & landmark coordinates (Figures 4b and A1) \\ \hline \hline \end{tabular}
\end{table}
Table 1: Calculated features based on facial landmarks.  
After the preprocessing stage is finished for the dataset with a balanced number of images for each class, SVM model training can be started for attention classification and emotion classification. This is best practice to avoid the bias of the model toward some image classes.