fixed crashes in camshiftdemo (ticket #875)

This commit is contained in:
Vadim Pisarevsky
2011-06-17 20:34:34 +00:00
parent 3ca31dcdb6
commit d5ba7c3826
2 changed files with 72 additions and 45 deletions

View File

@@ -90,6 +90,13 @@ cvMeanShift( const void* imgProb, CvRect windowIn,
int dx, dy, nx, ny;
double inv_m00;
cur_rect = cv::Rect(cur_rect) & cv::Rect(0, 0, mat->cols, mat->rows);
if( cv::Rect(cur_rect) == cv::Rect() )
{
cur_rect.x = mat->cols/2;
cur_rect.y = mat->rows/2;
}
cur_rect.width = MAX(cur_rect.width, 1);
cur_rect.height = MAX(cur_rect.height, 1);
cvGetSubRect( mat, &cur_win, cur_rect );
cvMoments( &cur_win, &moments );