▪︎ 도형 그리기

▫︎ 선 그리기

img = np.zeros((460, 640, 3), dtype=np.uint8)

COLOR = (0,255,255)
THICKNESS = 5

cv.line(img, (100,100), (300,300), COLOR, THICKNESS, cv.LINE_4)
cv.line(img, (150,100), (350,300), COLOR, THICKNESS, cv.LINE_8)
cv.line(img, (200,100), (400,300), COLOR, THICKNESS, cv.LINE_AA)

cv.imshow("Line", img)

cv.waitKey(0)
cv.destroyAllWindows()
cv.waitKey(1)

▫︎ 원 그리기

img = np.zeros((460, 640, 3), dtype=np.uint8)

RADIUS = 50
COLOR = (255,0,0)
THICKNESS = 10

# 속이 비어있는 원
cv.circle(img, (200, 200), RADIUS, COLOR, THICKNESS, cv.LINE_AA)

# 속이 채워진 원
cv.circle(img, (400, 200), RADIUS, COLOR, cv.FILLED, cv.LINE_AA)

cv.imshow("Circle", img)

cv.waitKey(0)
cv.destroyAllWindows()
cv.waitKey(1)

▫︎ 타원 그리기

img = np.zeros((460, 640, 3), dtype=np.uint8)

COLOR = (255,0,0)
THICKNESS = 10

cv.ellipse(img, (320, 230), (100, 50), 30, 0, 270, COLOR, THICKNESS, cv.LINE_AA)

cv.imshow("Ellipse", img)

cv.waitKey(0)
cv.destroyAllWindows()
cv.waitKey(1)

▫︎ 사각형 그리기

img = np.zeros((460, 640, 3), dtype=np.uint8)

COLOR = (255,0,0)
THICKNESS = 5

# 속이 비어있는 사각형
cv.rectangle(img, (150, 100), (250, 200), COLOR, THICKNESS, cv.LINE_AA)
# 속이 채워진 사각형
cv.rectangle(img, (300, 100), (400, 200), COLOR, cv.FILLED, cv.LINE_AA)

cv.imshow("Rectangle", img)

cv.waitKey(0)
cv.destroyAllWindows()
cv.waitKey(1)

▫︎ 다각형 그리기 (선)

img = np.zeros((460, 640, 3), dtype=np.uint8)

pts = np.array([[[100,100], [200,100], [100,200]]])
COLOR = (255,255,255)
THICKNESS = 10

cv.polylines(img, pts, True, COLOR, THICKNESS)

cv.imshow("Poltlines", img)

cv.waitKey(0)
cv.destroyAllWindows()
cv.waitKey(1)

▫︎ 다각형 그리기 (채우기)