⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cbgseg.h

📁 用高斯和离子滤波来跟踪视频图像中的移动对象
💻 H
字号:
#include "cv.h"
#include "highgui.h"
#include "cxcore.h"
#include "cvaux.h"
#include <time.h>
#include <math.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
//#include <malloc.h>

#define GAUSSIAN 0
#define PARTICLE 1

//Particle Filter
const double MHI_DURATION = 0.5;
const double MAX_TIME_DELTA = 0.5;
const double MIN_TIME_DELTA = 0.05;
const int N = 3;
const int CONTOUR_MAX_AERA = 16;

//Gaussian Mixture Modal

class CBGSeg
{
public:
	IplImage ** foreground;
	//BGSegment是用来做背景分离的函数
	//VideoPath是视频文件地址
	//Start_Fr是开始帧序号,End_Fr是结束帧序号
	//Format可以有GAUSSIAN和PARTICLE两个值,分别代表用混合高斯以及粒子滤波进行背景建模
	//Parameter是附带参数,当Format等于GAUSSIAN时这个参数可以等于任意值,如果Format等于PARTICLE,该参数设置为粒子滤波时的帧差阈值
	void BGSegment(char* VideoPath,int Start_Fr, int End_Fr, const int Format, int Parameter);
	CBGSeg()
	{
		Initialize();
	}
	~CBGSeg()
	{
		if (capture)	
		{
			cvReleaseCapture(&capture);
		}
		if (malloc_flag==1)	
		{
			for (int i=0;i <= End_Fr-Start_Fr; i++)
			{
				cvReleaseImage( &foreground[0] );
			}
			delete [] foreground;
		}
	}
private:
	//Sharing variant
	CvCapture* capture;
	IplImage* tmp_frame;
	int Fr;
	int Start_Fr;
	int End_Fr;
	int malloc_flag;

	//Particle Filter
	IplImage **buf;
	int last;
	IplImage *mhi; // MHI: motion history image	
	CvFilter filter;
	
	void Initialize();
	void Partical_Tracking(int diff_threshold);
	void Gaussian_Tracking();
	void update_mhi(IplImage *img, IplImage *dst, int diff_threshold);
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -