Random Forest Feature Selection and Back Propagation Neural Network to Detect Fire Using Video

State Key Laboratory of Reliability and Intelligence of Electrical Equipment, Hebei University of Technology, Tianjin 300401, China Hebei Key Laboratory of Robot Sensing and Human-Robot Integration, Tianjin 300401, China School of Mechanical Engineering, Hebei University of Technology, Tianjin 300401, China School CITIC Heavy Industry Kaicheng Intelligent Equipment Co., Ltd., Tangshan 063000, China


Introduction
With the continuous improvement of social development, the possibility of fires with large losses is also increasing. The traditional fire recognition methods mainly use detectors to sample the temperature, spectrum, and smoke of a specific region to determine whether a fire has occurred [1]. However, due to the limitation of the detection range and sensitivity of the detector, it is difficult to achieve timely detection in open spaces and harsh environments.
In recent years, fire recognition based on image processing technology has become the focus of researchers' attention. By analyzing the static and dynamic features of flame, researchers can distinguish flames from other objects. The static features of flame mainly include color and texture features. Chen et al. [2] proposed a flame recognition rule in RGB and HSI color space by analyzing the chromaticity and disorder of flames. Celik and Demirel [3] proposed a flame classification model based on YCbCr color space, and this flame model can better adapt to lighting changes compared with the RGB color model. Wang and Ren [4] improved the image brightness by performing histogram equalization on the V channel in HSV color space and then combined the flame pixel distribution rules in RGB and YCbCr color space to perform image segmentation. Prema et al. [5] extracted texture features based on wavelet decomposition and then used an extreme learning classifier to classify images. Their method can effectively eliminate red interference. Sheng et al. [6] studied the color, texture, and gray-scale statistical features of flame images and constructed a deep belief network (DBN) for fire detection. Jamali et al. [7] introduced texture features based on color features to detect fires. They combined different features to improve the accuracy of the fire detection system.
The dynamic features of flame mainly include motion features and geometric change features. Barnich and Van Droogenbroeck [8] proposed a visual background extractor (ViBe) algorithm, which provides a new idea for extracting flame motion features. To improve the overall performance of a fire detection system, Foggia et al. [9] attempted to combine the information of color, motion, and shape change to reduce the false alarm rate of the system. Gong et al. [10] proposed a flame centroid stabilization algorithm. They used color and motion features to segment suspected flame regions and further judged whether it is a flame by analyzing the changes of its area, shape, and center of mass.
The fire recognition model mainly includes machine learning classifiers and deep learning networks. Yang et al. [11] analyzed the shape features of flames and used support vector machine (SVM) to recognize fire images. Huang and Du [12] proposed a fire recognition method combining rough set (RS) theory and SVM. Their method can reduce overfitting and improve the accuracy of fire prediction. Qu et al. [13] extracted the red and blue color components and brightness component of flames in YCbCr color space and used the back propagation (BP) neural network model to detect fires. Li and Zhao [14] performed fire detection based on convolutional neural network (CNN) such as Faster-RCNN, R-FCN, SSD, and YOLO v3. Sheng et al. [15] improved the detection capabilities of flames and smokes by combining simple linear iterative clustering (SLIC), density-based spatial clustering of application with noise (DBSCAN), and CNN. Muhammad et al. [16] proposed a CNN framework for fire detection. The framework can be applied to video surveillance systems.
The above researches have enriched and developed fire recognition methods, but there are still some important problems. Firstly, region segmentation based on color features will inevitably overlap with the color space of other objects, which may result in inaccurate segmentation of suspected flame regions. Secondly, the extracted flame features are not comprehensive or have little correlation to the classification and recognition model, which makes it difficult to achieve accurate fire recognition in complex scenes. Thirdly, deep learning methods require high equipment performance, and the related model training and testing are complex.
In view of the shortcomings of the current fire recognition methods, the flame color model and the ViBe algorithm are combined to segment suspected flame regions in this paper. Then, multidimensional features are extracted on the suspected flame regions, and the random forest (RF) method is used to analyze the importance of each feature, and then, these features are combined and selected accordingly. Finally, a BP neural network model is built for fire detection. The proposed fire detection method is verified by using several experimental video sets. This paper is organized as follows: Section 2 describes a hybrid approach adopted in this study. Section 3 presents experiments and experimental results with discussions. Section 4 concludes this paper.

Region Segmentation Based on Color Model and ViBe
Algorithm. Region segmentation is a process to divide an image (being processed) into multiple regions with different characteristics and then to separate the target region from its background. The flame presents a special color distribution pattern and has the dynamic characteristics of spreading and diffusion. Therefore, the suspected flame region in an image can be segmented by using the color model and moving target detection method.
2.1.1. Color Model for Segmentation. In order to describe the color distribution of flame pixels, a statistical flame color model can be established. Yan et al. [17] established a color model of flames in RGB and HSI color space. The color model overcomes the cavity inside flames to a great extent, but there is still undersegmentation of the interference with high saturation. In the study of flame image saturation, Horng et al. [18] proposed an HSI color model of flames, which restricted the saturation component. Combining the characteristics of flames in RGB and HSI color space, we adopt the flame color segmentation rules as shown in where T 1 = |R − G|, T 2 = |G − B|, and T 3 = |R − B|. R, B, and G are the red, blue, and green color components of an image, respectively. R 0 is the threshold of the red component of an image. S 0 is the threshold of the saturation of an image. For a darker environment, S 0 = 20, and a brighter environment, S 0 = 40. R 1 and G 1 are the improved thresholds of the red and green components of an image, respectively. Th 1 , Th 2 , and Th 3 are the thresholds of T 1 , T 2 , and T 2 + T 3 , respectively. We use the improved color model, equation (1), to separate the region in the image that meets the constraints of the color model from the background. The images collected by Chino et al. [19] were used to test the segmentation effect. Figure 1 shows a segmentation example of a flame image using different flame color models.
From Figure 1, it can be found that compared with the method in [17], the improved color model can effectively eliminate the brown-yellow wood and the illuminated ground and achieve the accurate segmentation of the flame regions.

ViBe Moving Target Segmentation.
It is difficult to exclude objects whose colors are highly similar to flames only by using the color model, so it is necessary to segment moving objects based on the dynamic features of flames in a video. In the process of fire recognition, the interframe difference method [20], optical flow method [21], or background subtraction method [22] are commonly used to segment moving targets. The interframe difference method has low computational complexity, but it depends too much on the moving speed of the target. The optical flow method is computationally complex and sensitive to light. The background subtraction method is simple, and the extracted target is complete. The background subtraction method includes Gaussian mixture modeling (GMM) [23] and ViBe modeling methods [24] to establish the background statistical model. Compared with the GMM method, the ViBe algorithm randomly selects neighborhood pixel values to model or update the background according to the similarity between the neighboring pixels and does not need a lot of estimation or operation, so its time complexity to build a background model is lower. The followings are the calculation process of the ViBe algorithm: (1) Background model initialization. The background model initialization is the process to fill pixel sample set for building a background model. For each pixel in an image, use v i ðx, yÞ to represent its pixel value. Taking a certain point ðx, yÞ as the center, N samples are randomly selected within a certain radius to build a sample set of the background model. The sample set vðx, yÞ can be defined as follows: (2) Moving target detection. For the point ðx, yÞ in an image to be tested, its pixel value mðx, yÞ is compared with each sample value in the background model. If the absolute value of the difference with a certain sample point is greater than a given threshold K 0 , the sample point is considered not similar to the point to be detected. If there are more than the given number K 1 of sample points that are not similar to the point to be detected, the point is considered to be the foreground (moving target). Otherwise, the detected point is the background, as shown in where D n ðx, yÞ represents the distance between the point to be detected and the n th sample point. f ðx, yÞ represents the judgment result of background or foreground (3) Background model update. The ViBe algorithm uses a random updating strategy to update the background model from time to time. After a certain period of time t, the probability Pðt, t + dtÞ that a certain sample in the sample set is still retained can be defined as follows: The accuracy of region segmentation will affect feature extraction. The more accurate region segmentation is, the more extracted flame features can reflect the actual situation of flames. In the proposed hybrid method of video fire detection, color and motion features are combined for region segmentation. Based on the color distribution of flames in RGB and HSI color space, the improved color model is adopted to obtain segmented images. Meanwhile, the ViBe algorithm is adopted to obtain segmented images based on motion feature. The improved color model segmentation images and ViBe algorithm segmentation images are intersected, and the final suspected flame regions are obtained after corrosion, expansion, and region filling. Figure 2 shows some  Figure 2, the region segmentation method combining the improved color model and ViBe algorithm can effectively exclude the land with color similar to flame and the moving pedestrians and get an accurate flame region.

Multidimensional Feature Extraction and RF Feature
Selection. With the improvement of the ability of sensors to obtain information, multifeature fusion technology is widely used in the field of image recognition [25]. After region segmentation, there may still be regions that are mistakenly segmented as flames. Thus, it is necessary to extract multidimensional features such as geometry, texture, and dynamics of images and use multifeature fusion technology to achieve fire detection. However, some features are irrelevant or redundant to the recognition model, so it is necessary to select the feature subset with high discriminative ability from the multidimensional features.

Multidimensional Feature Extraction.
The multidimensional features extracted from an image mainly include its circularity, aspect ratio, texture features, area change rate, flicker feature, and edge jitter feature. The followings are a brief introduction and related formulas for each of them: (1) Circularity. Circularity reflects the degree to which the shape of the target region is close to a theoretical circle. The circularity C is calculated as where S represents the area of the flame region and L represents the perimeter of the flame region (2) Aspect ratio. Aspect ratio reflects the stretching degree of a flame. The aspect ratio W is calculated as where E represents the width of the smallest rectangle in the flame region and H represents the length of the smallest rectangle in the flame region (3) Texture features. In the description of the spatial relationship of image textures, the commonly used method is based on the statistical gray-level cooccurrence matrix (GLCM) [26], which is used to calculate the representative contrast, correlation, energy, and homogeneity of texture features. Specifically, the pixel offset is set to 1, and the texture feature statistics are calculated from the GLCM at four different angles of 0°, 45°, 90°, and 135°, and then, the average value of the four directions is taken as texture feature criterion for fire recognition.
The gray value of two points at a certain distance in an image is represented by ði, jÞ. Suppose Pði, jÞ is the probability of the gray value ði, jÞ. The formula of its contrast f 1 , correlation f 2 , energy f 3 , and homogeneity f 4 of the image is as follows: 4 Journal of Sensors where K represents the gray level of an image. μ x and μ y represent the mean value of Pði, jÞ in row and column, respectively. σ x and σ y represent the standard deviation of Pði, jÞ in row and column, respectively (4) Area change rate. Area change rate represents the area change of a flame region. The area change rate ΔS is calculated as where S n represents the area of the flame region in the current frame and S n−1 represents the area of the flame region in the previous frame (5) Flicker feature. Flame flicker will cause the image pixels to change from nonflame to flame. In order to effectively reflect the flicker characteristics of a flame without increasing the complexity of the algorithm, the change amplitude of the flame foreground is used to characterize the flicker feature of the flame.
The flicker feature ΔF is calculated as (6) Edge jitter feature. Edge jitter measures the degree of the edge change of an object in the process of deformation. The edge jitter feature ΔL is calculated as where L n represents the perimeter of the flame region of the current frame and L n−1 represents the perimeter of the flame region of the previous frame 2.2.2. Random Forest Feature Selection. Random forest (RF) [27] is an integrated machine learning method that uses decision tree as the basic learner and makes decision through voting mechanism. For feature selection, the importance of a single feature variable is calculated by the RF method, and then finding the feature variables that are highly related to the dependent variable. Thus, we can select a small number of feature variables which can fully guarantee the accuracy of the prediction results.
The purpose of feature selection is to select the relevant feature subset from the existing feature set. After feature extraction on the suspected flame region, we can get a 9dimensional feature vector ½C W f 1 f 2 f 3 f 4 ΔS ΔFΔL. We use the RF method to select the features with a strong correlation with the actual results as the input of the BP neural network model.
Since there is no published standard dataset in the field of fire prevention and detection at present, we mainly use a series of typical databases proposed in [28][29][30] to build our video set. Our video set includes 30 fire videos and 10 interference videos. Fire videos mainly include different shapes of flames in indoor, highway, and forest scenes. Interference videos mainly include street lights, car lights, and red objects. The resolution of the videos is uniformly adjusted to 1280 × 720, and 20 consecutive frames of images are selected from each video to form a sample dataset. The sample dataset has a total of 800 images, some of which are shown in Figure 3.
In this paper, the suspected flame regions are segmented on the sample dataset and the multidimensional features of the flame are extracted. The RF feature importance is calculated based on the Scikit-learn tool in the Python machine learning library. Specifically, the number of decision trees in the RF is set to 100, and the maximum depth of the decision trees is set to unlimited. The minimum number of samples required to split an internal node is set to 2; the minimum number of samples required to be at a leaf node is set to 1. The measurement criterion of split quality is set to mean square error (MSE). The ranking of the feature importance is given in Figure 4. From Figure 4, it can be found that flicker feature has the highest ranking and edge jitter feature has the lowest ranking.
According to the ranking in Figure 4, the flame features are divided into combined features F1-F9, which, respectively, represent ½ΔF, ½f 1 ΔF, ½C f 1 ΔF, ½C W f 1 ΔF, ½C W f 1 f 3 ΔF, ½C W f 1 f 3 f 4 ΔF, ½C W f 1 f 2 f 3 f 4 ΔF, ½C W f 1 f 2 f 3 f 4 Δ S ΔF, and ½C W f 1 f 2 f 3 f 4 ΔS ΔFΔL. The BP neural network method is used for training and classification, and the correct classification results of each combination feature are given in Figure 5. The correct classification rate is the average of 10 prediction results.
According to the classification results of the combined features as shown in Figure 5, the correct classification rate of samples reaches a high level starting from the 5 th combined feature, F5, and with the increase of features, the correct classification rate of samples tends to be stable. To avoid interference caused by excessive features and ensure the accuracy of classification results, the 5 th combined feature, F5, is selected for fire recognition, which includes circularity, aspect ratio, contrast, energy, and flicker feature.

Construction of the BP Neural Network
Model. The BP neural network [31] is also called error back propagation neural network. Because the weights of neurons in adjacent layers are interrelated, the network has a nonlinear mapping ability to solve complex problems. Considering the simplicity and practicability, a three-layer BP neural network with 5 Journal of Sensors one input layer, one hidden layer, and one output layer is constructed for multifeature fusion and fire recognition.
The number of nodes in the input layer of the BP neural network depends on the dimension of the feature vector. In this paper, five features of each fire image are selected to form the feature vector ½C W f 1 f 3 ΔF, so there are 5 nodes in the input layer. The output layer outputs the recognition result, so there is 1 node. The normalized output value ranges from [0, 1], and when the output value belongs to [0, 0.5), it means nonflame. When the output value belongs to [0.5, 1], it is expressed as flame. The number of hidden layer nodes is calculated using empirical equation (12), in which, m and n represent the number of nodes in the input layer and output layer, respectively, and a is a constant between [1,10]. Through repeated experiments, it is found that when the number of the hidden layer nodes h is 10, the neural network achieves the optimal training effect.
Ultimate chase.com Ultimate chase.com    Journal of Sensors Based on above analysis, the structure of the BP neural network constructed in this paper is given in Figure 6. The BP neural network model will be used for fire recognition in the following section.

Detection
Process. The process of video fire detection in this paper is given in Figure 7. 3.3. Training and Experiments. The sample dataset of the training set and the test set is divided based on typical standards of 70% and 30%. The division is given in Table 1. Specifically, the maximum number of epochs is set to 2000. The Levenberg-Marquardt (LM) algorithm is selected as the learning algorithm, and the learning rate is set to 0.001. MSE is used as the loss function, and the minimum value of the loss function is set to 0.01. The neural network training performance is shown in Figure 8. From Figure 8, it can be found that the value of the loss function gradually decreases during the training process and reaches the minimum value of the set loss function at 30 epochs.
After neural network training is completed, the correct classification rate on the test sample set is 96.67%. In order to further verify the performance of the fire detection method, five videos that have not participated in the training are selected to test the trained neural network model, including three fire videos and two interference videos. The experimental video sets are shown in Figure 9. The descriptions of the experimental videos are shown in Table 2.

Results
Analysis. The combined RF feature selection and BP neural network method (abbreviated as RF-BP) and the directly performed BP neural network method (abbreviated as Dir-BP) are used to do tests with several experimental videos. Furthermore, the two proposed methods are compared with the fire recognition method in [11,13]. The accuracy, precision, recall, and F-score are used to evaluate the effect on fire recognition [32], as shown in Precision = TP TP + FP , ð14Þ where TP represents the number of correctly classified frames of the fire videos. TN represents the number of correctly classified frames of the interference videos. FN represents the number of misclassified frames of the fire videos.     The fire recognition result is determined by the output value of BP neural network. The experimental results are given in Table 3, and the recognition effect evaluation is given in Table 4.
For the scene in Figure 9, the lights and the ground illuminated by the lights may be segmented into suspected flame areas. In [11], the shape change and centroid displacement of flame are concerned, and the recognition of fire images was realized by support vector machine. Since the lights follow the movement of the vehicle in interference videos, the ground illuminated by the lights has dynamic features similar to flames. This method did not perform well in interference videos (video4 and video5) according to the results in Table 3. In [13], the recognition of fire images was realized by the fusion of Y, Cb, and Cr components in YCbCr color space. There were too many false detection frames in fire videos (video1, video2, and video3) according to the results in Table 3. This shows that using only the color features of flames as a criterion, it is difficult to distinguish the interference of objects similar to the flame color in the background. Compared with the method in [11,13], the proposed Dir-BP method directly performs BP neural network fusion, in which the extracted features include 9dimensional features and are not selected. Since the texture and dynamic features of the flames are considered, this method has a certain degree of improvement in accuracy,     Table 4. However, due to the features with small correlation that may interfere with the recognition results, the number of false detection frames is still large. The proposed RF-BP method with the combination of RF feature selection and BP neural network makes full use of the geometric features, texture features, and dynamic features of flames, which can effectively avoid some feature interferences and perform the best in the evaluation indexes.

Conclusion
In this paper, an effective video fire detection hybrid method based on RF feature selection and BP neural network is proposed. The improved color model and ViBe algorithm are used to segment the suspected flame regions, and the RF importance analysis method is used for the feature combination and selection. Multidimensional features of flames are extracted from the suspected regions, and these extracted features are combined and selected according to the RF feature importance analysis. In addition, a BP neural network model is built for multifeature fusion to determine the fire recognition result. Experimental results show that the features extracted by this RF-BP hybrid approach can effectively avoid the interference caused by the features with small correlation and can well complete the fire detection of experimental videos in different scenes.
The proposed method will be further investigated and have a possible application for fire recognition in video surveillance and detection robots. Considering that the performance of the BP neural network model is easily affected by the sample dataset, the next step is to expand the existing dataset to make the features covered by the training samples with more comprehensive information.

Data Availability
The data supporting this study are from previously reported studies and datasets, which have been cited in the article.