This is the mathematical notation for "+ =" in C ++. You are not actually using ± directly. For instance:
//make a rectangle that 10x10 and centered at (0, 0) cv::Rect rect(0, 0, 10, 10); std::cout << "Original Rectangle: " << rect.area() << std::endl; //manual addition to rectangle dimensions -- this will make bigger_rect be 20x20 cv::Rect bigger_rect = rect; bigger_rect.height += 10; bigger_rect.width += 10; std::cout << "Bigger Rectangle: " << bigger_rect.area() << std::endl; //other method of adding to a rectangle area -- this will increase rect to be 20x20 rect += cv::Size(10, 10); std::cout << rect.area() << std::endl;
So, to make your example of adding 10 to the height and width of the rectangle, think of the ± symbol as equivalent to += cv::Size(width, height)
Well, you more or less had the right idea ...
EDIT: As for your comment, I have to clarify: rect + = point, rect - = point, rect + = size, rect - = size - 4 different operations, for example:
rect += point and rect -= point : moves the rectangle at the point where the point refers to the cv::Point object, i.e. you can declare a point as: cv::Point pt(5, 5); , then if you do rect += pt , it will shift the rectangle of x and y members (by default they refer to the upper left left side of the rectangle) by 5 - for example. this is equivalent to doing rect.x += 5 and rect.y += 5 . The case for rect -= point the same, although for subtraction and not for addition (so rect.x -= 5 and rect.y -= 5 ).
rect += size and rect -= size will change the size of the rectangle, not the coordinate, so += will increase the area of the rectangle, and -= will reduce it.
source share