Nodes/opencv-comfyui/OpenCV solveLP_1
ComfyUI Node

OpenCV solveLP_1

SolveLP_1 — the same LP solver, one overload over

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV solveLP_1
  • Func
  • Constr
  • z
  • int
  • nparray
constr_eps

If you've landed here after trying solveLP_0, good news: this is the same node, and there's nothing you're missing. solveLP_1 is the twin generated from the other overload of cv2.solveLP. Because OpenCV's C++ bindings declare the same function with a couple of different signatures, the pack's generator - which parses the type stubs and numbers every overload - produced solveLP_0 and solveLP_1 for the identical (Func, Constr, constr_eps, z) variant, plus solveLP_2/solveLP_3 for the constr_eps-less variant. In practice, the _0 and _1 nodes behave identically. Pick whichever, wire the same way.

For the full explanation of what cv2.solveLP actually computes, read the solveLP_0 article - this page is the "it's the same, here's the difference" version, which is worth having because the numbering confuses people more than the math does.

What you're looking at

The inputs are exactly what solveLP_0 has:

  • Func (NPARRAY, required) - the objective row-vector you're minimizing over.
  • Constr (NPARRAY, required) - the constraint matrix.
  • constr_eps (FLOAT, required) - feasibility tolerance.
  • z (NPARRAY, optional) - out-parameter for the solution; leave it unwired.

Outputs: int (the solver status: 1 = solved, 0 = unbounded, -1 = infeasible) and nparray (the solution vector).

So yes - solveLP_1 and solveLP_0 are the same node under two class names, and the schema in ComfyUI is byte-for-byte identical. That's not a bug; it's what happens when you auto-generate nodes from every C++ overload without deduplicating them. Don't overthink which to use.

The part that's actually worth knowing

This pair (_0/_1) includes the constr_eps input as required; the solveLP_2/solveLP_3 pair omits it entirely, which maps to the OpenCV overload that defaults it. If you don't care about the tolerance, the _2 variant is the less-cluttered node. Otherwise, they're interchangeable.

The rest of the honest friction from solveLP_0 applies identically here: you need nparrays from somewhere (there's no "type in a matrix" widget), and you can't preview a solution vector as an image without hitting the pack's 'NoneType' object has no attribute 'shape' error. For real LP work, a Python node is usually more practical. This is a "the pack wrapped everything" node, not a daily driver.

Install

Pack-level, same as always:

cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui
pip install opencv-contrib-python

Restart, then search the node by its display name "OpenCV solveLP_1" (or install via ComfyUI Manager by searching "opencv-comfyui"). No models, no weights - just OpenCV (opencv-contrib-python), numpy and torch.

Troubleshooting

  • Status 0 or -1 out of the int output means your LP is unbounded or infeasible - check Func and Constr.
  • invalid syntax (<unknown>, line 0) on any literal input is the pack's ast.literal_eval parser complaining; that message is pack-wide, not node-specific.
  • If install dies with Cannot import name 'guidedFilter' from 'cv2.ximgproc', you have conflicting OpenCV installs - the README links the known fix.

Bottom line: if you got solveLP_0 working, you already know how to use this one. The numbering is noise; the math is the same.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
FuncNPARRAY
ConstrNPARRAY
constr_epsFLOAT
zoptNPARRAY

Outputs (2)

NameTypeDescription
intINT
nparrayNPARRAY