# Automatic Mobile Warning System against People with Elevated Body Temperature
## 2 Materials and Methods
### Proposed Method  
A block diagram of the developed algorithm is presented in Figure 4 and its individual stages are discussed below (for the detection of a warm object and a human head). The thermal camera records images at a frequency of 8 frames per second. Raw data are transformed into a temperature matrix in degrees Celsius. The temperature matrix with a resolution of 240 \(\times\) 320 is transferred to the image-analysis algorithm, which detects areas above 35 \({}^{\circ}\)C by means of image thresholding (with a threshold of 35 \({}^{\circ}\)C). It then selects the largest object with temperature above the threshold and tracks its position in the subsequent frames by determining the binary mask and its centroid. In the case of two (or more) warm objects (in different distances from the camera), the nearest one (the object with the highest binary mask) is selected as the first one. In the case of several objects (at the same distance from the camera), the warmest is selected. If areas other than the binary mask of the head (for example, fragments of the neck or forearms) or small areas with an elevated temperature appear after the thresholding operation, the algorithm removes them, leaving the largest and warmest area for further analysis. In the case of the next image in the sequence, the head area is determined in the same way, but it is additionally verified whether it is the closest area that meets the above-mentioned criteria. The thresholding operation is shown in Figure 4 at the stage of determining the area mask, and it is carried out for each image in the sequence. For each subsequent frame, Euclidean distance \(\Delta_{AP}\) between the coordinates of the object mask centroid (in the current frame) \(\text{C}_{XYActual}\) and the coordinates of the object mask centroid (in the previous frame) \(\text{C}_{XYPrevious}\) is determined, as shown in (1). \[\Delta_{AP}=\sqrt{(\text{C}_{XActual(i)}-\text{C}_{XPre(i)})^{2}+(\text{C}_{ YActual(i)}-\text{C}_{YPre(i)})^{2}} \tag{1}\]  
Figure 3: Attachment of thermal camera and graphic presentation of system operation. where C\({}_{XYActual}\)--X, Y coordinates of the object binary mask centroid in the current frame; C\({}_{XYPre}\)--X, Y coordinates of the object binary mask centroid in the previous frame; i--subsequent pair of images (previous and current). In addition, to determine the shift degree of the entire object in subsequent frames, the Jaccard index is calculated as shown in (2), which enables assessing to what extent the masks of areas in subsequent frames coincide. The Jaccard index (J) is the intersection of two binary images divided by the union of these images [21]. In this case, J is calculated for the binary mask of the warm object in the previous frame (marked as A) and the binary mask in the current frame (marked as B). \[J(A,B)=\frac{\left|A\cap B\right|}{\left|A\cup B\right|} \tag{2}\]  
When the degree of coverage of masks in subsequent frames is known, the effect of the object size can be considered, and it is thereby easier to estimate the distance in connection with the change in the position of the area mask centroid. As a result, shift value \(\Delta_{AP}\) and the Jaccard index are determined for each subsequent pair of frames. Figure 5 shows that, despite similar object centroid shift values, the Jaccard index for the masks is slightly different (which is related to different distances, holes in the binary mask). The Jaccard index normalizes the results of measuring the coverage of binary masks from the previous and current frame regardless of the distance and absolute size of the mask. Figure 4: Block diagram of person distance-classification algorithm. At the same time, as the distance from the observed person increases, the Jaccard index value decreases, which is one of the reasons why it is possible to determine the distance.