Skip to content

Commit

Permalink
Clean up readme
Browse files Browse the repository at this point in the history
  • Loading branch information
gunarakulangunaretnam committed Feb 17, 2022
1 parent 1dd49f7 commit 3394e5d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 14 deletions.
24 changes: 22 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# Fire-Detection-System-in-python
This system can detect fires on video frames. I have used HSV algorithm to track fires in images and video. This system has three main features such as Detect fire in video frame, Turn on alarm sound, and then, It will send emails to fire engine services.
# Fire Detection System in Python using HSV Color


## Introduction

The fire detection system is a security system. The primary function of this system is to detect fires and turn on alarm to warn fire accidents. This system is written in python with OpenCV computer vision module. It is using the HSV color algorithm to detect fires.


## Technologies
- Python
- OpenCV
- SMTPLIB
- HSV Color

![](github-readme-content/image-1.jpg)


#### Execution

```
python fire-detector.py
```
File renamed without changes.
24 changes: 12 additions & 12 deletions fire_detector.py → fire-detector.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import cv2
import numpy as np
import smtplib
Expand All @@ -11,7 +11,7 @@

def play_alarm_sound_function():
while True:
playsound.playsound('Alarm Sound.mp3',True)
playsound.playsound('alarm-sound.mp3',True)

def send_mail_function():

Expand All @@ -31,35 +31,35 @@ def send_mail_function():


video = cv2.VideoCapture("video_file") # If you want to use webcam use Index like 0,1.

while True:
(grabbed, frame) = video.read()
if not grabbed:
break

frame = cv2.resize(frame, (960, 540))
frame = cv2.resize(frame, (960, 540))

blur = cv2.GaussianBlur(frame, (21, 21), 0)
hsv = cv2.cvtColor(blur, cv2.COLOR_BGR2HSV)

lower = [18, 50, 50]
upper = [35, 255, 255]
lower = np.array(lower, dtype="uint8")
upper = np.array(upper, dtype="uint8")

mask = cv2.inRange(hsv, lower, upper)

output = cv2.bitwise_and(frame, hsv, mask=mask)

no_red = cv2.countNonZero(mask)

if int(no_red) > 15000:
Fire_Reported = Fire_Reported + 1

cv2.imshow("output", output)

if Fire_Reported >= 1:

if Alarm_Status == False:
threading.Thread(target=play_alarm_sound_function).start()
Alarm_Status = True
Expand All @@ -71,6 +71,6 @@ def send_mail_function():

if cv2.waitKey(1) & 0xFF == ord('q'):
break

cv2.destroyAllWindows()
video.release()
video.release()
Binary file added github-readme-content/image-1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 3394e5d

Please sign in to comment.