cv2.transpose
A mirror across the diagonal, not the 90° rotation you meant
- src
- result
cv2.transpose swaps rows and columns. On a matrix that's exactly what you expect. On an image it's a flip across the top-left-to-bottom-right diagonal - a mirror, not a rotation. If you were reaching for "turn this picture 90°", you want cv2.rotate or a warp, and this node will quietly give you the mirrored version instead. It's a one-line distinction that costs people real time.
Where it earns its place is in the data half of a graph. Point arrays have layouts - Nx2 or 2xN - and different cv2 functions insist on different ones. cv2.triangulatePoints wants 2xN. cv2.findFundamentalMat and friends speak a third dialect. When you're chaining array nodes, a transpose is often the entire fix, and it beats rebuilding the array through Parse Matrix.
One of roughly 470 auto-generated raw cv2.* wrappers in ComfyUI CV (bmad4ever/comfyui_cv), LLM-generated and uncurated in the author's own words.
Inputs and outputs
src is type-preserving: link an IMAGE and you get an IMAGE, a MASK gives a MASK, an NPARRAY stays an NPARRAY. That means an image transposition needs no conversion nodes at all - and it means the node is one of the friendlier ones in the low-level set. An IMAGE batch is looped frame by frame and re-stacked, so a clip transposes in one call.
It is not a LATENT-accepting node. cv2's transpose tops out at channel counts a latent doesn't have - 4-channel latents for SD-family models are already at the edge - so the pack deliberately leaves latent handling out of it. If you need to rearrange latent axes, that's CV Permute Axes in the same pack, which was built for exactly this and works on ndarrays of any rank.
The single output is result, echoing whatever you plugged in. No options, no knobs, no flipCode: this node does one thing.
Two use cases that actually come up
Fixing point-array layout. You matched features, you have coordinates, and the next function in the chain wants them transposed. Drop this in, done. It shows up in the pack's own matrix-decomposition workflow (56_matrix_decomposition.json) doing exactly this kind of rearrangement around the SVD and RQ nodes, which is where you'd expect to find it.
Visual or tiling work. Since it echoes the socket type, an IMAGE in transposed output is a legal IMAGE - so it drops between any two image nodes. Flipping a tile sheet, deliberately mirroring a texture, or building a symmetric pattern out of one half.
And the honest warning: for anything a human would call "rotate", use cv2.rotate (which takes a ROTATE_90_CLOCKWISE-style flag) or the pack's curated CV Transform (Rotate/Scale/Shift). A transpose also swaps the image's width and height, which quietly invalidates every coordinate, mask and bounding box you built against the original dimensions - including the imageSize you fed to a stereo node two steps earlier. That's the failure mode: not an error, just a graph that produces plausible nonsense.
Installing the pack
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
cd comfyui_cv && pip install "opencv-contrib-python-headless~=5.0.0.93"
Manager → search ComfyUI CV → install → restart works too. Python ≥ 3.12 and a ComfyUI with the V3 node API are required, or none of these nodes appear. Keep the OpenCV wheel contrib: all four distributions share one site-packages/cv2, so installing plain opencv-python over the contrib build empties the contrib submodules and contrib nodes vanish - tools/repair_opencv_contrib.py --check then --apply is the pack's fix. Behaviour is curated against 5.0.0.93, and support is explicitly not promised.
Watch out for
Expecting a rotation and getting a mirror. Assuming the output has the same dimensions as the input - it has them swapped, and every downstream node that read a size earlier is now wrong. And reaching for this on a latent: the socket won't take one, and CV Permute Axes is the node that will.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| src | COMFY_MATCHTYPE_V3 | input array. The image output(s) echo this input's format. Accepts a ComfyUI IMAGE/MASK directly (frame 0 of a batch) or an NPARRAY. Arithmetic ops (add, multiply, etc.) process the full IMAGE batch when both inputs have the same batch size. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| result | COMFY_MATCHTYPE_V3 | Echoes the 'src' input's format: an IMAGE link comes back as IMAGE, MASK as MASK, NPARRAY stays NPARRAY. |