OpenCV solveLP_2
The cleaner solveLP — same solver, fewer required knobs
- Func
- Constr
- z
- int
- nparray
Of the four solveLP_* nodes this pack ships, this is the one I'd grab. solveLP_2 wraps cv2.solveLP in its (Func, Constr, z) overload - the variant that doesn't force you to supply a constr_eps tolerance you probably didn't care about anyway. It's the lean version of the same simplex-method linear programming solver, and if you've tried the _0/_1 pair and bounced off the extra required float, this is the node that behaves like you'd hope.
Still the same caveat that applies to every node in this family: this is real math in a graph, not image processing. cv2.solveLP solves "minimize cᵀx under linear inequality constraints," returning both a status code and the optimal x. It's a legitimate OpenCV function - the pack just also wrapped it as a node because it wraps everything.
Inputs and outputs
- Func (NPARRAY, required) - the objective row-vector you're minimizing.
- Constr (NPARRAY, required) - the constraint matrix.
- z (NPARRAY, optional) - out-parameter the solver writes the solution into; leave it unwired and read the returned nparray instead.
Outputs are int and nparray: the status (1 = feasible optimum found, 0 = unbounded, -1 = infeasible) and the solution vector.
That's it. Two required inputs, no tolerance knob, one status output you should actually look at. If your status comes back 0 or -1, your problem setup is wrong - the node is fine.
How it differs from the siblings
The _0/_1 pair requires constr_eps; this one doesn't, because it maps to the OpenCV overload where that parameter is optional. The _2/_3 pair are twins of each other, just like _0/_1 are - auto-generated from the duplicated overloads in OpenCV's type stubs. So between solveLP_2 and solveLP_3 there is no meaningful difference; use whichever ComfyUI suggests when you type "solveLP".
The real friction remains the same as the whole family: you need actual nparrays to feed Func and Constr, and the pack has no "type in a matrix" node - you'll be wiring arrays that came out of other cv2 functions or from Image2Nparray. And you can't preview the 1-D solution as an image; Nparrays2Image will complain with 'NoneType' object has no attribute 'shape' because a solution vector isn't an image. For serious LP work, a Python/Execute node is still the more practical tool. This node is the "auto-generated everything" story in one package.
Install
Standard pack install - Manager search "opencv-comfyui", or:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python
Restart ComfyUI. The only real dependency is OpenCV (opencv-contrib-python) plus numpy and torch; no model downloads.
Troubleshooting
- Status
0/-1→ your LP is unbounded or infeasible; fix the constraints, not the node. invalid syntax (<unknown>, line 0)→ the pack'sast.literal_evalparser rejected a literal input - pack-wide error, malformed input on your side.Cannot import name 'guidedFilter'at install → conflicting OpenCV packages; the README has the known fix.
Prefer this variant when you don't need the tolerance knob. Fewer required inputs, same simplex solver underneath.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| Func | NPARRAY | — | |
| Constr | NPARRAY | — | |
| zopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| int | INT | — |
| nparray | NPARRAY | — |