Rect object type

Rect is another important template class for defining 2D rectangles defined by the following parameters:

  • The coordinates of the upper-left corner

  • The width and height of a rectangle

The Rect template class can be used to define a region of interest (ROI) of an image, as follows:

Mat img=imread("lena.jpg");
Rect rect_roi(0,0,100,100);
Mat img_roi=img(r);