# Driver Fatigue Detection Based on Residual Channel Attention Network and Head Pose Estimation
## 3 Materials and Methods
### Head Pose Estimation  
The inattention that occurs when a driver is unable to maintain their head posture is a precursor to fatigue driving. In the case of excessive face rotation, head pose estimation can be used as a supplementary signal for driver fatigue detection. Therefore, this section proposes to use the EPnP method for head pose estimation, which is based on the identification of five 2D landmarks on a face by Retinaface. The 3D point distribution in the world coordinate system can usually be mapped to the point distribution of 2D images. This mapping relationship can be reflected by the rotation matrix of the camera. The rotation matrix based on the camera pose can transform into the Euler angle of the head pose (pitch, yaw, roll), which directly displays the head pose. Retinaface outputs the 2D positions of the left/right eye, the left/right mouth corner, and the nose. These five points are not coplanar in 3D space. Therefore, this study uses EPnP to determine the position, orientation, and  
Figure 3: The structure of an RCAB and its channel attention module. rotation matrix of the camera. Figure 4 shows the results of head pose estimation by EPnP in a natural scene. This study assumes that the camera extrinsic parameters and the 3D coordinates of the human face model in the world coordinate system are known. The internal parameters were calibrated by the checkerboard plane calibration method. The 3D coordinates in the world coordinate system are \(P_{i}^{w}\), \(i=1\), \(\cdots\), 5, and the 3D coordinates in the camera coordinate system are \(P_{i}^{c}\), \(i=1\), \(\cdots\), 5. EPnP requires each 3D point to be a weighted sum of four control points. The coordinates of the four control points in the world coordinate system are \(c_{j}^{w}\), \(j=1\), \(\cdots\), 4. The coordinates of the four control points in the camera coordinate system are \(c_{j}^{c}\), \(c_{j}^{c}\), \(j=1\), \(\cdots\), 4. Therefore, \(P_{i}^{w}\) and \(P_{i}^{c}\) can be represented by the following equation:  
\[P_{i}^{w}=\sum_{j=1}^{4}a_{ij}c_{j}^{w},P_{i}^{c}=\sum_{j=1}^{4}a_{ij}c_{j}^{c},\text{with}\sum_{j=1}^{4}a_{ij}=1 \tag{4}\]  
where \(a_{ij}\) are homogenous barycentric coordinates of control. Ref. [21] gives a specific method to determine the control points. In the world coordinate system, select the centroid of the 3D point as the first control point:  
\[c_{1}^{w}=\frac{1}{n}\sum_{1}^{n}P_{i}^{w},\text{with }n=5 \tag{5}\]  
Then the matrix \(A\) is obtained and can calculate the eigenvalue \(\lambda_{w,i},i=1,2,3\) of \(A^{T}A\). The eigenvector of \(A^{T}A\) is \((v_{w,i},i=1,2,3)\). \(A\) is shown in Equation (6), and the remain three control points can be determined by Equation (7). \[A= \begin{bmatrix}P_{1}^{w^{T}}c_{1}^{w^{T}}\\ \frac{1}{P_{3}^{w^{T}}c_{1}^{w^{T}}}\end{bmatrix}  \tag{6}\]  
\[c_{j}^{w}=c_{1}^{w}+\lambda_{w,j-1}^{\frac{1}{2}}v_{w,j-1},j=2,3,4 \tag{7}\]  
Therefore, the weight of the four control points can be calculated by the following equation:  
\[\left[ \begin{array}{c}a_{i1}\\ a_{i2}\\ a_{i3}\\ a_{i4}\end{array} \right]=\left[ \begin{array}{cccc}c_{1}^{w}&c_{2}^{w}&c_{3} ^{w}&c_{4}^{w}\\ 1&1&1&1\end{array} \right]^{-1}\left[ \begin{array}{c}P_{i}^{w}\\ 1\end{array} \right]^{-1} \tag{8}\]  
Figure 4: Results of head pose estimation by EPnP in a natural scene. **1** and **2** indicate that the head postures are normal. **3** and **4** indicate abnormal head rolling angles. **5** and **6** indicate abnormal head pitch angles. **7** and **8** indicate abnormal head yaw angles. This study assumes a camera with internal parameters calibrated. The calculation equation of \(P_{i}^{c}\) can be rewritten as:  
\[z_{j}^{c}\left[ \begin{array}{c}u_{i}\\ v_{i}\\ 1\end{array} \right]=\left[ \begin{array}{ccc}f_{u}&0&u\\ 0&f_{v}&v\\ 0&0&1\end{array} \right]\sum_{j=1}^{4}a_{ij}\left[ \begin{array}{c}x_{j}^{c}\\ y_{j}^{c}\\ z_{j}^{c}\end{array}