Nodes/comfyui_cv/CV Draw Polygon
ComfyUI Node

CV Draw Polygon

Draws a polygon/polyline through the given points (cv2.polylines or cv2.fillPoly) - e.g. a projected object outline or rotated text detection quads. When several outlines share one image, vary 'line_style' as well as the color so they stay tellable apart without relying on hue. Accepts IMAGE or MASK input. When thickness is 0, polygons are filled (useful for creating masks from rotated quads). Multiple polygons: pass an (N, M, 2) array to draw N separate M-point polygons (e.g. the quads output from 'CV EAST Text Detect'). To draw conditionally (e.g. only when 'CV Find Homography' reports found=true), select between this node's output and the original image with a control-flow node such as Basic data handling's 'if/else' - its lazy inputs skip the drawing branch entirely when it is not taken.

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Draw Polygon
  • source
  • points
  • image
color(0, 0, 255)
thickness3
closedtrue
line_stylesolid
Categoryimage/CV/features

Inputs (6)

NameTypeDefaultDescription
sourceCOMFY_MATCHTYPE_V3Image or mask to draw on (a copy is made). Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size.
pointsNPARRAY(N,2) for a single polyline/polygon, or (N,M,2) for N separate M-point polygons (e.g. rotated quads from EAST text detection).
colorSTRING(0, 0, 255)Color as a single value (broadcast to all channels) or BGR tuple, e.g. '255' or '(0, 0, 255)'. Shorter tuples are zero-padded; longer tuples are truncated.
thicknessINT30–64Outline width in pixels. 0 = filled polygons (cv2.fillPoly) - useful for creating masks.
closedBOOLEANtrueConnect the last point back to the first (closed polygon) vs leave it open (polyline). Ignored when thickness=0 (always filled).
line_styleoptCOMBOsolidStroke pattern. Colour alone cannot separate two overlaid line sets for a colour-blind viewer or in greyscale - give the second set a different style and the picture reads without the palette. 'solid' is cv2's own line. Ignored when the polygons are filled (thickness=0, or a MASK canvas).

Outputs (1)

NameTypeDescription
imageCOMFY_MATCHTYPE_V3Same format as the image input.