资源简介
粒子滤波器+目标跟踪的C实现,VS2013+opencv249+gsl1.8。包含gsl1.8工具,无需二外单独下载
代码片段和文件信息
/*
Functions for the observation model in a particle filter football player
tracker
@author Rob Hess
@version 1.0.0-20060306
*/
#include “defs.h“
#include “utils.h“
#include “observation.h“
/*
Converts a BGR image to HSV colorspace
@param bgr image to be converted
@return Returns bgr converted to a 3-channel 32-bit HSV image with
S and V values in the range [01] and H value in the range [0360]
*/
//将图像转换到HSV颜色空间
IplImage* bgr2hsv( IplImage* bgr )
{
IplImage* bgr32f * hsv;
bgr32f = cvCreateImage( cvGetSize(bgr) IPL_DEPTH_32F 3 );
hsv = cvCreateImage( cvGetSize(bgr) IPL_DEPTH_32F 3 );
cvConvertScale( bgr bgr32f 1.0 / 255.0 0 );
cvCvtColor( bgr32f hsv CV_BGR2HSV );
cvReleaseImage( &bgr32f );
return hsv;
}
/*
Calculates the histogram bin into which an HSV entry falls
@param h Hue
@param s Saturation
@param v Value
@return Returns the bin index corresponding to the HSV color defined by
\a h \a s and \a v.
*/
int histo_bin( float h float s float v )
{
int hd sd vd;
/* if S or V is less than its threshold return a “colorless“ bin */
vd = MIN( (int)(v * NV / V_MAX) NV-1 );
if( s < S_THRESH || v < V_THRESH )
return NH * NS + vd;
/* otherwise determine “colorful“ bin */
hd = MIN( (int)(h * NH / H_MAX) NH-1 );
sd = MIN( (int)(s * NS / S_MAX) NS-1 );
return sd * NH + hd;
}
/*
Calculates a cumulative histogram as defined above for a given array
of images
@param img an array of images over which to compute a cumulative histogram;
each must have been converted to HSV colorspace using bgr2hsv()
@param n the number of images in imgs
@return Returns an un-normalized HSV histogram for \a imgs
*/
/* 对直方图进行计算
* 颜色特征对图像本身的尺寸、方向、视角的依赖性较小,从而具有较高的鲁棒性
* 粒子与目标的直方图月相似,就越可能是目标
*/
histogram* calc_histogram( IplImage** imgs int n )
{
IplImage* img;
histogram* histo;
IplImage* h * s * v;
float* hist;
int i r c bin;
histo = malloc( sizeof(histogram) );
histo->n = NH*NS + NV;
hist = histo->histo;
memset( hist 0 histo->n * sizeof(float) );
for( i = 0; i < n; i++ )
{
/* extract individual HSV planes from image */
img = imgs[i];
h = cvCreateImage( cvGetSize(img) IPL_DEPTH_32F 1 );
s = cvCreateImage( cvGetSize(img) IPL_DEPTH_32F 1 );
v = cvCreateImage( cvGetSize(img) IPL_DEPTH_32F 1 );
cvCvtPixToPlane( img h s v NULL );
/* increment appropriate histogram bin for each pixel */
// 计算直方图
for( r = 0; r < img->height; r++ )
for( c = 0; c < img->width; c++ )
{
bin = histo_bin( /*pixval32f( h r c )*/((float*)(h->imageData + h->widthStep*r) )[c]
((float*)(s->imageData + s->widthStep*r) )[c]
((float*)(v->imageData + v->widthStep*r) )[c] );
hist[bin] += 1;
}
cvReleaseImage( &h );
cvReleaseImage( &s );
cvReleaseImage( &v );
}
return histo;
}
/*
Normalizes a histogram so all bins sum to 1.0
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6476814 2008-05-29 11:00 gsl-1.8.exe
----------- --------- ---------- ----- ----
6476814 1
相关资源
- 张平OpenCV算法精讲基于python和C++教材
- 虹膜识别开源代码OSIRIS4.1基于opencv
- staple多目标跟踪算法代码
- Sift特征点提取与匹配opencv库
- YCbCr、混合高斯以及YCbCg肤色检测模型
- 光流法代码
- OpenCV打开摄像机显示在MFC窗口工程源
- 使用c++读取图像到二维矩阵
- 三维点云的圆柱面拟合
- MFC+OPENCV摄像机标定程序
- 基于特征脸的人脸识别MFC+OpenCV
- opencv图像处理MFC
- OPENCV人脸检测加角点检测并输出坐标
- FillHole.rar
- 道路提取算法 c++ opencv
- PCA代码实现详解
- opencv卡尔曼滤波
- SeamCarving opencv c++
- opencv prewitt边缘检测
- MFC中使用OpenCV显示选定文件夹中所有
- 车牌识别系统和车型识别系统源代码
- opencv 模糊C均值 c++
- 基于opencv的图像配准程序
- VC++直方图均衡化显示图像及直方图
- Opencv+VC6.0实现摄像头视频的监控
- opencv入门教程(C++版)
- 简单的几何图形识别程序源代码
- 虹膜分割 Iris Segmentation C++和opencv实现
- 安装配置 opencl的指导手册
- C++(OPENCV)摄像头标定代码带图片O
评论
共有 条评论