Nodes/opencv-comfyui/OpenCV CV_64FC_0
ComfyUI Node

OpenCV CV_64FC_0

The Type-Code Calculator for OpenCV's Float Images

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV CV_64FC_0
    • int
    channels

    OpenCV CV_64FC_0 is the double-precision member of this pack's family of type-code helper nodes. Give it a channels count, get back the packed cv2 type constant for a 64-bit float image. CV_64FC(1) returns 6, CV_64FC(3) returns 22. That's the whole job, and it's a job you mostly won't need.

    It comes from geroldmeisinger/opencv-comfyui, a pack that auto-generates a ComfyUI node for every top-level standalone cv2 function - about 635 of them. The README is refreshingly honest: the nodes are "ugly and complex to use" and you should expect dragons. CV_64FC_0 is one of the plainest, because all it does is wrap cv2.CV_64FC(channels).

    What the number means

    OpenCV encodes an image's data type into a single integer: depth + (channels - 1) * 8, where CV_64F (double-precision float) is depth 6. So CV_64FC(1) = 6, CV_64FC(2) = 14, CV_64FC(3) = 22. The _C in the name stands for "channels" - the depth is baked in.

    Where this gets real for you: many OpenCV operations that produce fractional results - transforms, distance fields, calibration matrices, and the dct/decompose* nodes elsewhere in this pack - hand back float64 arrays. ComfyUI's own images are float32 tensors scaled 0–1, so the two worlds disagree by design. That's why the pack's conversion nodes (Image2NparrayNparrays2Image) exist and why you'll occasionally see a float64 nparray that refuses to behave like a picture. If a function needs a target type constant, CV_64FC_0 is how you build it.

    Inputs and outputs

    • channels (INT) - the channel count: 1 for scalar/grayscale data, 3 for color.
    • int (INT, output) - the packed type code, ready to feed a downstream node's type parameter.

    Install and first run

    ComfyUI Manager can install it by searching opencv-comfyui; otherwise:

    cd ComfyUI/custom_nodes
    git clone https://github.com/geroldmeisinger/opencv-comfyui
    pip install opencv-contrib-python
    

    Restart ComfyUI afterwards. No models, no weights - just numpy, torch, and the OpenCV contrib build that the requirements.txt pins (note: the README's pip install opencv-python-contrib is the wrong name; the real package is opencv-contrib-python).

    Where people trip

    The most common failure with this node family isn't the node itself - it's treating every nparray like a viewable image. The pack README's Nparrays2Image error - 'NoneType' object has no attribute 'shape' - happens exactly when you feed it a float vector or matrix that was never meant to be pixels. A float64 type code is often the smell: if the values aren't in 0–255 uint8 territory, it's not a picture, it's data. Check what the OpenCV function actually returns before wiring it to an image preview.

    And the _0/_1 suffix thing again: cv2's Python stubs declare most functions twice (once for MatLike, once for UMat), and the code generator dutifully makes a node per overload. They behave identically here, so don't agonize over which variant you drop in.

    Categoryimage/OpenCV

    Inputs (1)

    NameTypeDefaultDescription
    channelsINT

    Outputs (1)

    NameTypeDescription
    intINT