Nodes/opencv-comfyui/OpenCV ellipse_2
ComfyUI Node

OpenCV ellipse_2

Draw a rotated bounding box as an ellipse — the detection visualizer

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV ellipse_2
  • img
  • nparray
box
color
thickness
lineType

ellipse_2 is the friendlier sibling in this pack's ellipse family. Instead of seven geometry inputs, it takes one RotatedRect - the ((center), (size), angle) package that OpenCV's own fitting functions produce - and draws the ellipse it describes. If you're visualizing detections with rotated bounding boxes, this is the node: feed it a fitEllipse or minAreaRect result and it draws the exact ellipse those functions fitted.

The inputs

  • img - your NPARRAY.
  • box - a STRING literal in RotatedRect form: ((cx, cy), (w, h), angle). The center, the full width and height of the rectangle the ellipse fits inside, and the rotation in degrees. Note the nesting - that's a triple-nested literal, and it's exactly where the pack's ast.literal_eval parsing tends to break people's syntax.
  • color - a STRING literal in BGR ((0, 0, 255) is red here).
  • thickness - negative fills.
  • lineType - 8 or 16 (anti-aliased).

Single nparray output.

The practical difference from ellipse_0: there you hand-write center, axes, angles; here you hand over a single fitted rectangle. In a real workflow the box string will usually come from a node that computes RotatedRect-style output - or you'll construct it by hand from detection data. Either way, it's one value instead of three, and it's the natural way to draw what a detector found.

Install

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. _2/_3 are the identical overload pair here - same story as every _0/_1, just different numbers because cv2.ellipse has two distinct signatures in the stubs (full-params and RotatedRect), and each got its own overload pair.

The gotchas

The box literal must be valid Python: ((100, 100), (60, 40), 30) works, a stray brace or missing paren throws invalid syntax (<unknown>, line 0). And remember the whole pack is BGR - your colors will be backwards until you internalize that red is (0, 0, 255). House rules: in via Image2Nparray, out via Nparrays2Image, batch_size==1 only.

Verdict: this is the ellipse node you'll reach for in a detection-visualization workflow. The full-param version is for drawing by hand; this one is for drawing what the math found.

Categoryimage/OpenCV

Inputs (5)

NameTypeDefaultDescription
imgNPARRAY
boxSTRING
colorSTRING
thicknessINT
lineTypeINT

Outputs (1)

NameTypeDescription
nparrayNPARRAY