draw_polygon
-
Description: Draws a polygon on an image.
-
Parameters:
- img (
np.ndarray
): The image to draw on, as a NumPy array. - polygon (
Union[Polygon, np.ndarray]
): The polygon to draw, either as aPolygon
object or a NumPy array in the format [[x1, y1], [x2, y2], ...]. - color (
_Color
): The color of the polygon. Defaults to (0, 255, 0) (green). - thickness (
_Thickness
): The thickness of the polygon's border. Defaults to 2. - fillup (
bool
): Whether to fill the polygon. Defaults to False. - kwargs: Other parameters.
- img (
-
Return Value:
- np.ndarray: The image with the polygon drawn on it.
-
Example:
import capybara as cb
img = cb.imread('lena.png')
polygon = cb.Polygon([(20, 20), (100, 20), (80, 80), (20, 40)])
polygon_img = cb.draw_polygon(img, polygon, color=(0, 255, 0), thickness=2)