OpenCV setIdentity_1
The duplicate identity-matrix node, and why the pack has twins
- mtx
- nparray
Straight answer up front: setIdentity_1 and setIdentity_0 are interchangeable. Both call cv2.setIdentity with identical inputs and produce identical output. If you have one in a workflow, the other is a drop-in replacement. The _0/_1 suffix is the pack auto-generator numbering the two overloads it found in OpenCV's type stubs, and in this case the generated nodes came out the same. Not a bug - just what mechanical generation looks like.
The node itself: it fills a matrix with the identity - ones on the diagonal, zeros off it, optionally scaled - and returns it. It's a matrix-construction utility for computer-vision math inside ComfyUI, not an image filter. You'll meet it in workflows that do homographies, calibration, or transform composition, where something needs a clean starting matrix to feed solve or a warp.
Inputs, from the schema:
- mtx - NPARRAY, and here's the thing to get right: it's a matrix, not an image. The NPARRAY type in this pack covers both, and only context tells you which. Feed
setIdentitya photo and every pixel off the diagonal becomes zero. Feed it a small square matrix and it comes out as an identity. - s - STRING, parsed as a Python literal (the pack's convention for composite values). Type a plain
1for the default scale, or a tuple like(1, 1, 1)for multi-channel matrices. No parentheses on a tuple andliteral_evalthrowsinvalid syntax (<unknown>, line 0).
One nparray output: the identity-filled matrix.
Installation is identical to every node in this pack: ComfyUI Manager → search "opencv-comfyui", or git clone https://github.com/geroldmeisinger/opencv-comfyui into ComfyUI/custom_nodes and restart. It needs opencv-contrib-python; numpy and torch are already in ComfyUI. If ComfyUI refuses to start with Cannot import name 'guidedFilter' from 'cv2.ximgproc', a second OpenCV package from another node is fighting yours - uninstall the extra, keep one.
Honest take: you'll probably never touch this node. It exists because the pack faithfully generates every top-level OpenCV function - that's the whole pitch, "all top-level standalone functions of cv2" - and the author's own README warns they're "ugly and complex to use." The identity matrix is a building block that matters in CV math, not in the image-generation flow most ComfyUI users live in. If you're a beginner and it's in your graph, it's there because a transform or calibration chain needs a neutral matrix to start from. Leave it alone, keep the s input as 1, and let it pass the identity through.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| mtx | NPARRAY | — | |
| s | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| nparray | NPARRAY | — |