Fire Dection12
Fire Dection12
Fire Dection12
Submitted in partial fulfillment of the requirements for the award of the degree of
Master of Computer Applications - Artificial Intelligence & Machine
Learning
Under the department
UIDs: 23MCI10260
Section: 23MAM-3A
BONAFIDE CERTIFICATE
Certified that this project report is the bonafide work of Lalmani Kumar
Signature Signature
S. No Particulars Page No
1 Abstract 7
2 Introduction 9
3 About of Project 12
4 System Analysis 15
5 Objective 18
6 Flow Chart 20
7 Coding 21
8 Output 31
9 Conclusion 33
Page | 3
A B S T R A C T
The Fire Detection with Alarm System is an integrated solution
designed to detect fire incidents in real-time and alert users
through an audible alarm and email notifications. The project
leverages computer vision techniques, specifically using OpenCV,
to identify fire within a video feed from a webcam or external
camera. The system's architecture comprises several key
components:
Page | 5
I N T R O D U C T I O N
Fire safety is a critical concern across residential buildings,
commercial establishments, and industrial facilities. Traditional
fire detection systems like smoke detectors and heat sensors,
while widely used, suffer from drawbacks such as delayed
response times, false alarms, and lack of visual verification. These
limitations can lead to significant damage and loss of life before
appropriate measures are taken.
Page | 6
to individuals nearby, facilitating rapid evacuation and initial
firefighting efforts.
Page | 7
By providing reliable, real-time detection and alert capabilities,
this project significantly contributes to fire safety efforts,
potentially saving lives and reducing property damage. It
embodies the innovative spirit of MCA education, equipping
students to tackle complex issues with creative and effective
solutions.
Page | 8
A B O U T T H E P R O J E C T
The Fire Detection with Alarm System project represents a
significant advancement in fire safety technology, specifically
developed as the final year project for a Master of Computer
Applications (MCA) student. This project aims to address critical
gaps in traditional fire detection systems, such as smoke
detectors and heat sensors, which often suffer from delayed
responses, false alarms, and lack of visual verification
capabilities.
At its core, the system leverages sophisticated computer vision
techniques implemented through Python programming language
and OpenCV (Open Source Computer Vision Library). These
technologies enable the system to analyze live video feeds in
real-time, allowing for the early detection of fire incidents with
high accuracy and efficiency.
Page | 9
Audible Alarm System: Upon detecting a fire, the system
triggers audible alarms to alert individuals in the vicinity.
This immediate notification facilitates swift evacuation and
initiates emergency protocols, enhancing overall safety
measures.
Page | 13
By integrating these technologies and functionalities, the Fire
Detection with Alarm System project aims to significantly improve
fire safety measures across various environments, including
residential buildings, commercial establishments, and industrial
facilities. It exemplifies the practical application of computer
vision and automation in addressing real-world safety
challenges, preparing MCA students to innovate and contribute
effectively in their field of study.
This project not only underscores the importance of leveraging
modern technology for enhancing safety and security but also
highlights the educational value of applying theoretical
knowledge to develop practical solutions. Through
comprehensive detection and alert mechanisms, the Fire
Detection with Alarm System project aims to mitigate risks,
protect lives, and reduce property damage associated with fire
incidents.
Page | 14
S Y S T E M A N A L Y S I S
System analysis for the Fire Detection with Alarm System project
involves evaluating its components, functionality, and
effectiveness in meeting specified requirements. This analysis
typically includes:
Page | 15
lighting environments, fire sizes, and distances from the
camera. Performance metrics may include detection
accuracy, response time from detection to alert triggering,
and system stability.
5. Usability and User Experience: Evaluating the ease of use
and effectiveness of the graphical user interface (GUI)
developed with Tkinter. This includes user interaction with
controls for starting/stopping detection, viewing video
feeds, and receiving alerts.
6. Security and Reliability: Assessing the system's reliability in
continuous operation, robustness against false alarms, and
security measures implemented for email notifications (e.g.,
authentication and secure transmission protocols).
7. Integration and Deployment: Analyzing the integration of
different system components (Python scripts, OpenCV
modules, Tkinter UI) and deployment considerations on
various platforms (Windows, Linux). This includes packaging
the application for ease of installation and deployment.
8. Maintenance and Scalability: Considering the ease of
maintenance, future updates, and scalability of the system
to accommodate additional features or support for larger
environments (e.g., multiple cameras or networked systems).
Page | 16
providing a comprehensive evaluation of its design,
functionality, performance, and usability in enhancing fire
safety measures through advanced technology integration.
Page | 14
O B J E C T I V E
The objective of the Fire Detection System project is to develop a
robust and efficient system that utilizes computer vision and
machine learning technologies to detect fire incidents in real-
time through video surveillance. The primary goals include:
Page | 15
7. Application of Academic Knowledge: Applying theoretical
concepts learned during the MCA program to solve practical,
real-world challenges in the domain of safety and security.
Page | 19
Page | 17
C O D I N G
class Resize(Frame):
def init (self, master):
Frame. init (self, master)
def button_click(self):
self.stop_flag = False # Reset the stop flag
fire_cascade =
cv2.CascadeClassifier('C:/Fire_detection_with_alarm/fire_detectio
n_cascade_model.xml') # To access xml file which
includes positive and negative images of fire. (Trained
images)
# Email content
subject = "Urgent: Fire Detected!"
body = f"""
Dear Team,
Location: {location}
Date & Time: {detection_time}
Severity: {severity}
Immediate Actions Required: {immediate_actions}
Stay safe,
[Prem Kumar Team]
"""
Page | 26
try:
server = smtplib.SMTP('smtp.gmail.com',
587) server.ehlo()
server.starttls()
server.login("[email protected]",
'aaaa bbbb cccc dddd') # Sender's email login id and
password
server.sendmail(msg['From'], recipientmails,
msg.as_string()) # Correct usage of sendmail()
print("Alert mail sent successfully to
{}".format(", ".join(recipientmails))) # Confirmation
message server.close() # Close the server
except Exception as e:
print(e) # Print any errors encountered
def show_frame():
if self.stop_flag:
vid.release()
cv2.destroyAllWindows()
return
if not self.runOnce:
Page | 24
print("Mail send initiated")
threading.Thread(target=send_mail_function).s
tart() # To call alarm thread
self.runOnce = True
self.video_label.imgtk = imgtk
self.video_label.configure(image=imgtk)
self.video_label.after(10, show_frame)
show_frame()
def stop_detection(self):
self.stop_flag = True
def button_click2(self):
print("Exiting the application")
app.quit() # This will exit the application
e = Resize(app)
e.pack(fill=BOTH, expand=YES)
app.mainloop()
server.login("[email protected]",
'aaaa bbbb cccc dddd') # Sender's email login id and
password
Page | 25
server.sendmail(msg['From'],
recipientmails, msg.as_string()) # Correct usage of
sendmail()
print("Alert mail sent successfully to
{}".format(", ".join(recipientmails))) # Confirmation
message server.close() # Close the server
except Exception as e:
print(e) # Print any errors encountered
def show_frame():
if self.stop_flag:
vid.release()
cv2.destroyAllWindows()
return
if not self.runOnce:
print("Mail send initiated")
threading.Thread(target=send_mail_function).s
tart() # To call alarm thread
self.runOnce = True
Page | 26
cv2image = cv2.cvtColor(frame, cv2.COLOR_BGR2RGBA) #
Convert the image to RGBA
img = Image.fromarray(cv2image) # Convert image to
PIL format
imgtk = ImageTk.PhotoImage(image=img) # Convert
image to ImageTk format
self.video_label.imgtk = imgtk
self.video_label.configure(image=imgtk)
self.video_label.after(10, show_frame)
show_frame()
def stop_detection(self):
self.stop_flag = True
def button_click2(self):
print("Exiting the application")
app.quit() # This will exit the application
e = Resize(app)
e.pack(fill=BOTH, expand=YES)
app.mainloop()
Page | 27
O U T P U T
Window Screen tkinter GUI:
Page | 28
T e r m i n a l O u p u t :
E m a i l N o t i f i c a t i o n :
Page | 29
C O N C L U S I O N
Page | 30
results, making the system accessible to individuals with
varying levels of technical expertise.
4. Enhanced Safety and Reliability: The system's ability to
operate with minimal latency and its robustness in detecting
actual fire events while minimizing false alarms contribute
significantly to enhancing overall safety. Regular updates
and maintenance of the classifier model can further improve
the system's accuracy and reliability over time.
5. Scalability and Modularity: The modular design of the
system allows for easy maintenance and scalability. The
system can be adapted to different video resolutions, camera
types, and environments, making it a versatile solution for
various fire detection applications.
6. Educational Value: For final year MCA students, this project
provides an excellent opportunity to apply theoretical
knowledge in a practical context. It encompasses various
aspects of software development, including real-time data
processing, machine learning, user interface design, and
multithreading, offering a comprehensive learning
experience.
Page | 34
to create a cohesive and effective solution. The successful
implementation of this project highlights the potential for further
innovations in the field of automated safety systems.
Page | 35