# HelpResponder--System for the Security of First Responder Interventions
## 4 Implementation of the Safe and Flame-Aware Intervention Architecture
### Fire Detection System  
In this section, we will explain the fire detection algorithm for the MGAV. The FLIR A65 [35] camera was chosen as a thermal imaging temperature sensor for fire detection and condition monitoring. This camera offers comprehensive visual temperature monitoring. A UDOO XII ADVANCED PLUS [36] module has been used to process the video captured by the FLIR A65 camera. The computer vision algorithm designed for fire detection in thermal imaging can operate with video sequences in low visibility conditions. Figure 2 shows the scheme that describes the implemented algorithm operation's operation; Figure 3 explains it in more detail. The fire detection algorithm performs temporal analysis and color filtering to detect fire candidate regions in the image. The camera has a robust design that can withstand harsh conditions, and it can operate in temperatures up to 140 \({}^{\circ}\)F (60 \({}^{\circ}\)C). The temperature range measured on objects with this camera is \(-40\)\({}^{\circ}\)C to 550 \({}^{\circ}\)C (\(-40\) to 1022 \({}^{\circ}\)F). We extract features to discriminate fire from other similar regions such as area, boundary disorder, and average intensity measured for each obtained region. The algorithm receives as input the type of image to be processed. The first detection stage (FirePreprocessor), see Figure 3, improves the image characteristics to simplify the detection tasks in the following stages. Firstly, ROIs (Regions Of Interest) are established along with rescaling with linear interpolation. The objective is to decrease the number of pixels to be processed. Secondly, Gaussian smoothing is the traditional denoising method. This method allows the transformation of the images to the HSV (Hue Saturation Value) color space, removing the noise. Finally, the image contrast has been enhanced by combining two techniques: CLAHE (Contrast Limited Adaptive Histogram Equalization) and ImageEnhace. Contrast with a factor of 1.5. Once we have the processed images, the segmentation of candidate regions is started (FireSegmentation). The first method is a color filter based on the HSV format to get the hot elements located at the scene. The values are as follows:  
\[\textit{Colour\_min}=\textit{[0,0,105]}\quad\textit{Colour\_max}=\textit{[10,50,255]} \tag{1}\]  
Those parameters were obtained from several tests with the camera in an indoor space with smoke. We have deployed and evaluated the system using a moving camera in this work. Therefore, image processing is more complicated than when using static cameras. Figure 2: General block diagram of the fire detection system. At this point, the elements of the buffer that have got this previous filter have been obtained. Temporal analysis is performed. This analysis will identify the objects that are presented in all the images. Moreover, it has been taken into account that the fire is a dynamic element. The hypothesis is that the next elements of the scene are static--the volume and movements do not change. Once the binary images are obtained from the color filter, Equations (2)-(4) describe the subtraction of images:  
\[\textit{diff\_2\_1}=\textit{cv2.absdiff}(\textit{image\_binary\_current},\textit{ image\_binary\_previous1}) \tag{2}\]  
\[\textit{diff\_2\_0}=\textit{cv2.absdiff}(\textit{image\_binary\_current},\textit{ image\_binary\_previous0}) \tag{3}\]  
\[\textit{diff\_image}=\textit{cv2.absdiff}(\textit{diff\_2\_1},\textit{diff\_2\_0}) \tag{4}\]  
The result shown in Figure 4 is a binary image. The pixels of the objects that appear in the three images are the foreground pixels. They also have varied positions. Figure 3: Fire detection algorithm schematic. In this stage, the next step is getting and checks the regions of the current image. The target is to detect flame or fire where the pixel in movement belongs, see step at Figure 3 and the result in Figure 4. These steps are explained in Algorithm 1 and the diagram below (Figure 5). This process detects elements in a movement that have passed the color filter.