《学习OpenCV》平均距离法实现背景建模(page300)

本文档介绍了如何利用OpenCV库通过平均背景法来实现视频背景建模,适用于室内静态场景,避免了移动背景成分的影响。通过累积图像、计算背景和差值,设置阈值,从而实现背景减除并分割出前景物体。
摘要由CSDN通过智能技术生成
/********************************************************************************************
	Averaging Background Method
	平均背景法
	We’ve just seen a simple method of learning background scenes and segmenting fore-
	ground objects. It will work well only with scenes that do not contain moving background 
	components (like a waving curtain or waving trees). It also assumes that the lighting 
	remains fairly constant (as in indoor static scenes). 
*********************************************************************************************/

#include "cv.h"
#include "highgui.h"

/*******************************************************/
//全局变量:我们为需要的不同临时图像和统计属性的图像创建指针
/*Float 3-channel images*/
IplImage* IavgF, *IdiffF, *IprevF, *IhiF, *IlowF;
IplImage* Iscratch, *Iscratch2;

/*Float 1-channel images*/
IplImage* Igray1, *Igray2, *Igray3;
IplImage* Ilow1, *Ilow2, *Ilow3;
IplImage* Ihi1, *Ihi2, *Ihi3;

/*Byte 1-channel image*/
IplImage* Imaskt;
IplImage* Imask;

float Icount;
/******************************************************/


/*该函数为需要的所有临时图像分配内存,传入来自视频的首帧图像作为大小参考*/
void AllocateImages( IplImage* I )
{
	CvSize sz = cvGetSize(I);
	/*Float 3-channel images*/
	IavgF	= cvCreateImage(sz, IPL_DEPTH_32F, 3);
	IdiffF	= cvCreateImage(sz, IPL_DEPTH_32F, 3);
	IprevF	= cvCr
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值