# Face Spoofing Detection with Stacking Ensembles in Work Time Registration System
## 3 The Proposed Method
### Smartphone Bezel-Detection Algorithm  
The first developed module is a bezel-detection algorithm designed to detect whether a spoof face is displayed on an electronic device such as a smartphone or tablet. It does so by detecting high-contrast edges around the displayed face, and if enough edges of a certain size are detected, then the spoof is detected.  
First, pre-processing is performed on each image to normalize it and adapt it to different sizes of input images and positions of faces. The input images undergo resizing to 256 \(\times\) 256 pixels. Then, the face is detected, and the image is converted to grayscale. An example of this pre-processing is presented in Figure 6.  
To detect a bezel, the center point of the detected face is selected, and then the image is analyzed in four directions toward the edges. Iteratively, smaller and smaller fragments of the image are selected, and their average brightness is calculated. If the average is below a set value (in this case, a threshold of 28 for values between 0 and 255), then the fragment is considered a part of the bezel of an electronic device. This is presented in Algorithm 1. If bezels are detected in at least two directions, then the algorithm detects a spoofing attempt. For most cases, this ensures that even if a single bezel is detected due to uniform background colors or elements of the face (like dark hair), the face will not be mistaken for a spoof. This process is depicted in Figure 7.  
This algorithm is optimized for computational efficiency to minimize processing time. In addition, all algorithms are executed in parallel, further accelerating the overall analysis.  
\begin{table}
\begin{tabular}{c c c} \hline
**Layer (Type: Depth-Idx)** & **Output Shape** & **Param \#** \\ \hline BezelDetectionNet & [32; 2] & – \\ \hline Conv2d: 1-1 & [32; 32; 128; 128] & 896 \\ \hline BatchNorm2d: 1-2 & [32; 32; 128; 128] & 64 \\ \hline MaxPool2d: 1-3 & [32; 32; 64; 64] & – \\ \hline Conv2d: 1-4 & [32; 64; 64; 64] & 18,496 \\ \hline BatchNorm2d: 1-5 & [32; 64; 64; 64] & 128 \\ \hline MaxPool2d: 1-6 & [32; 64; 32; 32] & – \\ \hline Conv2d: 1-7 & [32; 128; 32; 32] & 73,856 \\ \hline BatchNorm2d: 1-8 & [32; 128; 32; 32] & 256 \\ \hline MaxPool2d: 1-9 & [32; 128; 16; 16] & – \\ \hline Conv2d: 1-10 & [32; 256, 16; 16] & 295,168 \\ \hline BatchNorm2d: 1-11 & [32; 256; 16; 16] & 512 \\ \hline MaxPool2d: 1-12 & [32; 256; 8; 8] & – \\ \hline Linear: 1-13 & [32; 1024] & 16,778,240 \\ \hline Linear: 1-14 & [32; 512] & 524,800 \\ \hline Linear: 1-15 & [32; 2] & 1026 \\ \hline Total params: & & 17,693,442 \\ \hline Trainable params: & & 17,693,442 \\ \hline Non-trainable params: & & 0 \\ \hline \end{tabular}
\end{table}
Table 2: Details about the proposed neural network architecture for the smartphone detection module.  
Figure 6: The input image (**left**) and the image preprocessed by the bezel-detection algorithm (**right**).  
Figure 7: The output image generated by the bezel-detection algorithm from the image in Figure 6. The red rectangle represents the detected face, while the green rectangles represent the detected bezels.