Ministry of Higher Education
& Scientific Research
University of KUFA
College of Engineering
Electrical Engineering Department
FIRE DETECTION SYSTEM BASED ON COMPUTER VISION
Project Submitted to the Electrical Engineering Department, University of KUFA in Fulfillment of the Requirements for the Bachelor Degree
HASSAN MOHAMMED JAWAD ALJAZAIRY
ALI HILAL ALQURASHI
ALI H. ALDABBAGH
We certify that a Project (Fire Detection System Based on Computer Vision) has met on ( / /2018) to conduct the final examination of Hassan Mohammed Jawad AlJazairy and Ali Hilal AlQurashi.
Project entitled (“Fire Detection System Based on Computer Vision”) in Electrical Engineering Department/ University of KUFA. The Committee recommends that the project is accepted.
Members of the Project Examination Committee were as follows:
Name of Chairperson:
Name of Examiner
I/We certify that this project (Fire Detection System Based on Computer Vision) was prepared under my supervision at Electrical Engineering Department/ College of Engineering -University of Kufa as a partial fulfillment of the requirements for B.Sc. in Electrical Engineering.
Members of the Project Supervisor Committee were as follows:
Name of Chairperson Supervisor:
Name of Co-Supervisor:
I hereby confirm that:
•This project is my original work.
•Quotations, illustrations and citations have been duly referenced.
•This project has not been submitted previously or concurrently for any other degree at any other institutions.
•Intellectual property from the project and copyright of project are fully-owned by Electrical Engineering Department/ University of Kufa.
•Written permission must be obtained from supervisor before project is published (in the form of written, printed or in electronic form) including books, journals, modules, proceedings, popular writings, seminar papers, manuscripts, posters, reports, lecture notes, learning modules or any other materials.
Table of Contents
Examination Committee 3
Supervisor Committee 4
Declaration Form 5
Chapter one (Introduction)
1.3 Types of sensors
1.4 Working principle
1.5 Purpose of the project
Chapter two (Hardware)
2.1.1 Raspberry Pi3 Model B
2.1.2 Types of Raspberry
2.1.3 History of Raspberry
2.1.5 Logitech C525 720p HD Webcam Camera
2.1.6 Switch Button
2.2 Hardware Wiring
Chapter three (Software)
3.2 System Software
3.3 Computer vision
Chapter Fourth (Results and Conclusion)
4.5 Future Method
There are cases in which fire detection systems fail to detect fire until it gets huge and case lots for damage in the properties especially in outdoor regions.
In the world of technology, there are many sensors for detecting fires and smokes. One of these sensors is (“Addressable smoke detector”) (Show figure below) .
Figure (1-1) Addressable smoke detector.
Fire detection system based on computer vision depends on the movement and color of the fire (Show figure below) .
Figure (1-2) The fire detection algorithm.
1.2 History 
In 1852, Moses Farmer and William F.Schweizer designed two fire alarm boxes, each containing a telegraph key. The first automatic electric fire detection was invented in 1890 by the English scientist Francis Robbins Upton. Ionic detection devices were sold for the first time in the United States in 1951. They were used in important industrial and commercial establishments in the years that followed because of the large size and high cost. In 1955, it developed a home-detecting device that revealed high temperatures.
The US atomic energy commission granted the first license to distribute smoke detectors using radioactive materials in 1963, the first smoke detectors invented in 1970 and announced next year were ionic detectors. (Show figure below).
Figure (1-3) a diagram showing all kinds of sensors.
1.3 Types of sensors: - 
1- Smoke Detector: is used in hallways and public rooms.
2- Heat Detector: is used in kitchens.
3- Optical Heat Smoke Detector: is used in the rooms of electricity, air conditioning and places with machines.
4- Bell and Break Glass: is used in doorways and stairs (Show figure below).
Figure (1-4) Types of Fires & Gas Detection Devices.
1.4 Working principle 
Smoke is detected either by optical detection (photovoltaic) or physical processing (ionization). In some of the reagents are used either one or both (Show figure below).
Figure (1-5) Ionization Smoke Detector.
1.5 Purpose of the project
The purpose of this project is to implement fire detection system works based on computer vision, and has the ability to detect fire in different scenarios, regardless of whether the fire in the dark, closed or open places.
The component used in the project, Raspberry pi3 model B, Webcam, Switch button and as well as alarm and you can watch the webcam and fire detection online by application mobile on (Android and iOS) and Laptop.
2.1.1 Raspberry pi3 model B: -  &  & 
Raspberry:- It is a microcomputer for all ages and capabilities that start in the wonderful world of programming and electronics. There are three main models of Raspberry Pi on the market today – Raspberry Pi 3 Model B+, Raspberry Pi Model A+ and Raspberry Pi Zero, the difference between model A and model B, Model A have contain SD Card 256 GB, one USB port and don't have contain Ethernet port While Model B have contain SD card 256 GB, two USB port or more and Ethernet port .
Here's the complete specs for the Raspberry Pi 3: - (Show figure below).
• Brand Name: Raspberry Pi.
• Series: RASPBERRYPI3-MODB-1GB.
• Item model number: RASPBERRYPI3-MODB-1GB.
• Hardware Platform: Raspberry pi.
• Operating System : Linux.
• Item Weight: 1.6 ounces.
• Product Dimensions: 4.8 x 3 x 1.3 inches.
• Item Dimensions L x W x H: 4.8 x 2.99 x 1.34 inches.
• Processor Brand: Broadcom.
• Processor Count: 4.
• Flash Memory Size: 1.00.
• Hard Drive Rotational Speed: 0.01.
• Optical Drive Type: None.
• Voltage: 5 volts.
• Batteries: 3 9V batteries required.
• SoC: Broadcom BCM2837 (roughly 50% faster than the Pi 2).
• CPU: 1.2 GHZ quad-core ARM Cortex A53 (ARMv8 Instruction Set).
• GPU: Broadcom Video Core IV @ 400 MHz.
• Memory: 1 GB LPDDR2-900 SDRAM.
• USB ports: 4.
• Network: 10/100 MBPS Ethernet, 802.11n Wireless LAN, Bluetooth 4.0.
Figure (2-1) Raspberry pi 3 model B.
2.1.2 Types of Raspberry: - a lot of 15 type (Show figure below). 
1. Raspberry Pi 3 Model B.
2. Raspberry Pi 3 Model B+.
3. Raspberry Pi Zero WH - with soldered headers.
4. Raspberry Pi 1 Model A+.
5. Raspberry Pi 3 Model A+.
6. Raspberry Pi Compute Module 3 Dev Kit.
7. Raspberry Pi Compute Module 3+ 32GB.
8. Raspberry Pi Compute Module 3+ 16GB.
9. Raspberry Pi Compute Module 3+ 8GB.
10. Raspberry Pi Compute Module 3+ Lite.
11. Raspberry Pi Compute Module Lite.
12. Raspberry Pi Zero W.
13. Raspberry Pi 2 Model B.
14. Raspberry Pi Compute Module.
15. Raspberry Pi Zero.
Figure (2-2) Types of Raspberry pi.
2.1.3 History of Raspberry: - 
It designed at the University of Cambridge to help teach computer science to its students, it integrates technology with Linux, programming science, electronics and intelligent control systems at the same time, making this microcomputer achieve incredible success in both the educational and practical fields.
2.1.4 Alarm: alarm buzzer: -
The purpose of the alarm is when the fire is found by the fire detection system it will trigger a warning siren. (Show figure below).
Specification: - 
• Color: White.
• Quantity: 5 pc.
• Alarm Diameter: 29mm / 1.14".
• Alarm Height: 15mm / 0.59”.
• Mounting Holes distance: 40mm / 1.57".
• Wires length: 105mm / 4.13".
• Rated Voltage: 12V.
• Operating Voltage: 3-24V.
• Rated Current (MAX): 20mA.
• Min Sound Output at 10 cm: 95 DB.
• Resonant Frequency: 3100±500.
• Operating Temperature: -20 ~ +80℃.
• Intermittent Sound.
• Mounting Holes.
Figure (2-3) Alarm.
2.1.5 Logitech C525 720p HD Webcam Camera: -
The Purpose of the Webcam to for imaging and transmitting data to the Raspberry pi3 model B. (Show figure below).
Specification: - 
• Resolution: 1280*720.
• Sensor: CMOS.
• Sensor pixels: 8MP.
• Frame rate: 30fps.
• RAM: 2GB.
• Hard disk space: 200MB.
• Zoom MODUS: automatic focusing.
Figure (2-4) Webcam Camera.
2.1.6 Switch Button: -
The Purpose of the switch when an error occurs in detecting the fire or closing the fire detection system. (Show figure below).
Specification: - 
• Power: 3.5.5V.
• Dimension: 24X29X22mm.
• Weight: 9g.
• Package Contents: 1x Rocker Switch module.
Figure (2-5) Switch Button.
2.1.7 Adapter AC to DC: -
The Purpose of the adapter to convert AC voltage to DC voltage to turn on of Raspberry pi3 model B. (Show figure below).
Specification: - 
• Model: HS-050040US.
• Type: Wall Charger.
• Connectivity: USB.
• Power Capacity: 1000mAh.
• Compatible Model: Universal.
• Number of Ports: 1.
• Country/Region of Manufacture: China.
• Compatible Brand: Universal, For Huawei.
Figure (2-6) Adapter AC to DC.
2.2 Hardware Wiring
The Raspberry pi3 model B contains a system that receives and processes images from the camera. If a fire is detected, a warning signal is sent to activate the alarm device indicating a fire. If no fire is detected, the alarm will not be activated. In the case of a fire was discovered by mistake, that is, there was no fire and the alarm was turned on, we can close it through switch.
Figure (2-7) System block diagram.
Figure (2-8) Wiring Connection.
In this chapter we will talk about how to pull the image and enter the Raspberry Pi3 model B, which will be processed and the statement in the event of the discovery of fire or not, and steps to processing them.
3.2 System Software
The system starts by entering a video consisting of a set of images in the processing unit, a raspberry pi3 model B that it processes to detect a fire. If a fire is not detected, take up another image will need to be detected, if a fire is detected, a warning device will be activated to indicate the fire.
If the fire is detected correctly, you will return to take up another image and process it, if there is no fire, there is an error. We can close the alarm with a switch. (Show figure below)
Figure (3-1) Flowchart.
3.3 Computer vision
Computer vision is one of the branches of computer science, designed to build intelligent applications, able to understand the content of images as understood by humans, in the late 1960s, computer vision began in universities that pioneered artificial intelligence. It was supposed to imitate the human visual system, as a starting point for the granting of intelligent behavior robots. 
The library associated with computer vision is OpenCV, a software library for computer vision developed by Intel, officially launched in 1999, the Intel Research Initiative to promote dense CPU (Central Processing Unit) applications, it has C++, Python and Java interfaces and supports Windows, Linux, Mac OS, iOS and Android. 
The process of reading the fire goes through several stages:
1- Take a picture from the Webcam. (Show below figure (a))
2- Convert image (RGB) (Red Green Blue) to HSV (Hue Saturation Value).
When RGB is a by 3 matrixes, triple RGB is a vector three - element array whose values are red, green and blue color components, respectively, convert to 3 row is hue, saturation and value.  (Show below figure (b))
3- Convert image to gray.
The image turns black and white from the grayscale and its intensity is 0 to 255, where 0 is white and 255 is black. (Show below figure (c))
4- Convert image to binary.
The image turns black and white and each pixel has a zero and one so that we can detect the fire. (Show below figure (d))
5- Addition erosion on image.
Erosion of the object boundaries, is the pixel detector specified in the image (either 0 or 1) and is only 1 pixel, where all pixels remain 1, the rest is eroded as 0, all pixels on the border will be discarded and the thickness or size of the foreground or white region decreases in the image.  (Show below figure (e))
6- Addition dilation on image.
Increases the object area, the pixel element in the original image specifies 1, where if its proximity to pixels less than 1 will be taken as 1, it will increase the region of the object or area of the white area.  (Show below figure (f))
7- Addition bounding box on image.
Depending on the results obtained from erosion and dilation, the image becomes a matrix consisting of 0 and 1, The matrix 1 be on them bounding box, and neglect matrix 0.  (Show below figure (g))
Figure (3-2) The steps of Computer vision.
Results and Conclusion
In this chapter, we will present the system results and the percentage of error that may occur and discuss these errors and appropriate solutions as well as the environment appropriate for the installation of this system, and the difference between it and other old systems currently used, and put up ideas for developing detection using more complex algorithms than used in this project.
Fire Detection by Sensor Fire Detection by Webcam
1. High Cost 1. Low Cost
2. Just in closed regions 2. Out Door and any regions
3. Hard to struct, connect and maintain 3. Easy to struct , connect and maintain
4. Covers small area with single sensor relatively 4. Covers large area with one camera relatively
Comparison between our system and the sensors systems: - (Show table below).
Table (4-1) Comparison between our system and sensors system.
These results show the percentage of error caused by the system in the detection of fire, where 300 frames were added to the system, distributed 100 pictures of the dark regions and 100 pictures of the opened regions in the day and 100 pictures of the closed regions in the day. (Show table below).
In Day (Closed Regions)
In Day In Dark
False Positive False Negative False Positive False Negative False Positive False Negative
24% 15% 17% 9% 0% 0%
Table (4-2) The percentage of error caused by the system
In the nature of the case, any system is having the errors, fire detection system is having percentage of the errors, this percentage of the errors is being in the different, it is depended of the regions that installing system in it.
Where it turned out that the percentage of error in dark regions 0% from where the broke out of fire and was not detected as well as the fire did not break out and was discovered.
In the closed regions, where the percentage of error was 9% in case the fire did not broke out and fire was discovered, and 17% in case of fire broke and was not discovered.
In the opened regions, where the percentage of error was 15% in case the fire did not broke out and fire was discovered and 24% in case of fire broke out and was not discovered.
The error that occurs to the system is due to the reflection of the fire light on the around things in it, which the system sees as fire and the camera resolution mainly affects the work of the system as well as affect the distance between fire and camera.
The fire detection system depends on detection of fire color, but the lighter and matchstick don't detection fire because that color of lighter and matchstick are filtered and different from the color of fire.
4.5 Future Method
In the future, we work to addition motion with the color in algorithm, that reduce of the percentage of error with clearly.
We work to addition GSM (Global System for Mobile) to the system, to send a message via mobile phone in case of fire outbreak.
And we work to addition GPS (Global Positioning System) if case we installing the system a lot of places, where when the fire is break out, we can find out where the fire broke out.
 " lumarfireprotection"," [Online]. Available: http://www.lumarfireprotection.com/.
 "Paper" Nicholas True, University of California, San Diego, 9500 Gilman Drive, La Jolla.
" Dplfire " [Online]. Available: http://www.dplfire.co.uk/.
 " Wikipedia " [Online]. Available: https://en.wikipedia.org.
" Raspberrypi " [Online]. Available: https://www.raspberrypi.org/magpi/.
 " Amazon " [Online]. Available: https://www.amazon.com/.
" Thepihut " [Online]. Available: https://thepihut.com/.
" Raspberry.Piaustralia " [Online]. Available: https://raspberry.piaustralia.com.au/.
" 3arrafni " [Online]. Available: https://www.3arrafni.com.
" Banggood " [Online]. Available: https://www.banggood.com/.
 " Compareimports " [Online]. Available: https://www.compareimports.com/.
" Geekbuying " [Online]. Available: https://www.geekbuying.com/.
" Ebay " [Online]. Available: https://www.ebay.com
" Computer Vision " [Book]. Available: Computer Vision: Algorithms and Applications.
" OpenCV " [Online]. Available: https://opencv.org/
" MathWorks " [Online]. Available: https://www.mathworks.com.
" Geeksforeeks " [Online]. Available: https://www.geeksforgeeks.org.
" Learnopencv " [Online]. Available: https://www.learnopencv.com.