混合高斯背景建模——opencv

混合高斯背景建模原理:
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述
这里写图片描述

代码:

#include<opencv2/highgui.hpp>
#include<opencv2/core.hpp>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main()
{
    CvCapture*capture = cvCreateFileCapture("C:\\Users\\aoe\\Desktop\\avi\\walk.avi");//读取视频
    IplImage*mframe = cvQueryFrame(capture);//读取视频中的一帧

    int height = mframe->height;
    int width = mframe->width;
    int C = 4;//number of gaussian components
    int M = 4;//number of background components
    int std_init = 6;//initial standard deviation
    double D = 2.5;
    double T = 0.7;
    double alpha = 0.01;
    double p = alpha / (1 / C);
    double thresh = 0.25;
    int min_index = 0;
    int*rank_ind=0;
    int i, j,k,m;
    int rand_temp=0;
    int rank_ind_temp = 0;
    CvRNG state;
    IplImage*current = cvCreateImage(cvSize(mframe->width, mframe->height), IPL_DEPTH_8U, 1);
    IplImage*test = cvCreateImage(cvSize(mframe->width, mframe->height), IPL_DEPTH_8U, 1);
    IplImage*frg = cvCreateImage(cvSize(mframe->width, mframe->height), IPL_DEPTH_8U, 1);

    double*mean = (double*)malloc(sizeof(double)*width*height*C);//pixelmeans
    double*std = (double*)malloc(sizeof(double)*width*height*C);//pixel standard deviations
    double*w = (double*)malloc(sizeof(double)*width*height*C);//权值
    double*u_diff = 
  • 2
    点赞
  • 26
    收藏
    觉得还不错? 一键收藏
  • 8
    评论
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值