Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

import cv2

import numpy as np

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

cv2.line(img, (50, 50), (100, 100), (255, 255, 255), 2)

cv2.imshow("Line", img)
cv2.waitKey(0)
cv2.destroyAllWindows()

-----------------------------------------------------
cv2.line(img, (50, 50), (100, 100), (255, 255, 255), 2)
cv2.rectangle(img, (100, 100), (300, 300), (255, 255, 255), 2)
cv2.circle(img, (250, 250), 100, (255, 255, 255), 2)
cv2.ellipse(img, (250, 250), (200, 100), 0, 0, 360, (255, 255, 255), 2)

# menentukan titik-titik sudut poligon


pts = np.array([[0, 0], [150, 200], [250, 250], [200, 100]], np.int32)
# True menankan bahwa gambar tertutup, jika False berarti gambar tidak tertutup
cv2.polylines(img, [pts], True, (0, 0, 255), thickness=2)

cv2.putText(img, "Hello, World!", (100, 250), cv2.FONT_HERSHEY_PLAIN, 3,


(255, 255, 255), 2)

You might also like