cv2.rectangle

import cv2

cv2.rectangle(img, (x1, y1), (x2, y2), (255,0,0), 2)


x1,y1 ------
|          |
|          |
|          |
--------x2,y2

Here is what the above code is Doing:
1. We’re creating a variable named img.
2. We’re reading in the image using the imread function.
3. We’re creating a variable named x1. This is the x coordinate of the top left corner of the rectangle.
4. We’re creating a variable named y1. This is the y coordinate of the top left corner of the rectangle.
5. We’re creating a variable named x2. This is the x coordinate of the bottom right corner of the rectangle.
6. We’re creating a variable named y2. This is the y coordinate of the bottom right corner of the rectangle.
7. We’re using the cv2.rectangle function to draw a rectangle on the image.
8. We’re displaying the image using the imshow function.
9. We’re waiting for the user to press any key.
10. We’re destroying all the windows.