• 大小: 4.7MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-09-21
  • 语言: 其他
  • 标签: MHI  

资源简介

前后向运动历史图的源代码,基于opencv1.0+vs6.0开发,容易转换成vs以后的版本,配置很容易,压缩包内有原始的paper。

资源截图

代码片段和文件信息

#include “cv.h“
#include “highgui.h“
#include 
#include 
#include 
#include 



float MHI_DURATION = 0.5;

// 用于运动检测的循环帧数,与机器速度以及FPS设置有关
const int N = 4;//N =2345  (帧间差间隔量:当两帧中间无间隔时 N=2,间隔一帧时 N=3,N越大,每层拖尾越宽)
const int L = 11;//L the number of layers (L越大,尾迹越长)
#define M (2*(N-1)+L) //the total of ring image buffer

// ring image buffer  环形缓存器 循环更新
IplImage **buf = 0;

// IplImage **bufDiffForward = 0;  //前向差分结果缓存器
IplImage **bufDiffBackward = 0; //后向差分结果缓存器

int last = 0; //the last index of frame for the Forward MHI
int lastDiff = 0;     //the last index of the diffBackward

/*
Figure of Forward-Backward MHI


History                                               Current  Future
 |_____________|_____________|_____________|_____________|_____________|_____________|_____________|_____________| 

   |---------------buf[2(N-1)+L](ring buffer forward order)------------->|
 idx1 idx2 last
   |_____________|_____________| _
 |_____________|         |      |_____________|  idx3         idx4 |
   |_____________| |           |      |_____________|     | L:layers
 |_____________|     |   |             |      |_____________|      |        (each of layer)
|   |             |           | -
    |---------------------------------------->|
diffBackward[L] 
  (ring buffer forward order)
    
*/


// temporary images
IplImage *mhiForward = 0; // Forward MHI: motion history image
IplImage *mhiBackward = 0; // mhiBackward MHI: motion history image
IplImage *orient = 0; // orientation
IplImage *mask = 0; // valid orientation mask
IplImage *segmask = 0; // motion segmentation map
CvMemStorage* storage = 0; // temporary storage




//parameters:
// silh - 单帧差图像
// mhi - MHI合成图像
// layers - 尾迹层数 
void myUpdateMotionHistory( IplImage* silh IplImage* mhi int layers) // update MHI
{
int xy;
    int silStep = silh->widthStep;
int mhiStep = mhi->widthStep;
CvSize size = cvGetSize(silh);


uchar * silhIm = silh->imageData;
uchar * mhiIm = mhi->imageData;

int d = 255/layers;

for(  y = 0; y < size.height; y++ silhIm += silStep mhiIm += mhiStep )
for(  x = 0; x < size.width; x++ )
{
int val = mhiIm[x];
val = max(silhIm[x]max(0val-d));
mhiIm[x] = val;
}
}



// parameters:
//  img - 输入最新视频帧
//  dstForward - 输出Forward MHI 
//  dstBackward - 输出Backward MHI
//  diff_threshold - 输入帧间差二值化阈值

void  update_mhi( IplImage* img IplImage* dstForward IplImage* dstBackward IplImage* curImg int diff_threshold )
{
    //double timestamp = clock()/1000.; // get current time in seconds
    CvSize size = cvSize(img->widthimg->height); // get current frame size
    int i;
int idx1;    //当前帧往前第(N-1)帧的标号
int idx2;    //当前帧的标号
int idx3;    //未来最新帧往前第

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    2270208  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.bsc

     文件     192584  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.exe

     文件     219556  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.ilk

     文件      21577  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.obj

     文件      21649  2009-04-02 11:30  OpenCV_forward-backwrd MHI\Debug\motempl.obj.enc

     文件    4164400  2009-08-20 08:57  OpenCV_forward-backwrd MHI\Debug\motempl.pch

     文件     467968  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.pdb

     文件          0  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\motempl.sbr

     文件      41984  2009-12-25 13:53  OpenCV_forward-backwrd MHI\Debug\vc60.idb

     文件      77824  2009-10-14 15:29  OpenCV_forward-backwrd MHI\Debug\vc60.pdb

     文件        135  2007-02-24 15:18  OpenCV_forward-backwrd MHI\Makefile

     文件      12581  2009-10-14 15:29  OpenCV_forward-backwrd MHI\motempl.c

     文件       4160  2008-06-15 06:32  OpenCV_forward-backwrd MHI\motempl.dsp

     文件        539  2007-03-07 20:41  OpenCV_forward-backwrd MHI\motempl.dsw

     文件      58368  2009-12-25 13:55  OpenCV_forward-backwrd MHI\motempl.ncb

     文件     345088  2009-12-25 13:55  OpenCV_forward-backwrd MHI\motempl.opt

     文件       1350  2009-10-14 15:29  OpenCV_forward-backwrd MHI\motempl.plg

    ..A.SH.     13824  2008-07-14 16:10  OpenCV_forward-backwrd MHI\Thumbs.db

     文件     432700  2007-02-24 15:18  OpenCV_forward-backwrd MHI\video1.avi

     文件    2533113  2008-05-27 11:32  OpenCV_forward-backwrd MHI\zyin06OTCBVS.pdf

     文件        348  2009-12-25 15:01  OpenCV_forward-backwrd MHI\说明.txt

     目录          0  2009-12-25 13:56  OpenCV_forward-backwrd MHI\Debug

     目录          0  2009-12-25 14:46  OpenCV_forward-backwrd MHI

----------- ---------  ---------- -----  ----

             10879956                    23


评论

共有 条评论