OpenCV minEnclosingTriangle_1
The tightest triangle around your points
- points
- triangle
- float
- nparray
First, the freebie: minEnclosingTriangle_1 and minEnclosingTriangle_0 are the same node. opencv-comfyui emits one node per cv2 overload, cv2.minEnclosingTriangle has two, and you got both. Nothing about the _1 is different or better. Pick it and move on.
What the function does: compute the minimum-area triangle that encloses a set of 2D points, and return its area plus its three vertices. It's the third shape in OpenCV's enclosing-family (after the rotated rectangle and the circle), and it earns its keep specifically when a point cluster is wedge-shaped - a triangular region where a rectangle would be half empty and a circle would be worse.
In a ComfyUI graph this is a specialist's tool, and it's worth saying plainly: most people never need it. The rectangle and circle nodes handle the common "bound the blob" jobs, and they're easier to reason about. Where the triangle pulls ahead: compact hull measurements - you want the smallest polygon with exactly three sides that still contains your points, and the area as a rotation-independent size metric. The vertices are also what you'd feed to the pack's polygon drawing nodes if you want the triangle drawn back over the image.
Inputs and outputs
- points - one
NPARRAY, N×2 coordinates. The pack skips contour-finding functions, so points have to come from a mask, corners, or another node pack rather thanfindContours. - triangle - optional; leave it empty. Out-parameter, same rule as
dst. - float - the area of the minimum enclosing triangle, a real number for your math chain.
- nparray - the triangle's three vertices. It's an array, but it is not an image. Routing it to
Nparrays2Imageis how you meet the pack's'NoneType' object has no attribute 'shape'error - the README calls this out specifically: not every nparray return is a picture.
Setup
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
or ComfyUI Manager → "opencv-comfyui" → install → restart. Dependencies: opencv-contrib-python, numpy, torch. The standard conflict to watch for is Cannot import name 'guidedFilter' from 'cv2.ximgproc' when another custom node disagrees about the OpenCV install.
Bottom line: reach for this one when a wedge-shaped point cluster makes the rectangle and circle look silly. It returns a useful area float and a vertex array that's for geometry, not pictures - keep those two facts straight and there's nothing else to trip on.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| points | NPARRAY | — | |
| triangleopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| float | FLOAT | — |
| nparray | NPARRAY | — |