cv2.eigenNonSymmetric
Real eigenvalues only, and it won't tell you when they aren't
- src
- eigenvalues
- eigenvectors
The sibling of cv2.eigen, for matrices that aren't symmetric. One NPARRAY in, two NPARRAYs out - eigenvalues and eigenvectors - and no third output, no boolean, no warning. That last part is the whole story of this node.
The silent-failure trap
I ran a rotation matrix through it - the classic 2×2 case whose eigenvalues are genuinely imaginary. OpenCV returned a pair of zeros and an eigenvector matrix, and raised nothing. No error, no flag, no NaN. Just zeroes that look like a legitimate answer if you don't know the input should have produced complex values.
That's because the function computes real eigenvalues only; there's no retval here like the symmetric version has, so nothing in the output tells you that the computation fell over. If you're feeding this node matrices you didn't construct yourself, sanity-check the result: zero eigenvalues for a matrix with a non-zero trace is your tell.
What it's for
Non-symmetric matrices show up in a specific kind of work - transition and dynamics matrices, adjacency and flow graphs, anything you'd write a small solver for. In this pack's image-adjacent world the realistic uses are:
- Sanity-checking a matrix you built. You expected symmetry and got something slightly off; comparing this node's answer against
cv2.eigen's tells you whether the asymmetry matters. (It usually does.) - Iterative numerical work. Power iteration, Markov-style weighting, small stability analyses - the maths you do when you're measuring rather than rendering.
- Non-symmetric covariance-like matrices you constructed by hand, where you know the eigenvalues are real because you built the thing.
With a real, non-symmetric example like [[4, 1], [2, 3]] it behaves exactly as advertised: eigenvalues 5 and 2, with the eigenvectors as rows of the output matrix - same convention as cv2.eigen, so don't re-learn the layout.
Inputs and outputs
src must be CV_32FC1 or CV_64FC1 float, and a NPARRAY - the socket takes a matrix, not an image. Use Parse Matrix for a literal, CV Scalar for a constant vector, or the output of cv2.calcCovarMatrix if you're doing statistics, and remember that the last one produces a symmetric matrix, which means you want cv2.eigen instead.
Outputs are eigenvalues and eigenvectors, both NPARRAY. Print them with CV Array To Text - as a table they're readable, and readable is the whole point of a node like this in a graph UI.
Which one do you want?
Nine times out of ten, cv2.eigen. Covariance matrices, structure tensors, Gram matrices, distance matrices derived from squared distances - the symmetric case dominates, and it comes with a success flag as a bonus. Reach for this one when the matrix you're analysing is genuinely not symmetric. If you're not sure, check: symmetrise the matrix, run both, compare. If the answers match, the asymmetry was irrelevant.
Installing the pack
One of ~470 auto-generated raw cv2.* wrappers in bmad4ever/comfyui_cv - GPL-3.0, forked from Gerold Meisinger's opencv-comfyui - plus curated nodes on top. Manager: search ComfyUI CV. Or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
Restart after. Python ≥ 3.12 and a recent ComfyUI built on the V3 node API; sole dependency opencv-contrib-python-headless~=5.0.0.93. Install the contrib wheel: all four OpenCV distributions overwrite the same site-packages/cv2, last one wins, and a non-contrib opencv-python silently strips the contrib submodules and their nodes. tools/repair_opencv_contrib.py --check diagnoses that, --apply repairs it.
Common issues
Zero eigenvalues for a matrix that shouldn't have any. Complex eigenvalues. This function can't represent them and doesn't say so.
(-215:Assertion failed) type == CV_32F || type == CV_64F. You passed an integer matrix. Cast to float.
Eigenvectors look transposed. They're rows, as in cv2.eigen. Transpose the output if you need columns.
Nothing downstream accepts the output. It's an NPARRAY, not an IMAGE, so it feeds data nodes - CV Array To Text, Preview CV Array, or another raw cv2.* wrapper.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| src | NPARRAY | input matrix (CV_32FC1 or CV_64FC1 type). A data array (points / matrix), NOT an image - only an NPARRAY link is accepted here. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| eigenvalues | NPARRAY | — |
| eigenvectors | NPARRAY | — |