OpenCV solveCubic_1
The twin cubic-root node and the 'not every nparray is an image' trap
- coeffs
- roots
- int
- nparray
solveCubic_1 finds the real roots of a cubic equation, and it's a duplicate: solveCubic_0 does exactly the same thing with the same inputs and outputs. Both wrap cv2.solveCubic; the _1 is just the pack's auto-generator numbering a second overload that turned out identical. Pick either, delete the other. The more interesting thing about this node is the trap it teaches you about the whole pack.
The function itself: give it the coefficients of a·x³ + b·x² + c·x + d = 0, get back the real roots. Inputs:
- coeffs - NPARRAY. Four elements
[a, b, c, d], or three elements[b, c, d]with the leading coefficient assumed to be 1. - Optional roots - the out-parameter; leave it unconnected.
Outputs:
- int - the number of real roots (1 to 3 for a cubic).
- nparray - the roots, padded with non-roots when fewer than 3 real ones exist. Check the
intoutput before trusting the array.
Now the trap, and it's worth internalizing because it applies to half the pack: the nparray output here is a 1-D array of numbers, not an image. This pack's NPARRAY type is overloaded - sometimes it holds BGR pixels, sometimes it holds math results. The README calls this out explicitly: not every nparray is an image, and feeding a root array into Nparrays2Image gives you 'NoneType' object has no attribute 'shape' or garbage pixels. If you're building a workflow that computes roots and then wants to see something, you need to convert the numbers into something visual yourself - that's on you, not the node.
When would you use this? Cubic roots appear in geometry and calibration math - camera pose, ray/surface intersection, certain fitting problems - so this is a building block for custom CV pipelines, not a tool for generation. If you don't do that kind of math in ComfyUI, you'll never need it. It exists because the pack's whole premise is "every top-level cv2 function, wrapped," and the author's own framing is that some of these are ugly and not obviously useful in a node graph.
Installation is the same everywhere in this pack: ComfyUI Manager → search "opencv-comfyui", or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Requirements are opencv-contrib-python, numpy, torch - you already have the last two. The known startup failure is Cannot import name 'guidedFilter' from 'cv2.ximgproc', caused by two conflicting OpenCV installs; uninstall the duplicate.
So, summing up this node in one line: use solveCubic_0 or solveCubic_1, doesn't matter which - just never forget that its output is math to feed other nodes, not a picture to preview.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| coeffs | NPARRAY | — | |
| rootsopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| nparray | NPARRAY | — |