Nodes/ComfyUI CV/cv2.CV_32UC
ComfyUI Node

cv2.CV_32UC

Unsigned 32-bit, the newest and least useful type code here

By bmad4ever·Created 4 months ago·Updated 14 days ago· 1
cv2.CV_32UC
    • int
    ◄channels0►

    cv2.CV_32UC builds the unsigned-32-bit type code. In the ComfyUI CV pack it's a node with an INT widget (channels) and an INT output (int), wrapping the CV_32UC(channels) macro - one of the depths that only newer OpenCV builds expose at all. If it isn't in your node list, your cv2 doesn't have it: the pack's registry is generated against whatever OpenCV you installed and entries the build lacks are skipped silently.

    I'll be straight with you: of the eight constant nodes in this set, this is the one you're least likely to use. The useful ones are cv2.CV_32FC (a float depth for derivative filters - see below) and cv2.CV_16SC (CV_16SC2, the fixed-point remap map type). The 64-bit and unsigned-32 depths exist because OpenCV's type system grew to cover data that isn't pixels, and the pack exposes every top-level function and constant it can parse. That's the pack's stated design, not a complaint: the author's README says the ~470 raw wrappers are auto-generated and uncurated, and that a generator can't tell which of them anyone wants.

    What it means and where it can matter

    Type codes pack depth and channel count into one integer - depth + ((channels − 1) << 3) - so a "type" here is just a small int identifying both things at once. Unsigned 32-bit is the depth for counts and identifiers that need more than 16 bits of positivity: pixel totals, histogram accumulations, large component indices, anything you'd naturally hold in a numpy uint32. In a ComfyUI pipeline that means data-management work rather than image processing, and it will live entirely in NPARRAY space, because ComfyUI's IMAGE socket is a 3-channel float32 tensor and has nowhere to put a uint32.

    Hand it to a wrapper's dtype parameter (after converting that widget to an input - right-click → Convert widget to input) when you want an operation's result to keep an unsigned-32 type, and check the node you're feeding actually implements that path. Integer depths beyond 8 and 16 bits have narrower coverage in OpenCV's kernels than the float ones do, so a surprising "unsupported type" is a real possibility rather than a user error.

    Two cautions carry over from every other code builder. The channels widget defaults to 0, and the macro subtracts one from it, so a zero yields a negative nonsense code - set 1. And this node converts nothing: CV Cast Array changes an array's dtype, CV DType reports one as a STRING, and cv2.CV_32UC only produces the integer.

    A sanity check on all eight of these nodes

    The way to know these are the real thing rather than a novelty: they're mechanically derived from the same macro family you see in cv2.CV_8UC(3)-style constants in every OpenCV program, and their output is exactly the value the corresponding cv2 parameter expects. If you want to confirm the mapping on your install:

    python -c "import cv2; print(cv2.CV_32FC(1), cv2.CV_32FC(3), cv2.CV_16SC(2))"
    

    Expect 5, 21 and 11 on a standard build - depth code plus 8 per extra channel. That's the arithmetic this node performs, and it's why CV_32FC(1) is literally the same number as CV_32F.

    Installing it

    Manager → search the pack title (ComfyUI CV) → install → restart. Manual route:

    cd ComfyUI/custom_nodes
    git clone https://github.com/bmad4ever/comfyui_cv
    pip install "opencv-contrib-python-headless~=5.0.0.93"
    

    Python ≥ 3.12 and a ComfyUI built on the V3 node API. This node is curated against OpenCV 5.0.0.93, so if you're on an older OpenCV most of the 64-bit and unsigned depths won't be there (and neither will the 5.0-only functions). Keep the contrib wheel: a plain opencv-python installed on top of it empties the contrib submodules from the shared site-packages/cv2 and takes nodes with it - tools/repair_opencv_contrib.py --check then --apply.

    Common issues and troubleshooting

    Negative output. channels = 0. Set it to 1.

    The output won't wire anywhere. Convert the destination widget to an input first; this node emits a plain INT intended for a numeric socket, not an image.

    "Unsupported type" from a downstream cv2 node. Integer depths above 16 bits have thinner kernel coverage. Cast down to a supported depth (CV Cast Array) or do the work in CV_32FC and cast at the end.

    The node is missing. Your OpenCV build doesn't expose this constant; the pack skips entries the build lacks. Nothing is broken.

    Categoryimage/CV/low-level/cv2 C

    Inputs (1)

    NameTypeDefaultDescription
    channelsINT0-2147483648–2147483647 - - -

    Outputs (1)

    NameTypeDescription
    intINT—