Nodes/ComfyUI-ArchiGraph/Find Contours 🐦
ComfyUI Node

Find Contours 🐦

Trace the outlines of everything in a binary image

By vincentfsΒ·Created 2 years agoΒ·Updated 9 months agoΒ· 3
Find Contours 🐦
  • Np_bins
  • contours
  • hierarchy
β—„modeRETR_CCOMPβ–Ί
β—„methodCHAIN_APPROX_SIMPLEβ–Ί

Contour detection is the workhorse of classical computer vision: take a binary image, trace the boundary of every connected region, and get back vector outlines you can measure, filter, or draw. This node wraps OpenCV's findContours and hands you both the contour list and the topology hierarchy. If you're doing plan analysis, floor-plan vectorization, or object measurement in ComfyUI, this is where the geometry gets extracted.

The inputs

  • Np_bins: a binary NPARRAY - non-zero pixels are foreground. The tooltip names the producers: compare, threshold, inRange, Canny, etc. from this pack's OpenCV set. Garbage in, garbage out: a noisy threshold means a thousand spurious contours.
  • mode (default RETR_CCOMP): how contours are organized.
    • RETR_EXTERNAL: only the outermost contours - no holes. Simplest, often all you want.
    • RETR_LIST: all contours, no hierarchy.
    • RETR_CCOMP: two-level hierarchy (outer + holes). The default, and the middle ground.
    • RETR_TREE: full nesting tree. Most information, most confusing.
  • method (default CHAIN_APPROX_SIMPLE): how tightly to store each contour. SIMPLE compresses straight segments to their endpoints (smaller, sufficient for most drawing/measuring); NONE keeps every boundary pixel; the two TC89 options run a compression algorithm.

The outputs

  • contours (CV_CONTOURS): each contour is a vector of points. This is exactly what the pack's Draw Contours node eats - the pairing is point-and-shoot.
  • hierarchy (CV_HIERARCHY): same length as contours; each entry is [next, prev, first child, parent] describing the nesting. Most beginners can ignore it; the moment you want "only the contours inside other contours," this is the map.

The constraint

This node is single-batch only (SINGULAR_ONLY). A batch of images raises a ValueError. The pack is full of these single-image OpenCV nodes - batch, then process one at a time.

Install

ComfyUI Manager β†’ search ComfyUI-ArchiGraph, or:

cd ComfyUI/custom_nodes
git clone https://github.com/vincentfs/ComfyUI-ArchiGraph

Restart and run the pack's install script once. OpenCV is the real dependency; no models to download.

Gotchas

  • It wants binary input. Feeding a raw color photo "works" (it converts to gray) but the contours will be noise.
  • RETR_EXTERNAL + SIMPLE is the beginner-friendly combo for "outlines of the main shapes." TREE is for when you're debugging nested structures and are prepared to think.
  • Pair it with Connected Components With Stats when you care about areas - contours give you geometry, stats give you bounding boxes and sizes.

For classical shape extraction, this is the pack's centerpiece OpenCV node. Feed it a clean binary image and you get the geometry back.

CategoryπŸ¦β€πŸ”₯ ArchiGraph/πŸ“€ OpenCV

Inputs (3)

NameTypeDefaultDescription
Np_binsNPARRAYBinary image. Non-zero pixels are treated as 1's. You can use compare(), threshold(), inRange(), Canny() etc. to create a binary image.
modeCOMBORETR_CCOMPContour retrieval mode
methodCOMBOCHAIN_APPROX_SIMPLEContour approximation method

Outputs (2)

NameTypeDescription
contoursCV_CONTOURSβ€”
hierarchyCV_HIERARCHYβ€”