本文来源公众号“OpenCV与AI深度学习”,仅用于学术分享,侵权删,干货满满。
原文链接:使用Python和OpenCV实现火焰检测(附源码)
完整项目源码下载:
https://github.com/mushfiq1998/fire-detection-python-opencv?source=post_page-----e55c8fc6fa54--------------------------------
图片:
项目结构:
fireDetection.py
import cv2 # Library for openCV
import threading # Library for threading -- which allows code to run in backend
import playsound # Library for alarm sound
import smtplib # Library for email sending
# To access xml file which includes positive and negative images of fire.
# (Trained images) File is also provided with the code.
fire_cascade = cv2.CascadeClassifier('fire_detection_cascade_model.xml')
vid = cv2.VideoCapture("videos\\fire2.mp4")
runOnce = False # created boolean
# defined function to play alarm post fire detection using threading
def play_alarm_sound_function():
# to play alarm # mp3 audio file is also pr