O'Reilly logo

Learn OpenCV 4 by Building Projects - Second Edition by Prateek Joshi, Vinicius G. Mendonca, David Millan Escriva

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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);

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required