Commit a3dfba36 authored by Vadim Pisarevsky's avatar Vadim Pisarevsky

fixed crashes in camshiftdemo sample

parent 921c68de
...@@ -892,7 +892,7 @@ EllipseEx( Mat& img, Point center, Size axes, ...@@ -892,7 +892,7 @@ EllipseEx( Mat& img, Point center, Size axes,
int angle, int arc_start, int arc_end, int angle, int arc_start, int arc_end,
const void* color, int thickness, int line_type ) const void* color, int thickness, int line_type )
{ {
CV_Assert( axes.width >= 0 && axes.height >= 0 ); axes.width = std::abs(axes.width), axes.height = std::abs(axes.height);
int delta = (std::max(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT; int delta = (std::max(axes.width,axes.height)+(XY_ONE>>1))>>XY_SHIFT;
delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5; delta = delta < 3 ? 90 : delta < 10 ? 30 : delta < 15 ? 18 : 5;
......
...@@ -80,9 +80,7 @@ cvMeanShift( const void* imgProb, CvRect windowIn, ...@@ -80,9 +80,7 @@ cvMeanShift( const void* imgProb, CvRect windowIn,
if( windowIn.height <= 0 || windowIn.width <= 0 ) if( windowIn.height <= 0 || windowIn.width <= 0 )
CV_Error( CV_StsBadArg, "Input window has non-positive sizes" ); CV_Error( CV_StsBadArg, "Input window has non-positive sizes" );
if( windowIn.x < 0 || windowIn.x + windowIn.width > mat->cols || windowIn = cv::Rect(windowIn) & cv::Rect(0, 0, mat->cols, mat->rows);
windowIn.y < 0 || windowIn.y + windowIn.height > mat->rows )
CV_Error( CV_StsBadArg, "Initial window is not inside the image ROI" );
criteria = cvCheckTermCriteria( criteria, 1., 100 ); criteria = cvCheckTermCriteria( criteria, 1., 100 );
eps = cvRound( criteria.epsilon * criteria.epsilon ); eps = cvRound( criteria.epsilon * criteria.epsilon );
...@@ -91,7 +89,8 @@ cvMeanShift( const void* imgProb, CvRect windowIn, ...@@ -91,7 +89,8 @@ cvMeanShift( const void* imgProb, CvRect windowIn,
{ {
int dx, dy, nx, ny; int dx, dy, nx, ny;
double inv_m00; double inv_m00;
cur_rect = cv::Rect(cur_rect) & cv::Rect(0, 0, mat->cols, mat->rows);
cvGetSubRect( mat, &cur_win, cur_rect ); cvGetSubRect( mat, &cur_win, cur_rect );
cvMoments( &cur_win, &moments ); cvMoments( &cur_win, &moments );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment