資源簡介
前景提取、圖像縮放、煙霧識別、圖像處理、運(yùn)動檢測、目標(biāo)圈定

代碼片段和文件信息
#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;//計(jì)數(shù),連續(xù)五張判斷成功就認(rèn)為有煙火
int?attr[3]?=?{?-1-1-1?};//圖片屬性,分別是上?左?右?最邊上的疑似像素位置
int?px_num?=?0;//疑似像素個數(shù)
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()) //檢測是否正常打開:成功打開時(shí),isOpened返回ture
{
cout?<“打開失敗“?< system(“pause“);
return?-1;
}
cout?<“打開攝像頭成功“?< //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);
//打開視頻文件,準(zhǔn)備寫入??
//write.open(arr2?-1?rate?S?true);
cout?<“進(jìn)入循環(huán)“?<
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?< 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; //是否有可疑點(diǎn)
bool?value?=?false; //是否進(jìn)行形態(tài)學(xué)處理以及邊框勾選
Mat?frt; //優(yōu)化,先進(jìn)行前景動態(tài)提取,背景直接過濾
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?ame.rows;?i++)
{
for?(j?=?0;?j?ame.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值動態(tài)地址計(jì)算法
G?=?multiRGB[1].at(i?j);
R?=?multiRGB[2].
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????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\li
?????文件???????3244??2017-12-05?17:36??煙霧識別\CplusImplement\Debug\CplusImplement.tlog\li
?????文件????????690??2017-12-05?17:36??煙霧識別\CplusImplement\Debug\CplusImplement.tlog\li
?????文件?????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\li
?????文件???????2898??2018-04-19?14:48??煙霧識別\CplusImplement\x64\Debug\CplusImplement.tlog\li
?????文件????????802??2018-04-19?14:48??煙霧識別\CplusImplement\x64\Debug\CplusImplement.tlog\li
?????文件????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個文件信息
評論
共有 條評論