OpenCV isContourConvex_0
One boolean about your contour
- contour
- bool
OpenCV isContourConvex_0 is the simplest node in this pack: it takes one contour, asks "is this shape convex?", and outputs a single boolean. That's it. cv2.isContourConvex wrapped and returned. No knobs, no options - one NPARRAY in, one True/False out.
Convexity is one of those quiet properties that decides whether a bunch of other OpenCV operations even make sense. intersectConvexConvex_0 (this pack) assumes convex inputs and returns garbage otherwise; convexityDefects_0 only finds "dents" in concave shapes by comparing a contour against its convex hull; a whole family of collision and fitting routines have convex-only fast paths. So isContourConvex_0 is the gatekeeper: check a contour's convexity before you trust the results of anything that depends on it.
In a real ComfyUI workflow, though, be realistic about your odds of needing this. The pack cannot produce contours from an image - findContours wasn't auto-generated (its stub returns a Sequence type the generator skipped) - so the contour NPARRAY has to come from a scripting node, a SAM/segmentation mask's boundary, or the pack's own geometry nodes like convexHull_0 / approxPolyDP_0. If you're not already passing point arrays around your graph, this node has nothing to chew on.
How it works
cv2.isContourConvex(contour) tests whether the polygon described by the contour's vertices is convex - every interior angle ≤ 180°, equivalently no self-intersection and a single consistent turning direction along the boundary. It's a cheap, deterministic geometric test: a handful of cross-products, no iteration over pixels.
Inputs and outputs
contour- NPARRAY of contour points (N×2).- Output
bool- BOOLEAN,Trueif the contour is convex.
Use the boolean as a gate in front of a geometry node (e.g., feed it into a switch or conditional so convex contours take one path and concave take another), or as a diagnostic to debug why an intersectConvexConvex result looks wrong.
Installing
From opencv-comfyui:
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
The contour-provenance problem is the real friction - remember there's no findContours here, so get your point arrays from elsewhere. Also note that "convex" here is about the geometry, not about image brightness or color; don't feed it a mask image and expect a meaningful answer. And isContourConvex_0 vs _1 are identical overload duplicates - the _1 has nothing extra.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| contour | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |