Giter VIP home page Giter VIP logo

fatihilhan42 / fire-detection-using-haar-cascade-classifier-in-opencv-main Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 11 KB

It is the Fire detection project with Arduino of our Computer Vision work with Opencv. In this project, when fire detection was detected using Opencv intelligence libraries, the LED on the Arduino burned, the detection text was printed on the buzzer and LCD screen. I tried to explain the details of the project step by step below.

C++ 69.46% Python 30.54%
ardunio-uno computer-vision fire-detection image-processing opencv-python python3 harrcascade

fire-detection-using-haar-cascade-classifier-in-opencv-main's Introduction

Fire-Detection-using-HAAR-Cascade-Classifier-in-OpenCV

It is the Fire detection project with Arduino of our Computer Vision work with Opencv. In this project, when fire detection was detected using Opencv intelligence libraries, the LED on the Arduino burned, the detection text was printed on the buzzer and LCD screen. I tried to explain the details of the project step by step below.

Setup

  1. OpenCV for Windows - 3.4.9
  2. OpenCV Python Library - 4.4.0
  3. Numpy - 1.18.1
  4. Serial Library in Python - 3.4

Training of Classifier

  1. Dataset for training was generated by capturing images from the webcam of the laptop and saving them using capture_images.py
  2. opencv_annotation.exe was used to mark out the regions containing fire in positive training images.
  3. positives.vec file was generated using opencv_createsamples using appropriate width and height parameters.
  4. Classifier was trained using opencv_traincascade and cascade.xml file was produced as an output.

Download Library

First, we will download the libraries we will use.

import numpy as np
import cv2
import serial
import time

Code block that we connect to Arduino

ser1 = serial.Serial('COM5',9600)

Arduino Code Block

#include <SoftwareSerial.h>
#include<string.h>
SoftwareSerial gsm_module(9, 10);   //initialise serial ports for communication with GSM module

#include <LiquidCrystal.h>
const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);   //initialise LCD display

int pump=13;   //pin for contrlling water pump
int LED=12;    //pin for controlling LEDs
int buz=11;    //pin for controlling buzzer
int d=0;

int ledState = LOW;    //initial LED state
int pumpState = LOW;   //initial water pump state
unsigned long previousMillis = 0; 
const long interval = 200;  
unsigned long previousMillis2 = 0; 
const long interval2 = 30000;  

void setup() {
    gsm_module.begin(9600);    //start communication with GSM
    lcd.begin(16, 2);          //start communication with LCD
    pinMode(LED, OUTPUT);      //initialise LED pin as OUTPUT
    pinMode(buz, OUTPUT);      //initialise buzzer pin as OUTPUT
    pinMode(pump, OUTPUT);     //initialise pump pin as OUTPUT
    lcd.print("HEllO");
    Serial.begin(9600);        //start serial communication with PC
}

void loop() {
    d=Serial.read();        //read output from PC
   
    if(d == 'p') {         //if fire detected
        lcd.clear();
        lcd.print(" Fire Detected ");    //diaplay message on LCD
        SendMessage();     //send message to owners number
        Blink();           //activate water pump, LEDs and buzzer
    }
  
    if(d == 's' ) {        //if no fire detected
        lcd.clear();
        lcd.print("Capturing Video...");    
        digitalWrite(LED, LOW); 
        digitalWrite(buz, LOW); 
        unsigned long currentMillis2 = millis();
        if((unsigned long)(currentMillis2 - previousMillis2) >= interval2) {   
            digitalWrite(pump, LOW);
            previousMillis2 = currentMillis2;
        }
        delay(5);
    }
}

void SendMessage() {        //Functon for sending message
    gsm_module.println("AT+CMGF=1");    //Sets the GSM Module in Text Mode
    delay(1000);  // Delay of 1000 milli seconds or 1 second
    gsm_module.println("AT+CMGS=\"+919988872138\"\r"); //Phone number on which alert is sent
    delay(1000);
    gsm_module.println("Fire detected at LAT: 30.742308, LONG: 76.738843");    //SMS alert
    delay(100);
    gsm_module.println((char)26);    //ASCII code of CTRL+Z
    delay(1000);
}

void Blink() {      //Function for controlling LEDs, pump, buzzer
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis >= interval) {
        previousMillis = currentMillis;
        ledState = HIGH;
        digitalWrite(LED, HIGH);
        digitalWrite(buz, HIGH);
        digitalWrite(pump, HIGH);
        delay(5000);
        
    }
}

image

fire-detection-using-haar-cascade-classifier-in-opencv-main's People

Contributors

fatihilhan24 avatar fatihilhan42 avatar

Watchers

 avatar

Forkers

sonudileep

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.