draw_polygon
-
Dependencies
- Install
capybara-docsaid[visualization]first.
- Install
-
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 aPolygonobject or a NumPy array in the format [[x1, y1], [x2, y2], ...]. - color (
_Color): Polygon color (BGR). Default is (0, 255, 0). - thickness (
_Thickness): Line thickness. Default is 2. - fillup (
bool): Whether to fill the polygon. Defaults to False. - kwargs: Other parameters.
- img (
-
Returns
- np.ndarray: The image with the polygon drawn on it.
-
Example
from capybara import Polygon, imread
from capybara.vision.visualization.draw import draw_polygon
img = imread('lena.png')
polygon = Polygon([(20, 20), (100, 20), (80, 80), (20, 40)])
polygon_img = draw_polygon(img, polygon, color=(0, 255, 0), thickness=2)