Nodes/opencv-comfyui/OpenCV eigen_1
ComfyUI Node

OpenCV eigen_1

The second eigen overload — symmetric matrices only, same answer

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV eigen_1
  • src
  • eigenvalues
  • eigenvectors
  • bool
  • nparray_1
  • nparray_2

Same song as every _1 in this pack: eigen_1 is the second overload of cv2.eigen - one declaration for MatLike, one for UMat - and the generated nodes are interchangeable. What's actually worth talking about is whether you should touch the function at all, because cv2.eigen is pure linear algebra with zero image involvement: give it a square symmetric matrix, get back its eigenvalues and eigenvectors.

The function, unpacked

The node's inputs are src (the matrix, as an NPARRAY) plus optional eigenvalues/eigenvectors, which are the function's out-parameters - skip them, as with every out-param in this pack. Its three outputs are bool (did the computation succeed), nparray_1 (eigenvalues), and nparray_2 (eigenvectors, one per row). OpenCV sorts the eigenvalues in descending order, which is convenient if you're doing the classic "grab the top few" dimensionality-reduction dance.

Why you might (or might not) want it

If your ComfyUI graph is doing anything where a covariance or correlation matrix shows up as an NPARRAY - feature analysis, PCA-ish steps, stability checks - eigen is a real building block. If it isn't, this node will sit unused forever, and the pack's own README already told you that some of these functions "are not useful within ComfyUI without further processing." eigen is near the top of that list.

One genuinely important caveat: cv2.eigen is documented for symmetric matrices. If you feed it a non-symmetric one, the results are not what you want - OpenCV's sibling eigenNonSymmetric exists for that case (also in this pack). Routing an actual image through here is the other classic misuse: an Image2Nparray output is a pixel array, and its eigen-decomposition is numbers about pixels, not an image operation.

Install

opencv-comfyui (geroldmeisinger). ComfyUI Manager → search OpenCV, or:

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

Restart. requirements.txt: opencv-contrib-python, numpy, torch. No models.

Bottom line: _0 or _1, doesn't matter - both are fine wrappers of a math function. Know what a symmetric matrix is before you wire this up, or you'll be debugging numbers you don't understand.

Categoryimage/OpenCV

Inputs (3)

NameTypeDefaultDescription
srcNPARRAY
eigenvaluesoptNPARRAY
eigenvectorsoptNPARRAY

Outputs (3)

NameTypeDescription
boolBOOLEAN
nparray_1NPARRAY
nparray_2NPARRAY