Nodes/opencv-comfyui/OpenCV PCAProject_1
ComfyUI Node

OpenCV PCAProject_1

The duplicate that's identical to PCAProject_0 (and why that's fine)

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV PCAProject_1
  • data
  • mean
  • eigenvectors
  • result
  • nparray

If you searched for this node you almost certainly landed here confused: PCAProject_1 and PCAProject_0 have the same inputs, same outputs, same everything. That's because this pack auto-generates a node per OpenCV function overload, and OpenCV declares cv2.PCAProject twice - once with the MatLike type, once with the UMat type. Two type declarations, two generated nodes, one actual function. _1 is the UMat twin. Pick either; there is no behavioral difference.

So what you're actually getting is cv2.PCAProject, which performs PCA projection: it takes high-dimensional data and maps it into a lower-dimensional subspace defined by the eigenvectors from PCACompute. Per row it computes (data - mean) @ eigenvectors.T, returning one column per eigenvector. It's the "encode" step of a PCA pipeline - compress first, reconstruct later with PCABackProject, and you've got yourself a deterministic, model-free dimensionality reduction (or a denoise, if you drop weak components between the two steps).

The inputs that matter

  • data (NPARRAY) - samples to project, one row each (flattened image patches work).
  • mean, eigenvectors (NPARRAY) - the model from PCACompute_0 / PCACompute2_0. Reuse the same model everywhere, or your projections are meaningless.
  • result (NPARRAY, optional) - OpenCV out-parameter; safe to ignore.

Output: nparray - the projected coefficients, same row count as data.

How to install it

Pack-level install, once:

  • ComfyUI Manager → search opencv-comfyui → Install, restart ComfyUI.
  • Or manually:
cd ComfyUI/custom_nodes
git clone https://github.com/geroldmeisinger/opencv-comfyui

Requires opencv-contrib-python. No models to download.

Common issues & troubleshooting

  • Shapes, shapes, shapes. data's column count must match eigenvectors' row count. error: (-215:Assertion failed) in this pack is almost always a PCA shape mismatch.
  • mean is a hard requirement here even though OpenCV can compute it internally. Feed it a zero vector if you're okay skipping centering, or get the real mean from a PCACompute pass.
  • Don't agonize over _0 vs _1. For most of this pack's functions the numbered twins are interchangeable; the numbering only carries real meaning for things like PCACompute, where _0/_1 (max components) genuinely differ from _2/_3 (retained variance).

Short version: same as PCAProject_0, and that's the whole story.

Categoryimage/OpenCV

Inputs (4)

NameTypeDefaultDescription
dataNPARRAY
meanNPARRAY
eigenvectorsNPARRAY
resultoptNPARRAY

Outputs (1)

NameTypeDescription
nparrayNPARRAY