ImageUtils.cpp
CvRect scaleRect(const CvRect rectIn, float scaleX, float scaleY, int w, int h)
{
	CvRect rect;
	// Scale the image region position & size
	rect.x = cvRound(scaleX * (float)rectIn.x);
	rect.y = cvRound(scaleY * (float)rectIn.y);
	rect.width = cvRound(scaleX * (float)rectIn.width);
	rect.height = cvRound(scaleY * (float)rectIn.height);
	// Make sure it doesn't go outside the image
	if (w > 0 && h > 0) {
		if (rect.x + rect.width > w)
			rect.width = w - rect.x;
		if (rect.y + rect.height > h)
			rect.height = h - rect.y;
	}
	return rect;
}
// Enlarge or shrink the rectangle size & center by a given scale.
// If w & h are given, will make sure the rectangle stays within the bounds if it is enlarged too much.
// Note that for images, w should be (width-1) and h should be (height-1).

Enlarge or shrink the rectangle size & center by a given scale.
If w & h are given, will make sure the rectangle stays within the bounds if it is enlarged too much.
Note that for images, w should be (width-1) and h should be (height-1).
Enlarge or shrink the rectangle size & center by a given scale . If w & h are given will make sure the rectangle stays within the bounds if it is enlarged too much . Note that for images w should be ( width - 1 ) and h should be ( height - 1 ) .
CvRect scaleRect(const CvRect rectIn, float scaleX, float scaleY, int w, int h)
{
	CvRect rect;
	rect.x = cvRound(scaleX * (float)rectIn.x);
	rect.y = cvRound(scaleY * (float)rectIn.y);
	rect.width = cvRound(scaleX * (float)rectIn.width);
	rect.height = cvRound(scaleY * (float)rectIn.height);
	if (w > 0 && h > 0) {
		if (rect.x + rect.width > w)
			rect.width = w - rect.x;
		if (rect.y + rect.height > h)
			rect.height = h - rect.y;
	}
	return rect;
}
CvRect scaleRect ( const CvRect rectIn , float scaleX , float scaleY , int w , int h ) { CvRect rect ; rect . x = cvRound ( scaleX * ( float ) rectIn . x ) ; rect . y = cvRound ( scaleY * ( float ) rectIn . y ) ; rect . width = cvRound ( scaleX * ( float ) rectIn . width ) ; rect . height = cvRound ( scaleY * ( float ) rectIn . height ) ; if ( w > 0 && h > 0 ) { if ( rect . x + rect . width > w ) rect . width = w - rect . x ; if ( rect . y + rect . height > h ) rect . height = h - rect . y ; } return rect ; }
Enlarge or shrink the rectangle size & center by a given scale.
Enlarge or shrink the rectangle size & center by a given scale .
// Scale the image region position & size
 // Make sure it doesn't go outside the image
