#includeint main() { int gd = DETECT, gm; initgraph(&gd, &gm, ""); rectangle(200, 100, 400, 300); int area = (400 - 200) * (300 - 100); cout << “Area of the rectangle is:” << area << endl; getch(); closegraph(); return 0; }
#includeIn this example, the Rect class from the OpenCV library is used to create an instance of a rectangle with the given coordinates. The area of the rectangle is then calculated using the area() method provided by the Rect class. The package library being used in this example is the OpenCV package.#include using namespace cv; int main() { Rect rect(50, 50, 200, 200); int area = rect.area(); std::cout << "Area of the rectangle is: " << area << std::endl; return 0; }