इस कार्यक्रम में, हम OpenCV फ़ंक्शन आयत () का उपयोग करके एक आयत बनाएंगे। यह फ़ंक्शन कुछ पैरामीटर लेता है जैसे निर्देशांक प्रारंभ करना, निर्देशांक समाप्त करना, रंग और मोटाई और स्वयं छवि।
मूल चित्र

एल्गोरिदम
Step 1: Import cv2. Step 2: Read the image using imread(). Step 3: Define the starting coordinates. Step 5: Define the ending coordinates. Step 6: Define the color and the thickness. Step 7: Draw the rectangle using the cv2.reactangle() function. Step 8: Display the rectangle.
उदाहरण कोड
import cv2
image = cv2.imread('testimage.jpg')
height, width, channels = image.shape
start_point = (0,0)
end_point = (width, height)
color = (0,0,255)
thickness = 5
image = cv2.rectangle(image, start_point, end_point, color, thickness)
cv2.imshow('Rectangle',image) आउटपुट
