Nodes/opencv-comfyui/OpenCV contourArea_1
ComfyUI Node

OpenCV contourArea_1

ContourArea_0 or contourArea_1? Honestly, either

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV contourArea_1
  • contour
  • float
oriented

If you searched for this node you probably already found contourArea_0 and wondered what the _1 variant does differently. Short answer: nothing you'll ever notice. Both nodes are generated from two overloads of cv2.contourArea in OpenCV's Python type definitions - one typed for a regular MatLike array, one for a UMat (OpenCV's GPU-backed array). Because this pack maps every image-ish input to the same NPARRAY socket, both overloads collapsed into identical node code. Same inputs, same float output, same behavior.

So this article is mostly a pointer to its twin. Read contourArea_0 for the full run-down: it takes a contour (NPARRAY, typically the point array from findContours_0) and an oriented boolean, and returns the region's area as a FLOAT. The oriented flag is the one control you might touch - False gives you plain unsigned area, True gives signed area where counterclockwise contours come out positive.

If you're measuring detected regions to filter them - drop anything under a pixel-count threshold before the detailer touches it - this node is the tool. It sits in the "get a mask and act on it" loop that ComfyUI's detection ecosystem is built around, except where the usual detectors give you bounding boxes or SEGS, this is the raw geometry layer under all of it.

Install and the usual dragons

Same as the whole pack: ComfyUI Manager → search opencv-comfyui, or

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-python-contrib

Restart after. No models, no downloads.

The same gotchas apply as everywhere in this pack: feed it nparrays, not IMAGE tensors - go through Image2Nparray first (batch size 1 only), and remember contours are (N, 1, 2) point arrays, not pictures. If you get an assertion error about shape, you handed it an image instead of a contour.

My actual advice: don't agonize over _0 vs _1. They're the same node wearing two names because auto-generating 600+ nodes from type definitions doesn't produce pretty names - the pack's own README calls itself ugly and complex on purpose. If one shows up in a workflow you're reading, wire it as-is. If you're building fresh, use whichever loads first and move on with your life.

Categoryimage/OpenCV

Inputs (2)

NameTypeDefaultDescription
contourNPARRAY
orientedBOOLEAN

Outputs (1)

NameTypeDescription
floatFLOAT