이 프로그램에서는 opencv 함수인 fillPoly()를 사용하여 채워진 다각형을 그립니다. 이 함수는 이미지와 다각형의 끝점을 가져옵니다.
알고리즘
Step 1: Import cv2 and numpy. Step 2: Define the endpoints. Step 3: Define the image using zeros. Step 4: Draw the polygon using the fillpoly() function. Step 5: Display the output.
예시 코드
import cv2
import numpy as np
contours = np.array([[50,50], [50,150], [150,150], [150,50]])
image = np.zeros((200,200))
cv2.fillPoly(image, pts = [contours], color =(255,255,255))
cv2.imshow("filledPolygon", image) 출력
