5. OpenCv_ 그리기 함수
· 배운 것 · 1분 읽기
import numpy as np
import cv2
img = np.full((400, 400, 3), 255, np.uint8)
cv2.line(img, (50,50), (200, 50), (0, 0, 255), 5)
cv2.line(img, (50,60), (150, 160), (0, 0, 128))
cv2.rectangle(img, (50, 200, 150, 100), (0, 255, 0), 2)
#thickness에 -1로 지정하면 내부를 채운다!
cv2.rectangle(img, (70, 220), (180, 280), (0, 128, 0), -1)
cv2.circle(img, (300, 100), 30, (255, 255, 0), -1, cv2.LINE_AA)
cv2.circle(img, (300, 100), 60, (255, 0, 0), 3, cv2.LINE_AA)
pts = np.array([[250, 200], [300, 200], [350, 300], [250, 300]])
cv2.polylines(img, [pts], True, (255, 0, 255), 2)
cv2.imshow("img", img)
cv2.waitKey()
cv2.destroyAllWindows()