Skip to content

simon-zerisenay/FireGuardVision

Repository files navigation

Fire Detection using YOLOv8

This Python project utilizes the YOLOv8 object detection model to detect fires in real-time using either a webcam or a video file as input. When a fire is detected, an alarm sound is triggered to alert the user. The alarm has a cooldown period, during which it will not be triggered again if additional fires are detected. This project assumes that you have already trained the YOLOv8 model with around 50 images, each repeated 1500 times, specifically for fire detection.

Dependencies

Before running the project, make sure you have the following dependencies installed:

  • OpenCV: Used for image processing and video capture.
  • Pygame: Used to play the alarm sound.
  • cvzone: Used for drawing text and rectangles on the image.
  • Ultralytics: Used to load the YOLOv8 model and perform real-time object detection.

Install the dependencies using the following command:

pip install -r requirements.txt
pip install opencv-python pygame cvzone ultralytics

Getting Started

  1. Clone or download the YOLOv8 model repository and place the trained fire.pt file inside the project directory.
  2. Replace 'alarm_sound.wav' with the path to your desired alarm sound file. Make sure the file is in WAV format.
  3. If you want to run the project using a webcam, set cap = cv2.VideoCapture(0). For a video file, set cap = cv2.VideoCapture('fire4.mp4').

Usage

  1. Run the Python script containing the provided code to start the fire detection system.
  2. The program will use the selected video source (webcam or video file) to capture frames.
  3. When a fire is detected with a confidence level greater than 50%, a rectangle will be drawn around the detected fire, and the label along with the confidence percentage will be displayed on the screen.
  4. The alarm sound will be played when a fire is detected, provided the alarm is not already triggered.
  5. The alarm will be in a cooldown state for a defined duration (default: 10 seconds) after being triggered once. During this time, the alarm will not be triggered even if more fires are detected.
  6. After the cooldown duration has passed, the alarm will be ready to trigger again if another fire is detected.

Note

  • The provided code assumes that you have trained the YOLOv8 model with a dataset consisting of approximately 50 fire images, each repeated 1500 times. Make sure the model is well-trained for accurate fire detection.
  • The confidence threshold for fire detection is set to 50%. You can adjust this value based on your requirements in the code: if confidence > 50.
  • The cooldown duration is set to 10 seconds by default. You can modify this value by changing the cooldown_duration variable in the code.
  • The program will continue to run until you manually stop it. Press 'Ctrl + C' in the terminal or close the image window to terminate the execution.

Credits

Disclaimer

This fire detection system is intended for educational and experimental purposes only. It may not be suitable for critical or high-stakes applications. Always use professional and reliable fire detection systems for real-world scenarios to ensure the safety of life and property. The author is not responsible for any misuse or consequences of using this project.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages