python draw rectangle code example
Example 1: python how to draw a rectangle
import turtle
for i in range(2):
turtle.forward(20)
turtle.right(90)
turtle.forward(10)
Example 2: python opencv draw rectangle
image = cv2.imread(path)
start_point = (5, 5)
end_point = (220, 220)
color = (255, 0, 0)
thickness = 2
image = cv2.rectangle(image, start_point, end_point, color, thickness)
Example 3: python how to draw a rectangle
import turtle
for i in range(2):
turtle.forward(20)
turtle.right(90)
turtle.forward(10)
Example 4: python draw rectangle on image
img = matplotlib. image. imread("./kite_logo.png")
figure, ax = pyplot. subplots(1)
rect = patches. Rectangle((125,100),50,25, edgecolor='r', facecolor="none")
ax. imshow(img) Displays an image.
ax. add_patch(rect) Add rectangle to image.