Nodes/opencv-comfyui/OpenCV intersectConvexConvex_1
ComfyUI Node

OpenCV intersectConvexConvex_1

The geometry twin, same overlap math

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV intersectConvexConvex_1
  • p1
  • p2
  • p12
  • float
  • nparray
handleNested

Same story as every _1 in this pack: OpenCV intersectConvexConvex_1 is the identical duplicate of intersectConvexConvex_0. OpenCV's type stubs list cv2.intersectConvexConvex twice (MatLike and UMat), the auto-generator made two nodes, and with real nparrays they behave the same. The _1 suffix is overload numbering, not an advanced mode. Read the _0 article for the mechanics; here's the condensed practical version.

What it does

Takes two convex polygons (each an N×2 NPARRAY of vertices) and returns the area of their intersection plus the polygon describing it. handleNested controls whether a polygon fully inside the other counts its own area or reports zero. It's a geometry/region-math utility - overlap checking between detected shapes, "how much does region A sit in region B" gates.

Inputs and outputs

  • p1, p2 - NPARRAYs, polygon vertices N×2.
  • handleNested - BOOLEAN, nested-polygon handling.
  • p12 - optional NPARRAY out-parameter (returned on the output anyway).
  • Outputs: float (intersection area) and nparray (intersection polygon).

The honest friction

This node is only useful if you have polygon data to feed it, and the pack has a real hole there: findContours was not generated (its stub returns a Sequence type, which the pack's filter dropped). You can't go straight from an image to contours in pure opencv-comfyui. Your options are the pack's own convexHull_0 / approxPolyDP_0 (which output point nparrays) or a scripting node. Both polygons must be convex for the result to be meaningful, so if you're hand-building shapes, isContourConvex_0 is the sanity check to run first.

Installing

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
cd opencv-comfyui
pip install -r requirements.txt

or ComfyUI Manager → "opencv-comfyui". No models; deps are opencv-contrib-python, numpy, torch.

Gotchas

Beyond the findContours gap: the area float is the output worth consuming (threshold on it to gate branches); keep batch_size == 1; and don't switch to this variant expecting something _0 doesn't have - they're interchangeable, so use whichever a shared workflow already uses.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
p1NPARRAY
p2NPARRAY
handleNestedBOOLEAN
p12optNPARRAY

Outputs (2)

NameTypeDescription
floatFLOAT
nparrayNPARRAY