cv.Rect - MATLAB File Help Go to online doc for cv.Rect
cv.Rect

Class for 2D rectangles

A rectangle [x,y,w,h] is described by the following parameters:

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:

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
See also
Class Details
Sealed false
Construct on load false
Constructor Summary
Rect Class for 2D rectangles 
Method Summary
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