在cvcamshift中有改变跟踪窗口的算法。
请问大侠其原理是什么?m00 = moments.m00;
m10 = moments.m10;
m01 = moments.m01;
mu11 = moments.mu11;
mu20 = moments.mu20;
mu02 = moments.mu02;if( fabs(m00) < DBL_EPSILON )
EXIT;inv_m00 = 1. / m00;
xc = cvRound( m10 * inv_m00 + windowIn.x );//新计算出来的中心
yc = cvRound( m01 * inv_m00 + windowIn.y );
a = mu20 * inv_m00;
b = mu11 * inv_m00;
c = mu02 * inv_m00;/* Calculating width & height */
square = sqrt( 4 * b * b + (a - c) * (a - c) );/* Calculating orientation */
theta = atan2( 2 * b, a - c + square );/* Calculating width & length of figure */
cs = cos( theta );
sn = sin( theta );rotate_a = cs * cs * mu20 + 2 * cs * sn * mu11 + sn * sn * mu02;
rotate_c = sn * sn * mu20 - 2 * cs * sn * mu11 + cs * cs * mu02;
length = sqrt( rotate_a * inv_m00 ) * 4;
width = sqrt( rotate_c * inv_m00 ) * 4;/* In case, when tetta is 0 or 1.57... the Length & Width may be exchanged */
if( length < width )
{
double t;CV_SWAP( length, width, t );
CV_SWAP( cs, sn, t );
theta = CV_PI*0.5 - theta;
}/* Saving results */
if( _comp || box )
{
int t0, t1;
int _xc = cvRound( xc );
int _yc = cvRound( yc );t0 = cvRound( fabs( length * cs ));
t1 = cvRound( fabs( width * sn ));t0 = MAX( t0, t1 ) + 2;
comp.rect.width = MIN( t0, (mat->width - _xc) * 2 );t0 = cvRound( fabs( length * sn ));
t1 = cvRound( fabs( width * cs ));t0 = MAX( t0, t1 ) + 2;
comp.rect.height = MIN( t0, (mat->height - _yc) * 2 );comp.rect.x = MAX( 0, _xc - comp.rect.width / 2 );
comp.rect.y = MAX( 0, _yc - comp.rect.height / 2 );comp.rect.width = MIN( mat->width - comp.rect.x, comp.rect.width );
comp.rect.height = MIN( mat->height - comp.rect.y, comp.rect.height );
comp.area = (float) m00;
}__END__;if( _comp )
*_comp = comp;if( box )
{
box->size.height = (float)length;
box->size.width = (float)width;
box->angle = (float)(theta*180./CV_PI);
box->center = cvPoint2D32f( comp.rect.x + comp.rect.width*0.5f,
comp.rect.y + comp.rect.height*0.5f);
}