CV GEMM Flags
The three transpose bits nobody wants to type as integers
- flags
- value
cv2.gemm computes alpha * src1 * src2 + beta * src3. It also takes a flags integer whose bits mean "transpose src1", "transpose src2", "transpose src3", and the raw wrapper in this pack wants that integer as a plain number. This node is the dial for it.
Another flag-builder from bmad4ever's ComfyUI CV (bmad4ever/comfyui_cv, forked from Gerold Meisinger's opencv-comfyui) - the same shape as its FloodFill, Warp, DFT and Threshold siblings: one flags string in, the resolved string plus the integer out.
What's on the dial
flags renders as a base dropdown with the single option none (0) and three independent toggles:
- GEMM_1_T - transpose
src1before multiplying - GEMM_2_T - transpose
src2 - GEMM_3_T - transpose
src3
That's the entire node. Outputs are flags (the pipe-joined string, validated and resolved - a typo errors loudly instead of silently flipping a different bit) and value (the resolved integer, for raw int flag params elsewhere or a MathExpression).
Why the transpose bits exist
Matrix multiplication is not commutative, and the arrays you have are frequently not in the orientation the multiplication needs. A @ B with A shaped (3, N) when the algebra wants (N, 3) is a shape error or a silently wrong result depending on the numbers; the transpose bit is how OpenCV lets you fix it without physically copying the array. If you're multiplying a camera matrix chain, composing a homography with something else, or applying a colour-correction matrix in a graph, this is the knob you'd reach for.
Install
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
Or find ComfyUI CV in ComfyUI Manager. Python ≥ 3.12 and a V3-API ComfyUI.
The honest assessment
Most people will never open this node, and that's fine - no shipped workflow in the pack uses it. It exists because the generated cv2_gemm wrapper has a flags parameter that is unusable without it, and because the pack's flag-builder family is generated from one template, so the marginal cost of covering it was near zero.
If you are doing matrix algebra in ComfyUI, check whether you need cv2.gemm at all before wiring this up: the pack also ships CV Matrix Multiply, which is just left @ right with none of the alpha/beta/transpose ceremony, and CV Eye for an identity matrix. Reach for GEMM only when you actually need the third term or the transposes. And if you're authoring the same flag set for several nodes, that's the point of the family - set it once, fan the string out.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| flags | STRING | none (0) | Pipe-joined cv2 constant names, e.g. "none (0) | GEMM_1_T". In the UI this renders as a base dropdown with one toggle per flag. |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| flags | STRING | The pipe-joined flags string - wire it into the flags input of cv2_gemm nodes. |
| value | INT | The resolved integer (constants OR-ed together). |