Nodes/opencv-comfyui/OpenCV minEnclosingCircle_1
ComfyUI Node

OpenCV minEnclosingCircle_1

The circle-measuring node's twin

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV minEnclosingCircle_1
  • points
  • literal
  • float

Same node, other overload - minEnclosingCircle_1 and minEnclosingCircle_0 are identical, generated once per cv2 type-stub overload by the opencv-comfyui pack. There's no meaningful difference between them, so if you're here, what you actually want is the function: given a set of points, find the smallest circle that contains all of them and return its center and radius.

That's a surprisingly useful primitive in a node graph. If you've got a detected or segmented region and you want a compact geometric summary of it - center for cropping, radius for sizing - this is the node. It shines on round-ish subjects: a face, a coin, a lens, a circular label. Measure here, and if you want to visualize it, the pack's circle node can draw the outline back onto the image. It's deterministic and instant, the sort of traditional-CV operation the post-processing layer is supposed to be full of.

Inputs and outputs

  • points - one NPARRAY, N×2 coordinates. These usually come from a contour in vanilla OpenCV, but this pack skips contour-finding functions, so supply points from a mask, corners, or another pack.
  • literal - the center, as a STRING: (center_x, center_y) in tuple text.
  • float - the radius, as a real FLOAT you can plug into math.

The output split is the pack's auto-generation at work: floats ride through natively, Point2f (the center) gets stringified because there's no clean node type for it. So you can do arithmetic on the radius but you'll be reading the center as text - wire it to a string node or just read it from the queue.

Setup

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

or ComfyUI Manager → "opencv-comfyui" → install → restart (opencv-contrib-python, numpy, torch).

Two habits to form: never route the literal center toward Nparrays2Image - it's text, and the pack will happily throw its "not every return type is an image" error at you; and pick the right enclosing shape for your subject. For round blobs the circle is the tight, honest bound. For anything long and skinny, minAreaRect_0 gives you a rectangle that actually fits, and the circle just wastes space. Match the shape to the object and this twin will be all you need.

Categoryimage/OpenCV

Inputs (1)

NameTypeDefaultDescription
pointsNPARRAY

Outputs (2)

NameTypeDescription
literalSTRING
floatFLOAT