OpenCV学习——物体跟踪的粒子滤波算法实现之权重归一化

/*
Normalizes particle weights so they sum to 1

@param particles an array of particles whose weights are to be normalized
@param n the number of particles in \a particles
*/
void normalize_weights( particle* particles, int n )
{
float sum = 0;
int i;

for( i = 0; i < n; i++ )
sum += particles[i].w;
for( i = 0; i < n; i++ )
particles[i].w /= sum;
}

你可能感兴趣的:(算法)