資源簡介
壓縮包里共包含4種最常用的運動目標檢測算法:混合高斯模型 相鄰幀差法 運行期均值法 自適應閾值的三幀差分法 ;全部是自己總結和寫的,絕對可以運行。

代碼片段和文件信息
#include?“opencv2/imgproc/imgproc.hpp“
#include?“opencv2/video/background_segm.hpp“
#include?“opencv2/highgui/highgui.hpp“
#include?“opencv2/objdetect/objdetect.hpp“
#include?“cxcore.h“
#include?“cv.h“
#include?
using?namespace?std;
using?namespace?cv;
int?main(int?argc?const?char**?argv)
{
namedWindow(“frame“?0);
namedWindow(“foreground_mask1“?0);//高斯提取結果
namedWindow(“foreground_mask2“?0);//形態學處理后
moveWindow(“frame“00);
moveWindow(“foreground_mask1“3500);
moveWindow(“foreground_mask2“7000);
VideoCapture?cap;
cap.open(“E:\\1.MTS“);
????if(?!cap.isOpened()?)
????{
????????printf(“can?not?open?camera?or?video?file\n“);
????????return?-1;
????}
//定義GMM檢測的類
????BackgroundSubtractorMOG2?bg_model;//(100?3?0.3?5);
int?frame_num=0;
Mat?frame;
for(;;)
{
double?t?=?(double)getTickCount();
frame_num++;
cap?>>?frame;
????????if(?frame.empty()?)
????????????break;
Mat?input_image??foreground_mask;
frame.copyTo(input_image);
????????cvtColor(?input_image?input_image?COLOR_BGR2GRAY?);
//高斯前景分割,具體閾值有優化的空間
????????bg_model(?input_image?foreground_mask?0.01?);//更新背景+檢測前景
threshold(?foreground_mask?foreground_mask?20?255?CV_THRESH_BINARY?);
if(frame_num<=20)
continue;
imshow(“foreground_mask1“?foreground_mask);
//形態學處理1:去噪,先腐蝕后膨脹
dilate(foreground_mask?foreground_mask?Mat()?Point(-1-1)?1);
erode(foreground_mask?foreground_mask?Mat()?Point(-1-1)?1);
imshow(“foreground_mask2“?foreground_mask);
?
t?=?(double)getTickCount()?-?t;
????????printf(“%d:?%gms\n“?frame_numt*1000./cv::getTickFrequency());
imshow(“frame“?frame);
char?k?=?(char)waitKey(0);
????????if(?k?==?27?)?
break;
}
return?0;
}
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????1844??2014-07-15?15:30??運動目標檢測算法研究總結\混合高斯模型\1?混合高斯模型提取運動區域.cpp
?????文件???????2530??2013-10-09?14:24??運動目標檢測算法研究總結\相鄰幀差法\相鄰幀差法提取運動目標.cpp
?????文件???????2730??2013-10-25?14:32??運動目標檢測算法研究總結\相鄰幀差法\相鄰幀差法提取運動目標并計時.cpp
?????文件???????4662??2014-01-04?12:27??運動目標檢測算法研究總結\自適應閾值的三幀差分法\IplImage三幀差1.cpp
?????文件???????2225??2014-01-02?20:14??運動目標檢測算法研究總結\自適應閾值的三幀差分法\Mat???????三幀差2.cpp
?????文件???????4766??2014-04-21?15:55??運動目標檢測算法研究總結\自適應閾值的三幀差分法\自己改寫的IplImage三幀差分法閾值需手動設定.cpp
?????文件???????6446??2013-10-09?12:02??運動目標檢測算法研究總結\運行期均值法\IplImage+CvMat運行期均值法在視頻中提取運動目標已添加注釋.cpp
?????文件???????2283??2013-10-09?14:25??運動目標檢測算法研究總結\運行期均值法\運行期均值提取運動目標.cpp
?????文件???????6450??2013-10-29?12:20??運動目標檢測算法研究總結\運行期均值法\運行期均值法已添加注釋.cpp
?????目錄??????????0??2016-12-25?12:03??運動目標檢測算法研究總結\混合高斯模型
?????目錄??????????0??2016-12-25?12:03??運動目標檢測算法研究總結\相鄰幀差法
?????目錄??????????0??2016-12-25?12:03??運動目標檢測算法研究總結\自適應閾值的三幀差分法
?????目錄??????????0??2016-12-25?12:03??運動目標檢測算法研究總結\運行期均值法
?????目錄??????????0??2016-12-25?12:03??運動目標檢測算法研究總結
-----------?---------??----------?-----??----
????????????????33936????????????????????14
- 上一篇:LM331 V/F Converter
- 下一篇:數據保存框圖
評論
共有 條評論