How draw Line, Rectangle, Circle, Triangle, and write text in openCV.

import cv2
import numpy as np


black_image = np.zeros((600, 800, 3), np.uint8)

cv2.line(black_image, (0, 0), (800, 600), (255, 0, 0), 3)
cv2.rectangle(black_image,(0, 0),(300, 400),(255, 0, 0),3)
cv2.circle(black_image, (400, 300), 100, (255, 0, 0), 2)
cv2.circle(black_image, (200, 150), 100, (255, 0, 0), -1)

pts = np.array([[0, 600], [800, 600], [400, 300]])

cv2.polylines(black_image, [pts], True, (255, 255, 0), 2)

font = cv2.FONT_HERSHEY_SIMPLEX

cv2.putText(black_image,'you are best',(0, 300), font, 4, (0, 255, 0))

while True:
    cv2.imshow('window', black_image)

    if cv2.waitKey(1) == 27:
        break
cv2.destroyAllWindows()

Comments

Popular posts from this blog

how to Create a Black Image in OpenCV

Playing a video from file with color BGR, RGB, GRAY, HSV in OpenCV

Capturing Video via webcam