当前位置: 首页 > news >正文

国外幼儿园网站模板网站推广的工作内容

国外幼儿园网站模板,网站推广的工作内容,外贸商城源码,绵阳网站设计制作1、 项目源码和结构(转) https://github.com/mushfiq1998/fire-detection-python-opencv 2、 运行环境 # 安装playsound:用于播放报警声音 pip install playsound # 安装opencv-python:cv2用于图像和视频处理,特别是…

1、 项目源码和结构(转) 

https://github.com/mushfiq1998/fire-detection-python-opencv

2、 运行环境

# 安装playsound:用于播放报警声音

pip install playsound

# 安装opencv-python:cv2用于图像和视频处理,特别是用于检测火灾

pip install opencv-python

3、 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')# To start camera this command is used "0" for laptop inbuilt camera 
# and "1" for USB attahed camera
# vid = cv2.VideoCapture(0) 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 provided with the code.playsound.playsound('fire_alarm.mp3',True) print("Fire alarm end") # to print in consol# Defined function to send mail post fire detection using threading
def send_mail_function(): recipientmail = "add recipients mail" # recipients mailrecipientmail = recipientmail.lower() # To lower case mailtry:server = smtplib.SMTP('smtp.gmail.com', 587)server.ehlo()server.starttls()# Senders mail ID and passwordserver.login("add senders mail", 'add senders password') # recipients mail with mail messageserver.sendmail('add recipients mail', recipientmail, "Warning fire accident has been reported") # to print in consol to whome mail is sentprint("Alert mail sent sucesfully to {}".format(recipientmail))server.close() ## To close serverexcept Exception as e:print(e) # To print error if anywhile(True):Alarm_Status = False# Value in ret is True # To read video frameret, frame = vid.read() # To convert frame into gray colorgray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # to provide frame resolutionfire = fire_cascade.detectMultiScale(frame, 1.2, 5) ## to highlight fire with square for (x,y,w,h) in fire:cv2.rectangle(frame,(x-20,y-20),(x+w+20,y+h+20),(255,0,0),2)roi_gray = gray[y:y+h, x:x+w]roi_color = frame[y:y+h, x:x+w]print("Fire alarm initiated")# To call alarm threadthreading.Thread(target=play_alarm_sound_function).start()  if runOnce == False:print("Mail send initiated")# To call alarm threadthreading.Thread(target=send_mail_function).start() runOnce = Trueif runOnce == True:print("Mail is already sent once")runOnce = Truecv2.imshow('frame', frame)if cv2.waitKey(1) & 0xFF == ord('q'):break
  • 加载训练模型:代码加载预训练的机器学习模型fire_detection_cascade_model.xml(XML 文件),该模型可以检测图像中的火灾。
  • 设置视频源:设置视频输入源,可以是笔记本电脑内置摄像头,也可以是外接USB 摄像头。该代码当前配置为从名为“fire2.mp4”的文件中读取视频。
  • 播放报警声音:定义播放报警声音的函数play_alarm_sound_function(),该函数在后台运行(线程)并播放名为“fire_alarm.mp3”的警报声音文件。
  • 发送电子邮件:send_mail_function()定义了另一个函数来发送电子邮件。它使用 Gmail 的 SMTP 服务器向指定收件人发送有关火灾检测的警告电子邮件。代码中需要提供发件人的电子邮件和密码。

4、结果 

http://www.hkea.cn/news/749026/

相关文章:

  • 有没有做鸭的网站工作室招聘广州网站优化工具
  • 深圳营销外深圳网络营销公司seo和sem的联系
  • 专业的网站制作公司哪家好竞价专员是做什么的
  • 海南省建设厅网站百度seo霸屏软件
  • 淄博张店做网站的公司爱站小工具圣经
  • wordpress w3seo优化自学
  • 临沂手机建站模板微信seo排名优化软件
  • 网站管理员怎么做板块建设艺人百度指数排行榜
  • 如何创建企业网站网络舆情处置的五个步骤
  • 做站长工具网站周口seo公司
  • 泉州自助建站系统地推
  • 美国 做网站免费网站建设哪家好
  • 如何做响应式布局网站seo搜索引擎优化期末及答案
  • 电脑系统优化软件十大排名北京网优化seo公司
  • 宁夏网站建设优化外贸网站优化推广
  • 开发网站开发工程师培训心得简短200字
  • 网站优化工具升上去软文营销代理
  • 北京监理协会培训网站变现流量推广app
  • 邯郸做wap网站最全bt搜索引擎入口
  • 用网站做自我介绍pptsem推广竞价托管
  • 建设网站项目的目的是什么意思营销型网站方案
  • 濮阳网站建设价格南昌seo排名收费
  • jsp做网站案例steam交易链接在哪里看
  • 做网站需要招聘内容范本信息流广告
  • 如何建公众号外贸网站建设优化
  • 怎么把网站横幅做很大东莞营销推广公司
  • 网站运营与管理实训报告松松软文平台
  • 奉化云优化seo手机网站排名优化软件
  • h5响应式集团网站推荐电商平台有哪些?
  • 企业所得税税率三个档次关键词优化快排