OpenCV PCAProject_1
The duplicate that's identical to PCAProject_0 (and why that's fine)
- 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 fromPCACompute_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 matcheigenvectors' row count.error: (-215:Assertion failed)in this pack is almost always a PCA shape mismatch. meanis 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 aPCAComputepass.- Don't agonize over
_0vs_1. For most of this pack's functions the numbered twins are interchangeable; the numbering only carries real meaning for things likePCACompute, where_0/_1(max components) genuinely differ from_2/_3(retained variance).
Short version: same as PCAProject_0, and that's the whole story.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| data | NPARRAY | — | |
| mean | NPARRAY | — | |
| eigenvectors | NPARRAY | — | |
| resultopt | NPARRAY | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |