资源简介
行人检测C++代码
代码片段和文件信息
#include “cv.h“
#include
#include “highgui.h“
#include
#include
#include
#include
#include
// various tracking parameters (in seconds)
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;
// ring image buffer
IplImage **buf = 0;
int last = 0;
// temporary images
IplImage *mhi = 0;
// MHI: motion history image
int filter = CV_GAUSSIAN_5x5;
CvConnectedComp *cur_comp min_comp;
CvConnectedComp comp;
CvMemStorage *storage; CvPoint pt[4];
// 参数:
// img – 输入视频帧
// dst – 检测结果
void update_mhi( IplImage* img IplImage* dst int diff_threshold )
{
double timestamp = clock()/100.;
// get current time in seconds
CvSize size = cvSize(img->widthimg->height);
// get current frame size
int i j idx1 idx2;
IplImage* silh;
uchar val;
float temp;
IplImage* pyr = cvCreateImage( cvSize((size.width & -2)/2 (size.height & -2)/2) 8 1 );
CvMemStorage *stor;
CvSeq *cont *result *squares;
CvSeqReader reader;
if( !mhi || mhi->width != size.width || mhi->height != size.height )
{
if( buf == 0 )
{
buf = (IplImage**)malloc(N*sizeof(buf[0]));
memset( buf 0 N*sizeof(buf[0]));
}
for( i = 0; i < N; i++ )
{
cvReleaseImage( &buf[i] );
buf[i] = cvCreateImage( size IPL_DEPTH_8U 1 );
cvZero( buf[i] );
}
cvReleaseImage( &mhi );
mhi = cvCreateImage( size IPL_DEPTH_32F 1 );
cvZero( mhi );
// clear MHI at the beginning
}
// end of if(mhi)
cvCvtColor( img buf[last] CV_BGR2GRAY );
// convert frame to grayscale
idx1 = last;
idx2 = (last + 1) % N;
// index of (last - (N-1))th frame
last = idx2;
// 做帧差
silh = buf[idx2];
cvAbsDiff( buf[idx1] buf[idx2] silh );
// get difference between frames
// 对差图像做二值化
cvThreshold( silh silh 30 255 CV_THRESH_BINARY );
// and threshold it
cvUpdateMotionHistory( silh mhi timestamp MHI_DURATION );
// update MHI
cvCvtScale( mhi dst 255./MHI_DURATION
(MHI_DURATION - timestamp)*255./MHI_DURATION );
cvCvtScale
- 上一篇:贪心算法解多重背包代码
- 下一篇:C++编写的多叉树结构
相关资源
- OLED驱动源码
- tm1650+stm32f103源码(board_tm1650.c)
- 颜色识别形状识别STM103嵌入式代码
- 汽车电子编程规范(Unlock-MISRA C 2012)
- cheat engine 7.2源码
- CrySearch内存搜索器源码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- windows网络编程_文件传输
- MFC视频播放器源码(支持avi/wma/mp3等格
- CreatBitmap图片合成源码
- c++ 画图(14Qt-XPS)
- 工程库实现面向对象编程
- c++多边形交并差运算
- VC++基于OpenGL模拟的一个3维空间模型
- c++ 虚拟摄像头
- vs2008 can总线通讯源码
- 宠物管理系统课程设计(源码+数据库
- hook,捕获所有案件,查找所有窗口,
- C语言课设计算器
- Windows扩展命令程序(源码)
- c语言实现火车订票系统(控制台)源
- 鼠标连点器(附源码)
- c++ 简易贪吃蛇源码
- 杀毒软件源码
- 经典外汇智能交易程序Amazing3.1源码(
- 高精度加法(c++代码)
- C++调用百度地图案例
评论
共有 条评论