• 大小: 9.62MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-11-17
  • 语言: 其他
  • 标签: 烟雾识别  

资源简介

前景提取、图像缩放、烟雾识别、图像处理、运动检测、目标圈定

资源截图

代码片段和文件信息

#include
#include 
#include 

#include “opencv2/core.hpp“
#include “opencv2/imgproc/imgproc.hpp“
#include   
#include 
#include  
#include  
#include  
#include 
using namespace std;
using namespace cv;
#define NUM 10
int number = 0;//计数,连续五张判断成功就认为有烟火
int attr[3] = { -1-1-1 };//图片属性,分别是上 左 右 最边上的疑似像素位置
int px_num = 0;//疑似像素个数
int attr1[3] = { -1-1-1 };//用于跟上一张图片比较属性的变化
int px_num1 = 0;
Mat frame1;
Ptr pMOG2;

int Check_Fire(Mat &frame);
int Check_Smoke(Mat &frame);
Mat dll(Mat inputImg Mat foreImg);
void pic_attr(Mat foreImg);

int main(void)
{
int i = -1;
String imagename;
SYSTEMTIME sys;
char buf[30] = { 0 };

Mat  frame;
//Mat frt;
//VideoWriter write;
VideoCapture capture(“C:/Users/Administrator/Desktop/WORK/CplusImplement/CplusImplement/冒烟003.MP4“); //打开视频文件

if (!capture.isOpened()) //检测是否正常打开:成功打开时,isOpened返回ture
{
cout << “打开失败“ << endl;
system(“pause“);
return -1;
}
cout << “打开摄像头成功“ << endl;
//double rate = capture.get(CV_CAP_PROP_FPS); //获取帧率 视频长度
//int delay = 1000 / rate;
pMOG2 = createBackgroundSubtractorMOG2();

capture >> frame;
//capture >> frame;
//int w = static_cast(capture.get(CV_CAP_PROP_frame_WIDTH));
//int h = static_cast(capture.get(CV_CAP_PROP_frame_HEIGHT));
//Size S(w h);
//打开视频文件,准备写入  
//write.open(arr2 -1 rate S true);
cout << “进入循环“ << endl;

while (1)
{
if (frame.empty())
{
cout << “Open fail\n“;
system(“pause“);
return -1;
}
//pMOG2->apply(frame frt);
//imshow(“Co“ frt);

i = Check_Smoke(frame);
imshow(“Control“ frame1);
//write.write(frame);
if (i == 1)
{
imagename = “../file/“;
GetLocalTime(&sys);
sprintf_s(buf 30 “h%4d%02d%02d%02d%02d%02d%03d_%04d“ sys.wYear sys.wMonth sys.wDay sys.wHour sys.wMinute sys.wSecond sys.wMilliseconds i);
imagename = imagename + buf + “.bmp“;
cout << imagename << endl;
imwrite(imagename frame);
i = -1;
}
if (waitKey(35) >= 0)
break;
capture >> frame;
}
capture.release();//释放对象
  //write.release();
if (i)
return 1;//有火
return 0;//没火
}


//火焰图形二值化
int Check_Fire(Mat &frame)
{
bool num = false; //是否有可疑点
bool value = false; //是否进行形态学处理以及边框勾选
Mat frt; //优化,先进行前景动态提取,背景直接过滤
Mat fireImg; //最终火焰二值化显示
fireImg.create(frame.size() CV_8UC1);
Mat multiRGB[3];
int a = frame.channels();
split(frame multiRGB); //将图片拆分成RGB三通道的颜色
pMOG2->apply(frame frt 0.005);

int i j;
for (i = 0; i < frame.rows; i++)
{
for (j = 0; j < frame.cols; j++)
{
if (frt.at(i j) == 0)
{
fireImg.at(i j) = 0;
continue;
}

float B G R;
B = multiRGB[0].at(i j); //每个像素的RGB值动态地址计算法
G = multiRGB[1].at(i j);
R = multiRGB[2].

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       9958  2018-04-19 14:47  烟雾识别\CplusImplement\CplusImplement.cpp

     文件       7783  2018-04-12 09:08  烟雾识别\CplusImplement\CplusImplement.vcxproj

     文件        955  2018-01-31 13:58  烟雾识别\CplusImplement\CplusImplement.vcxproj.filters

     文件        165  2018-01-31 13:56  烟雾识别\CplusImplement\CplusImplement.vcxproj.user

     文件        513  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.log

     文件      51036  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.obj

     文件        898  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\CL.command.1.tlog

     文件      14014  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\CL.read.1.tlog

     文件        732  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\CL.write.1.tlog

     文件        238  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\CplusImplement.lastbuildstate

     文件        522  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\CplusImplement.write.1u.tlog

     文件       1412  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\link.command.1.tlog

     文件       3244  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\link.read.1.tlog

     文件        690  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\CplusImplement.tlog\link.write.1.tlog

     文件     363520  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\vc140.idb

     文件     438272  2017-12-05 17:36  烟雾识别\CplusImplement\Debug\vc140.pdb

     文件       1451  2018-03-06 13:40  烟雾识别\CplusImplement\x64\Debug\CplusImplement.Build.CppClean.log

     文件       1245  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.log

     文件     334542  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.obj

     文件       1772  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\CL.command.1.tlog

     文件      31438  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\CL.read.1.tlog

     文件        836  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\CL.write.1.tlog

     文件        230  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\CplusImplement.lastbuildstate

     文件       3044  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\link.command.1.tlog

     文件       2898  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\link.read.1.tlog

     文件        802  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\CplusImplement.tlog\link.write.1.tlog

     文件    1477632  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\vc140.idb

     文件     897024  2018-04-19 14:48  烟雾识别\CplusImplement\x64\Debug\vc140.pdb

     文件       1828  2018-01-31 13:56  烟雾识别\CplusImplement\x64\Release\CplusImplement.Build.CppClean.log

     文件        246  2018-02-01 09:18  烟雾识别\CplusImplement\x64\Release\CplusImplement.log

............此处省略44个文件信息

评论

共有 条评论