OpenCV boxPoints_0
Turn a rotated rectangle into four drawable corners
- points
- nparray
OpenCV has a special rectangle type for the moments when the box around your object isn't axis-aligned: a RotatedRect - center, width/height, and an angle. It's compact and elegant, and it's useless for actually drawing or cropping, because nothing in ComfyUI consumes a RotatedRect directly. OpenCV boxPoints_0 fixes that: it takes the rotated-rect description and expands it into the four actual corner points as an (N, 2) array. If you've ever gotten a minAreaRect-style angled box and wondered how to draw it, this is the missing piece.
The classic pairing: something (a detector, minAreaRect, your own geometry) says "the box is centered at (x,y), is W×H, tilted by θ degrees" - feed that as the box string, and boxPoints hands you the four corner coordinates, which you can then plot, mask around, or run through boundingRect to get the axis-aligned bounds of the tilted box. That last move - rotated box → corners → tight upright rectangle - is the workflow this node exists for in ComfyUI, because every crop node wants an upright box.
Inputs
- box - a STRING, and this is the pack's literal-parsing quirk in full effect. You type the RotatedRect as a Python tuple:
((250, 250), (200, 100), 30). That's center(x, y), size(width, height), then the angle in degrees. The node parses it with a literal evaluator, so the syntax has to be valid Python - wrong shape throwsinvalid syntax (<unknown>, line 0). - points (optional) - an
NPARRAYout-parameter (pre-allocated output buffer). Leave it unwired and OpenCV allocates the result.
Output: one nparray - shape (4, 2), float32: the four corner points of the rectangle, ordered around the perimeter. Convert with Nparrays2Image if you want to draw them onto a frame.
Install and gotchas
ComfyUI Manager → opencv-comfyui, or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Needs opencv-contrib-python.
The traps are the two usual pack ones plus one specific: batch size 1, NPARRAY conventions, and getting the box string format right. The angle is in degrees (not radians - a classic OpenCV footgun), and the center/size/angle order is strict: center first, size second, angle last. And note there's no minAreaRect equivalent in this pack's node list - the generator didn't ship one, so boxPoints tends to be fed from values you compute or hardcode, which makes it more of a geometry utility than a detector companion. Still, when you need four corner coordinates from a rotated box, it's the cleanest single node around.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| box | STRING | — | |
| pointsopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |