Microsoft Word - CET--006.docx CHEMICAL ENGINEERING TRANSACTIONS VOL. 59, 2017 A publication of The Italian Association of Chemical Engineering Online at www.aidic.it/cet Guest Editors: Zhuo Yang, Junjie Ba, Jing Pan Copyright © 2017, AIDIC Servizi S.r.l. ISBN 978-88-95608- 49-5; ISSN 2283-9216 Research on Fire Image Processing System Based on Chemical Sensor Fuguang Yao Chongqing University of education, Chongqing 400065, China yaofuguang@cque.edu.cn Aiming at the gas sensor monitoring and image display system in the fire, a gas detection system based on porphyrin chemical sensor was developed. According to the principle that the reaction between porphyrin and organic gas will produce color change, CCD is used to collect the image of porphyrin chemical sensor array and the target gas before and after the chemical reaction. Image processing technology is used to obtain the characteristic information of the target gas, and a suitable pattern recognition algorithm is used to detect the target gas. The system was used to detect nine kinds of VOCs and ammonia. The results show that the method is effective in the identification of VOCs and the quantitative detection of ammonia gas. The upper computer software system and pattern recognition method of gas detection system are studied. The signal acquisition function is completed, and the signal processing and analysis system is realized. The system can detect nine kinds of common VOCs and perform quantitative image processing. 1. Introduction Chemical sensor array (CSA) technology can be used to identify multiple gas components and to differentiate different analyte concentrations (Csiszar, et al., 2014; Aleixandre et al., 2016; Romain et al., 2016; Spinelle et al., 2016). So far, CSA's response has been monitored by using a personal computer-driven flatbed scanner (Colombelli, et al., 2017). This method is suitable for use in laboratory environments and is not suitable for use in environmental monitoring in this area. On the basis of CSA technology, a fast, cheap and portable handheld device was developed for the detection of toxic industrial compounds (TICS). In the presence of three interfering gases, the device successfully distinguished four low concentrations of TICs in less than two minutes (Dimitropoulos, et al., 2015). Adriano (2013) presents a chemical sensor array. It uses the optical properties of the chemical layer on the array to detect sensitive volatile compounds in the process of fish deterioration. The system builds a very simple platform based on computer screens and web cameras, which use metalloporphyrin arrays to distinguish the number of days of storage and the degree of corruption of thawed fish. By using VC.net platform, a software system based on porphyrin chemical sensor gas detection system is developed. According to the principle that the reaction between porphyrin and organic gas will produce color change, CCD is used to collect the image of porphyrin chemical sensor array and the target gas before and after the chemical reaction. Image processing technology is used to obtain the characteristic information of the target gas, and a suitable pattern recognition algorithm is used to detect the target gas. 2. The overall design of gas detection system software 2.1 The principle of detection Porphyrin is a kind of macrocyclic compound containing four pyrrole molecules, and its precursor is porphine. When the pyrrole proton is replaced by metal ions, it is metalloporphyrin. Metalloporphyrins are used to identify gases by the bond between metal ions and gas molecules. When the target gas and metal porphyrin contact, its absorption spectrum will change, showing a change in color (Moraes, et al., 2014). The bonding degree and tension of different gas molecules and metal ions are different. The change of the color of metalloporphyrin is also different after the reaction (Moragues, et al., 2014). The combination of the color DOI: 10.3303/CET1759104 Please cite this article as: Fuguang Yao, 2017, Research on fire image processing system based on chemical sensor, Chemical Engineering Transactions, 59, 619-624 DOI:10.3303/CET1759104 619 changes of different metalloporphyrins can represent the characteristic information of the target gas, which is called the "fingerprint" information of the target gas. The metal porphyrin chemical sensing array is a metal porphyrin complex as a gas - sensitive unit (Marco, et al., 2014). The gas is identified by detecting the combination of the color change information after the contact between the sensitive unit and the target gas. For example, the metal porphyrin sensor array contains 6x6=36 sensitive cells. Among them, each sensitive unit represents a metalloporphyrin (Toulouse, et al., 2016). After the reaction with the target gas, each porphyrin will show different colors. The combination of these different color changes as well as color changes can uniquely characterize the characteristic information of the target gas. Moreover, the larger the chemical sensor array, the more detailed the information, the higher the recognition accuracy (Wang, et al., 2016). Through the CCD, the gas detection system is used to collect images of the porphyrin chemical sensor array chip before and after the chemical reaction of the target gas (Yuan, et al., 2015). The color change of each metal porphyrin point in the image of the sensor array is obtained by image processing technique. The combination of the color change information constitutes the response characteristic of the gas (Zetola, et al., 2016). 2.2 The structure of detection system Based on the chemical reaction kinetics requirements for the detection of the target gas, the detection system must achieve target gas acquisition, flow control and exhaust gas treatment under fixed kinetic conditions, and be able to monitor the temperature and humidity during the reaction in real time. Since the system identifies the gas by detecting the color change produced by the reaction of the sensitive material in the chemical sensor array with the target gas, the system must have the function of image acquisition and analysis. In order to avoid the influence of ambient light, the whole reaction chamber should be sealed. Based on the above requirements, the design of the detection system is shown in Figure 1. It mainly includes air pump, reaction chamber (built-in porphyrin chemical sensor array chip), temperature sensor, humidity sensor, flow sensor, image sensor, PC and power supply. The air pump is used to collect the response of target gas and sensor array. The exhaust gas after reaction is discharged to the waste gas treatment device to avoid pollution to the atmosphere. The reaction chamber is designed into a sealed transparent container, which is used for placing the porphyrin sensor array chip. The reaction chamber comprises an inlet port and an outlet port. The target gas is pumped into the reaction chamber from the air inlet, and then reacted with the sensor array chip, and then the unreacted exhaust gas is discharged into the waste gas treatment device from the air outlet. The temperature sensors, humidity sensors and flow sensors placed in the air chamber are used to monitor the temperature, humidity and flow rate during the reaction. The CCD is connected to the PC via the USB interface for collecting sensor array images. PC is responsible for the control and signal acquisition, processing, analysis and data management of the whole system through the software system. target gas target gas a certain concentra tion of the target gas pump flow sensor porphyrin sensor array PC temperature sensor humidity sensor gas treatment Figure 1: Schematic diagram of porphyrin sensor detection system The working flow of gas detection is shown in Figure 1. At the beginning of the test, the LED and the camera are opened by the PC software system to control the image signal of the porphyrin sensor array before the CCD reaction. Then, the air pump is opened, and the measured gas is pumped into the reaction chamber and the chemical sensor array chip. After waiting for a certain reaction time, the image signal of the porphyrin chemical sensor array is controlled by CCD after the reaction. At the same time, the collected sensor array 620 image signal before and after the reaction is saved to the PC machine. After image preprocessing, grid partition, array sensitive point identification and feature extraction, the pattern recognition method is used to recognize the characteristic signals, and the results are given. In the whole process of image acquisition, the software system detects the humidity by reading the humidity sensor data, and detects the temperature by reading the temperature sensor data. The flow rate of the gas in the reaction chamber is detected by reading the flow sensor data. start monitor open camera open lighting collect the image before the reaction open the air pump introducing the gas the chip reacts with the gas collect the image after the reaction image processing real-time display flow rate, temperature and humidity exhaust gas, turn off air pump, lighting and camera display the standard template feature recognition output monitoring results gas fingerprint database experiment al data flow control response characteristics data storage Figure 2: Schematic figure of gas detection system 3. Image acquisition of porphyrin sensor array 3.1 The technical basis of multi - parameter acquisition based on multithread CserialPort class In the hardware communication module, on the one hand, it is necessary to realize the image acquisition of porphyrin sensor array; on the other hand, it is necessary to realize parameter detection and display of the temperature, humidity and flow rate. The traditional single task serial mode cannot meet the needs of both efficiency and reliability. It needs to be solved by concurrent multithreading. Processes and threads are the basic unit of the program, and the system uses the basic unit to achieve the system on the application of concurrency. The difference between a process and a thread is that, in short, a program has at least one process and a process has at least one thread. Thread division scale is less than the process, and the multithreaded program has high concurrency. In addition, the process has a separate memory unit in the implementation process, and multiple threads share memory, which greatly improves the efficiency of the program. When multiple threads want to access some resources at the same time, it is unavoidable to get conflicting access to shared resources. In order to solve the problem of resource conflict, the concept of thread synchronization is introduced. The Win32 API 621 provides a variety of synchronization control objects to solve shared resource access conflicts, such as the use of semaphores, the use of events, the use of critical areas, and the use of mutex objects. 3.2 Implementation of multi parameter and multi thread sampling The third-party serial communication class is used for serial programming. It can improve programming efficiency and enhance the controllability of the program. Compared with the Window API programming, it is simpler. Among them, the most widely used third-party serial communication class is CSerialPort. Based on multithreading, it is a wrapper class for Win32 APIs. The Win32 API class for handling the serial port is encapsulated. The serial port can be easily manipulated by using it, and it is easy to achieve multi-threaded serial communication. The program can run well under the Windows 98 / NT / 2000 / XP operating system. The serial communication process is shown in Figure 3. select the serial port start serial port initialization the main thread of the application image acquisition and display close the serial port end create a serial port monitoring thread read temperature, humidity and flow data write serial port control LED and flow rate process turn off the serial port monitoring thread Figure 3: Diagram of serial communication 4. Image processing module After the image acquisition is completed, it enters the image processing process. In the detection system, the system does not identify the chemical sensor array image itself, but to identify the color change information in the sensor array before and after the reaction of porphyrin sensitive points and gas. In the image signal processing module, the image processing technology is used to extract the color information of the chemical sensor array in the image before and after the reaction with the target gas. By subtracting, the color change caused by the reaction between the sensor and the gas is obtained, and the color change information is the response characteristic of the sensor to the gas. 4.1 Image preprocessing The main purpose of image preprocessing is to improve image quality, to enhance or weaken some of the information in the image, and to prepare for subsequent processing. In the pretreatment, the sensor chip image collected by the camera is geometric correction, color space conversion, image filtering and other processing. The geometric correction of the original image is that the porphyrin lattice is arranged in the image by image rotation and shearing. Color space conversion is to transform the RGB space image into gray space, and improve the processing speed. Image filtering is to filter the gray image to remove the noise in the image. In the process of shooting the sensor array chip image, due to operational errors, the location of the chip placement may be offset, such as tilt, resulting in uneven array of lattice. The image rotation can correct the 622 physical position of the image, so that the sensitive points in the array are arranged in the image in a regular way, which is convenient for subsequent adaptive mesh generation. The rotation of an image is the rotation of an image around its center in an anticlockwise or clockwise direction. The transformation formula of the rotation operation is derived as follows. As shown in Figure 4, the point (x0, y0) is transformed into a coordinate (x1, y1). Figure 4: The rotation coordinate space 4.2 Identification of sensitive points of porphyrin arrays In the porphyrin sensor chip, the porphyrin with effective information is arranged in the image with an array of m × n. The system locates each porphyrin point by meshing, and then uses the image segmentation algorithm to separate the porphyrin from the background of the image. Through the meshing and porphyrin fractionation, the porphyrin in the porphyrin chip sensor can be completely identified and located. The flow chart is as follows. porphyrin sensor array chip image image pre- segmenta tion adaptive meshing regional porphyrin dot location recognition array sensitive point color information extraction standard template visualization display Figure 5: Diagram of image processing 5. Conclusions Based on the rapid cross identification of gas by porphyrin chemical sensing array chip, a new gas detection system was constructed. The system identifies the gas by converting the characteristic information of the gas into the image information of the porphyrin sensor. A perfect software system was developed for the gas detection system, which integrates signal acquisition, signal processing and data management. The contents of the following parts are completed: (1) the function of signal acquisition is realized. It includes image signal acquisition and real-time acquisition and display of temperature, humidity and flow in the reaction chamber. The acquisition of image signal can be divided into two modes: manual acquisition and automatic acquisition; (2) the function of signal processing and analysis is realized. The signal processing is divided into two modes: single image processing and sequence image processing. The single image processing mode consisted of open, simultaneously or separately rotating, cropping, automatic processing, the result printing and so on. (3) aiming at the characteristics of porphyrin chemical sensing array chip, the image filtering, gray scale, meshing, feature information extraction and visualization of sensor array chip are realized. 623 Reference Aleixandre M., Horrillo C., Gerboles M., Spinelle L., Bonavitacola F., 2016, Comparison of tin dioxide ozone sensor operated in on/off switching temperature cycles and at constant temperature, Chemical Engineering Transactions, 54, 49-54, DOI: 10.3303/CET1654009 Colombelli A., Manera M.G., Borovkov V., Giancane G., Valli L., Rella, R., 2017, Enhanced sensing properties of cobalt bis-porphyrin derivative thin films by a magneto-plasmonic-opto-chemical sensor. Sensors and Actuators B: Chemical, 246, 1039-1048. Csiszar I., Schroeder W., Giglio L., Ellicott E., Vadrevu K.P., Justice C.O., Wind, B., 2014, Active fires from the Suomi NPP Visible Infrared Imaging Radiometer Suite: Product status and first evaluation results. Journal of Geophysical Research: Atmospheres, 119(2), 803-816. Dimitropoulos K., Barmpoutis P., Grammalidis N., 2015, Spatio-temporal flame modeling and dynamic texture analysis for automatic video-based fire detection. IEEE transactions on circuits and systems for video technology, 25(2), 339-351. Marco S., Gutiérrez-Gálvez A., Lansner A., Martinez D., Rospars J.P., Beccherelli R., Persaud K., 2014, A biomimetic approach to machine olfaction, featuring a very large-scale chemical sensor array and embedded neuro-bio-inspired computation. Microsystem technologies, 20(4-5), 729-742. Moraes E.P., Da Silva N.S., De Morais C.D.L., Neves L.S.D., Lima K.M.D., 2014, Low-Cost Method for Quantifying Sodium in Coconut Water and Seawater for the Undergraduate Analytical Chemistry Laboratory: Flame Test, a Mobile Phone Camera, and Image Processing. Journal of Chemical Education, 91(11), 1958-1960. Moragues M.E., Montes-Robles R., Ros-Lis J.V., Alcañíz M., Ibañez J., Pardo T., Martínez-Máñez R., 2014, An optoelectronic sensing device for CO detection in air based on a binuclear rhodium complex. Sensors and Actuators B: Chemical, 191, 257-263. Romain A.C., Molitor N., Adam G., Bietlot E., Collard C., 2016, Comparison “low cost chemical sensors – analytical instruments” for odour monitoring in municipal waste plants, Chemical Engineering Transactions, 54, 211-216, DOI: 10.3303/CET1654036 Spinelle L., Gerboles M., Aleixandre M., Bonavitacola F., 2016, Evaluation of metal oxides sensors for the monitoring of o3 in ambient air at ppb level, Chemical Engineering Transactions, 54, 319-324, DOI: 10.3303/CET1654054 Toulouse T., Rossi L., Celik T., Akhloufi M., 2016, Automatic fire pixel detection using image processing: a comparative analysis of rule-based and machine learning-based methods. Signal, Image and Video Processing, 10(4), 647-654. Wang T., Yasukochi W., Korposh S., James S.W., Tatam R.P., Lee S.W., 2016, A long period grating optical fiber sensor with nano-assembled porphyrin layers for detecting ammonia gas. Sensors and Actuators B: Chemical, 228, 573-580. Yuan C., Zhang Y., Liu, Z., 2015, A survey on technologies for automatic forest fire monitoring, detection, and fighting using unmanned aerial vehicles and remote sensing techniques. Canadian journal of forest research, 45(7), 783-792. Zetola N.M., Modongo C., Matlhagela K., Sepako E., Matsiri O., Tamuhla T., Di Natale, C., 2016, Identification of a Large Pool of Microorganisms with an Array of Porphyrin Based Gas Sensors. Sensors, 16(4), 466. 624