1import cv2
2path = r'C:\Users\Rajnish\Desktop\geeksforgeeks\geeks.png'
3image = cv2.imread(path, 0)
4# represents the top left corner of rectangle
5start_point = (100, 50)
6# represents the bottom right corner of rectangle
7end_point = (125, 80)
8color = (0, 0, 0)
9linethickness = -1
10image = cv2.rectangle(image, start_point, end_point, color, linethickness)
11cv2.imshow('Image', image)
1image = cv2.imread(path)
2
3start_point = (5, 5)
4end_point = (220, 220)
5
6# Blue color in BGR
7color = (255, 0, 0)
8
9# Line thickness of 2 px
10thickness = 2
11
12# Using cv2.rectangle() method
13# Draw a rectangle with blue line borders of thickness of 2 px
14image = cv2.rectangle(image, start_point, end_point, color, thickness)