OpenCV solve_0
Solve a linear system inside your ComfyUI graph
- src1
- src2
- dst
- bool
- nparray
solve_0 solves a system of linear equations: given src1 (a matrix of coefficients) and src2 (a right-hand side), it returns the x that satisfies src1 · x = src2, plus a boolean telling you whether it actually succeeded. It's cv2.solve wrapped as a node, and it's the kind of node that makes people who build image-generation workflows blink - but it's genuinely the workhorse underneath a lot of computer-vision math.
Where it earns its keep: homography and affine estimation, camera calibration, geometric transforms. If you're building a workflow that computes a perspective warp from point correspondences, or fitting a transform to matching keypoints, at some point you're solving a linear system - and that's this node. It's the "give me the transform parameters" step, and it sits naturally next to the pack's getPerspectiveTransform and findHomography family.
The mechanism is OpenCV's dense linear solver, with a choice of decomposition picked by flags. The outputs are the important part here, because they're a tuple:
- bool - whether the system was solvable. This is your canary:
falsemeans singular or near-singular coefficients, i.e. your point correspondences are degenerate (collinear points, for instance) and the transform you computed is garbage. - nparray - the solution
x.
Inputs:
- src1 - NPARRAY, the coefficient matrix (typically
n×nfor a square system, orn×mfor over-determined). - src2 - NPARRAY, the right-hand side.
- flags - INT, the decomposition method.
0isDECOMP_LU(square systems),1isDECOMP_SVD(works for singular/degenerate systems, slower),4isDECOMP_QR. For least-squares fits of over-determined systems, combine16(DECOMP_NORMAL) with one of the above. Beginners: start with0; switch to1if you getfalsereturns. - Optional dst - the OpenCV out-parameter; leave it unconnected.
A wrinkle worth knowing: the inputs are NPARRAYs, and - same as setIdentity - these are matrices, not images. The pack's NPARRAY type serves both, and context tells you which. Don't feed this node a photo and expect a useful x.
And yes, solve_1 is the twin overload: same inputs, same behavior, both call cv2.solve. The auto-generator numbered the overloads and didn't dedupe them. Pick one and be consistent.
Install: ComfyUI Manager → search "opencv-comfyui", or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes, restart. Requirements: opencv-contrib-python, numpy, torch. If ComfyUI won't start with Cannot import name 'guidedFilter' from 'cv2.ximgproc', you have two conflicting OpenCV installs - uninstall one.
Honest take for most users: you'll rarely touch this node, and that's fine - it's a tool for the geometry and calibration corner of the ecosystem, not for day-to-day generation. But when a workflow needs a transform computed from data rather than hand-wired, this is the node that does it, and knowing what the bool output means is the difference between silent garbage and a solvable bug.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| src1 | NPARRAY | — | |
| src2 | NPARRAY | — | |
| flags | INT | — | |
| dstopt | NPARRAY | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| bool | BOOLEAN | — |
| nparray | NPARRAY | — |