Shapes and Texts

â—¾ giving color values to specific area

import cv2
import numpy as np

img = np.zeros((512,512,3),np.uint8)
img[200:300, 100:300] = 255,0,0

cv2.imshow("Image", img)


cv2.waitKey(0)

We don't no longer add 'import lines' again and again.

cv2.FILLED might be used as thickness in arguments.

🥢 Line

img = np.zeros((512,512,3),np.uint8)

cv2.line(img,(0,0), (300, 300), (0, 255, 0), 3)
#cv2.line(img, (0,0), (img.shape[1], img.shape[0]), (0,255,0), 3) for diagonal line.

cv2.imshow("Image", img)

cv2.waitKey(0)

⬛ Rectangle

cv2.rectangle(img, (0,0), (250,300), (255, 0, 0), 4)

Last updated