Nodes/comfyui_cv/CV Draw Contours
ComfyUI Node

CV Draw Contours

Debug helper: draws contours on the image (cv2.drawContours). Two contour sets over one image should differ in 'line_style' as well as color, so the distinction does not depend on hue. Drawing nothing (0 contours) is fine - the image passes through unchanged. The output comes back in the same format as the image input (IMAGE in, IMAGE out; MASK in, MASK out).

By bmad4ever·Created 3 months ago·Updated 2 days ago· 0
CV Draw Contours
  • source
  • contours
  • image
color(0, 255, 0)
thickness2
fillfalse
max_draw0
line_stylesolid
Categoryimage/CV/contours

Inputs (7)

NameTypeDefaultDescription
sourceCOMFY_MATCHTYPE_V3Image or mask to draw on (a copy is made; the input is not modified). 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.
contoursCV_CONTOURSContours to draw, e.g. from 'CV Find Contours'.
colorSTRING(0, 255, 0)Color as a single value (broadcast to all channels) or BGR tuple, e.g. '255' or '(0, 255, 0)'. Shorter tuples are zero-padded; longer tuples are truncated - so on a single-channel MASK canvas a BGR tuple keeps only its BLUE component ('(0, 255, 0)' becomes 0, i.e. draws nothing visible). Use a single value like '255' for a MASK.
thicknessINT21–64Outline width in pixels (ignored when 'fill' is on).
fillBOOLEANfalseFill the contours instead of outlining them.
max_drawINT00–10000Draw at most this many contours (largest first, as sorted by 'CV Find Contours'). 0 = all.
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 'fill' is on.

Outputs (1)

NameTypeDescription
imageCOMFY_MATCHTYPE_V3Same format as the image input.