Nodes/opencv-comfyui/OpenCV ellipse_0
ComfyUI Node

OpenCV ellipse_0

Draw an ellipse (or just an arc) with literal coordinates

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV ellipse_0
  • img
  • nparray
center
axes
angle
startAngle
endAngle
color
thickness
lineType
shift

ellipse_0 is the full-parameter version of OpenCV's ellipse drawing function - the one where you control everything: center, axes, rotation, how much of the arc to draw, color, thickness. It's an annotation/overlay primitive, useful whenever you want to ring something on an image with a mathematically exact ellipse: a face region, a wheel, an object's outline, or a UI-style ring. It's also the node that will teach you to love (or hate) this pack's "everything is a Python literal" design, because the points and colors arrive as strings.

The inputs that matter

  • img - your NPARRAY.
  • center - a STRING literal, (cx, cy).
  • axes - a STRING literal, (a, b), where these are the half-lengths of the ellipse's two axes (the semi-axes), not the full width/height. Classic gotcha: a (100, 50) axes means a 200×100 ellipse.
  • angle - rotation of the whole ellipse in degrees.
  • startAngle, endAngle - degrees around the ellipse. 0 and 360 draw a full ellipse; anything else draws an arc between those angles. This is how you make pie-chart slices or partial rings.
  • color - a STRING literal in BGR (this pack's pipeline is BGR: red is (0, 0, 255)).
  • thickness - stroke width; a negative value fills the ellipse instead of outlining it.
  • lineType - 8 for default, 16 for anti-aliased.
  • shift - subpixel precision shift; leave it at 0.

Single nparray output.

Install

In opencv-comfyui (geroldmeisinger). ComfyUI Manager → search OpenCV, or:

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

Restart. requirements.txt: opencv-contrib-python, numpy, torch. No downloads. _0/_1 are identical overloads.

The traps, spelled out

The literal parsing is the big one. These strings are evaluated with ast.literal_eval, so (250, 250) works and 250, 250 throws the pack's trademark invalid syntax (<unknown>, line 0). Nested literals like (250, 250) are fine - it's the missing parens that kill you. And the BGR color thing will get you at least once: (0, 0, 255) is red here, not blue.

House rules otherwise: images come in through Image2Nparray (RGB→BGR) and out through Nparrays2Image, and only batch_size==1 is supported.

Honest take: if you're drawing lots of ellipses, this is fiddlier than a dedicated drawing pack with proper widgets - the string literals are the pack's compromise for composite types. But inside a cv2 pipeline it's the exact primitive you want, and arcs from startAngle/endAngle are something most UI-oriented annotation packs don't give you.

Categoryimage/OpenCV

Inputs (10)

NameTypeDefaultDescription
imgNPARRAY
centerSTRING
axesSTRING
angleFLOAT
startAngleFLOAT
endAngleFLOAT
colorSTRING
thicknessINT
lineTypeINT
shiftINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY