Nodes/opencv-comfyui/OpenCV solveLP_3
ComfyUI Node

OpenCV solveLP_3

SolveLP_3 — the duplicate of the duplicate, and that's fine

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

Here's the whole mystery of this node, solved in one line: solveLP_3 and solveLP_2 are the same node, generated twice. OpenCV's Python bindings declare the constr_eps-less overload of cv2.solveLP twice in slightly different forms, the pack's generator numbered each one, and you ended up with a _2 and a _3 that behave identically. The display name says "OpenCV solveLP_3"; the inputs say "OpenCV solveLP_2". There is no scenario where one of them does something the other can't.

So if you came here from the other page looking for a difference - there isn't one. Use this node or its twin; the result is the same.

What it does, briefly

It's the simplex-method linear programming solver cv2.solveLP in its (Func, Constr, z) form. You give it:

  • Func (NPARRAY, required) - the objective row-vector to minimize.
  • Constr (NPARRAY, required) - the constraint matrix.
  • z (NPARRAY, optional) - out-parameter for the solution; unwired is fine.

Outputs: int (status: 1 = feasible optimum found, 0 = unbounded, -1 = infeasible) and nparray (the solution vector).

The _0/_1 variants add a required constr_eps tolerance; _2/_3 skip it. That's the only real fork in this family, and it's between the pairs, not within them.

The honest truth about this corner of the pack

Every solveLP node shares the same two limitations, and they're worth repeating because they're the reason this is a niche node rather than a daily driver:

  1. Feeding it matrices is awkward. Func and Constr are NPARRAY sockets. The pack can turn an image into an nparray (Image2Nparray) and generate kernels (getGaussianKernel_0, getStructuringElement_0), but there's no "type a matrix here" widget. You're wiring arrays that other nodes produced.
  2. You can't see the answer. A 1-D solution vector isn't an image, and Nparrays2Image will throw 'NoneType' object has no attribute 'shape' at you. The README even lists a "Preview Nparray" node as a to-do item that hasn't shipped.

If you genuinely need LP inside a workflow, a Python/Execute node reading and writing nparrays is the more sensible tool. This node is the pack's auto-generated-everything philosophy on display - charming, occasionally useful, often more trouble than it's worth for real math.

Install

Same as every node in this pack - it's one pack, one install:

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

or via ComfyUI Manager searching "opencv-comfyui". Restart after. Only dependency that matters is OpenCV (opencv-contrib-python), plus numpy and torch. No weights, no models.

Troubleshooting

  • Status 0 or -1 means an unbounded or infeasible LP - your Func/Constr setup is off.
  • invalid syntax (<unknown>, line 0) is the pack's literal parser rejecting a malformed input; it's pack-wide, not this node's fault.
  • Cannot import name 'guidedFilter' from 'cv2.ximgproc' on startup means conflicting OpenCV installs - see the README's linked fix.

If solveLP_2 works for you, this one will too. Same solver, same constraints, same number at the end.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
FuncNPARRAY
ConstrNPARRAY
zoptNPARRAY

Outputs (2)

NameTypeDescription
intINT
nparrayNPARRAY