没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
// my_mixgaussians.cpp : 定义控制台应用程序的入口点。
//
//#include "stdafx.h"
#include "cv.h"
#include "highgui.h"
int main(int argc,char *argv[])
{
CvCapture *capture=cvCreateFileCapture("short.avi");
IplImage *mframe,*current,*frg,*test;
int *fg,*bg_bw,*rank_ind;
double *w,*mean,*sd,*u_diff,*rank;
int
C,M,sd_init,i,j,k,m,rand_temp=0,rank_ind_temp=0,min_index=0,x=0,y=0,counter_frame=0;
double D,alph,thresh,p,temp;
CvRNG state;
int match,height,width;
mframe=cvQueryFrame(capture);
frg = cvCreateImage(cvSize(mframe->width,mframe->height),IPL_DEPTH_8U,1);
current = cvCreateImage(cvSize(mframe->width,mframe->height),IPL_DEPTH_8U,1);
test = cvCreateImage(cvSize(mframe->width,mframe->height),IPL_DEPTH_8U,1);
C = 4; //number of gaussian components (typically 3-5)
M = 4; //number of background components
sd_init = 6; //initial standard deviation (for new components) var = 36 in
paper
alph = 0.01; //learning rate (between 0 and 1) (from paper 0.01)
D = 2.5; //positive deviation threshold
thresh = 0.25; //foreground threshold (0.25 or 0.75 in paper)
p = alph/(1/C); //initial p variable (used to update mean and sd)
height=current->height;width=current->widthStep;
fg = (int *)malloc(sizeof(int)*width*height); //foreground array
bg_bw = (int *)malloc(sizeof(int)*width*height); //background array
rank = (double *)malloc(sizeof(double)*1*C); //rank of components
(w/sd)
w = (double *)malloc(sizeof(double)*width*height*C); //weights array
mean = (double *)malloc(sizeof(double)*width*height*C); //pixel means
sd = (double *)malloc(sizeof(double)*width*height*C); //pixel standard
deviations
u_diff = (double *)malloc(sizeof(double)*width*height*C); //difference of each
pixel from mean
for (i=0;i<height;i++)
{
for (j=0;j<width;j++)
{
for(k=0;k<C;k++)
{
*m_frame 原图
*current 灰度图
*frg 前景图
*test 背景图
——*——
*fg 前景数组指针
*bg_bw 背景数组指针
*rand_ind模式初始序号(0,1......)
——*——
*w 保存各模式权值系数
*mean 均值u
*sd 方差
*u_diff |x-u|
*rank w/方差(用于排序)
——*——
C高斯模式数 M有效背景模式数
资源评论
- zcnc20122014-09-30谢谢分享,参考一下
haoxiaodao
- 粉丝: 68
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功