| cv.Rect - MATLAB File Help | Go to online doc for cv.Rect |
Class for 2D rectangles
A rectangle [x,y,w,h] is described by the following parameters:
[x,y] in OpenCV. Though, in your algorithms you may count x and
y from the bottom-left corner.[w h].OpenCV typically assumes that the top and left boundary of the rectangle are inclusive, while the right and bottom boundaries are not. For example, the method cv.Rect.contains returns true if:
x <= pt.x < x + width , y <= pt.y < y + height
Virtually every loop over an image ROI in OpenCV (where ROI is specified by an integer rectangle) is implemented as:
roi = [x,y,w,h];
for y=roi(2):(roi(2)+roi(4)-1)
for x=roi(1):(roi(1)+roi(3)-1)
%...
end
end
In addition, the following operations on rectangles are implemented:
rect += point): shifting a rectangle by a
certain offset.rect += size): expanding or shrinking a rectangle by
a certain amount.rect1 & rect2): rectangle intersection.rect1 | rect2): minimum area rectangle containing rect1
and rect2.This is an example how the partial ordering on rectangles can be
established (rect1 \subseteq rect2):
function b = rect_le(r1, r2)
b = all(cv.Rect.intersect(r1,r2) == r1);
end
| Sealed | false |
| Construct on load | false |
| Rect | Class for 2D rectangles |
| Static | adjustPosition | Shift a rectangle by a certain offset |
| Static | adjustSize | Expand or shrink a rectangle by a certain amount |
| Static | area | Area (width*height) of the rectangle |
| Static | br | The bottom-right corner |
| Static | contains | Checks whether the rectangle contains the point |
| Static | crop | Extract region-of-interest from image |
| Static | from2points | Create a rectangle from 2 points |
| Static | intersect | Rectangle intersection |
| Static | size | Size (width, height) of the rectangle |
| Static | tl | The top-left corner |
| Static | union | Minimum area rectangle |