python bounding box on image 1

python bounding box on image

# cv2.rectangle(img, pt1, pt2, color, thickness, lineType, shift)
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 create a variable called img. img is set to the image that we loaded.
2. We create a variable called pt1. pt1 is set to the coordinates (100,100).
3. We create a variable called pt2. pt2 is set to the coordinates (200,200).
4. We create a variable called color. color is set to the color red.
5. We create a variable called thickness. thickness is set to 2.
6. We create a variable called lineType. lineType is set to 8.
7. We create a variable called shift. shift is set to 0.
8. We use the cv2.rectangle function to draw a rectangle on the image.

Similar Posts