#includeusing namespace cv; // Create a rectangle object with parameters Rect r1 = Rect(10, 10, 50, 50); // x, y, width, and height
#includeusing namespace cv; // Create a rectangle object with parameters Rect r1 = Rect(10, 10, 50, 50); // Accessing the properties of a rectangle object int x = r1.x; // 10 int y = r1.y; // 10 int width = r1.width; // 50 int height = r1.height; // 50
#includeHere, the Rect class is used in OpenCV library in C++ programming language to create, modify and manipulate rectangles in the context of image processing and computer vision. Package/library: OpenCV#include using namespace cv; int main() { // Load an image Mat image = imread("image.jpg"); // Create a rectangle object with parameters Rect r1 = Rect(10, 10, 50, 50); // Draw a rectangle on the image rectangle(image, r1, Scalar(255, 0, 0), 2); // Display the image imshow("Image with a rectangle", image); waitKey(0); return 0; }