OpenCV minEnclosingCircle_0
The smallest circle that holds a blob
- points
- literal
- float
minEnclosingCircle_0 answers a tidy geometry question: given a set of points, what's the smallest circle that contains all of them? OpenCV finds it, and hands you the center and the radius. It's the "give me a clean boundary around this thing" node - the circle that tightens around a blob where a rectangle would be wasteful or wrong.
When does that matter in a ComfyUI workflow? The classic case: you've segmented or detected an object and you want a tidy region around it - a circular mask for a subject, a crop that's centered on something, or just a compact "where is this thing and how big" measurement. For roughly circular subjects (a face, a lens, a ball in a frame), the enclosing circle is the honest shape, and the radius gives you a size number you can act on. It's also the natural partner for the pack's circle drawing node: measure here, draw the outline there.
It's part of opencv-comfyui's auto-generated ~635-node surface, and as usual the _0/_1 pair are the same node from two cv2 overloads. Same inputs, same outputs - use whichever.
Inputs and outputs
- points - one
NPARRAY: the set of 2D points, N×2 coordinates. In stock OpenCV these are usually a contour, but this pack skips contour-finding functions (their return types didn't survive generation), so your points come from elsewhere - a mask's coordinates, detected corners, or an array built by another node pack. - Output literal - the center, as a
STRING. It's the repr of OpenCV'sPoint2f, i.e.(center_x, center_y)in tuple text. - Output float - the radius, as an actual number you can wire into arithmetic.
Note the asymmetry: the radius comes out as a real FLOAT (usable), but the center comes out as a string literal (readable, not directly math-able). That's the pack's auto-generation at work - Point2f has no clean node type, so it gets stringified, while float rides through natively.
Setup and gotchas
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or ComfyUI Manager → "opencv-comfyui" → install → restart. Needs opencv-contrib-python, numpy, torch. If another node pack already installed OpenCV, you're usually fine; the conflict signature is Cannot import name 'guidedFilter' from 'cv2.ximgproc'.
The mental model to keep: literal is not an image, not an nparray - don't route it to Nparrays2Image or you'll hit the pack's "not every return type is an image" errors. And be honest about when this node earns its place: for blobs that are genuinely round-ish, the enclosing circle is the right fit. For long, thin objects it's mostly wasted space - that's what minAreaRect_0 is for. Pick the shape that matches your subject, and this node will do the measuring.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| points | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| literal | STRING | — |
| float | FLOAT | — |