cv2.linemod.colormap
A debug visualiser for LINEMOD's quantised depth bins
- quantized
- nparray
This is the most obscure node in the whole pack and it deserves an honest framing: cv2.linemod.colormap is a debug function. OpenCV's own docstring for it says as much - it exists so the LINEMOD authors could look at a quantised image and see what the algorithm was actually seeing. It takes one input and returns one output. There is nothing to tune.
So if you googled this node, the useful answer is "what is it for, and is it worth my time". It's for looking at depth.
How it works
LINEMOD is OpenCV's rgbd module detector for template-based 6D pose estimation - old-school computer vision for "find this object in this bin", pre-dating every learned approach. Its trick is to quantise depth into discrete bins and then run its templates against those bins rather than against continuous depth values. Binning is what makes the matching robust to sensor noise and to a few millimetres of pose error.
colormap is the human-readable end of that pipeline: hand it the quantised single-channel image and it paints each bin in a colour so you can see the bands as colours instead of as a grey ramp where everything looks like mud. The node's only input is called quantized and it accepts a ComfyUI IMAGE/MASK or an NPARRAY; the output is an NPARRAY.
Practical use in ComfyUI
Two honest uses. First, a real one: if you're doing anything with depth - a depth map from a ControlNet preprocessor, CV Depth to 3D Points output, a disparity map - a colour-binned view is genuinely easier to read than greyscale, and that's what this gives you. Second, the completionist one: you're wiring toward cv2.linemod proper and want to see the intermediate.
If you just want a pretty colour depth map, don't use this. cv2.applyColorMap is in the pack, takes a real colormap enum, echoes your input format, and is the general-purpose tool. This one exists for one narrow thing and the palette is whatever LINEMOD's demos use.
Note the output is an NPARRAY, so to look at it wire Preview CV Array (render: image is fine here) or CV Array → Image, which is also the route to plumbing it into an IMAGE socket.
Installing the pack (read this part)
ComfyUI CV (bmad4ever/comfyui_cv) via ComfyUI Manager - search "comfyui_cv" - or:
cd ComfyUI/custom_nodes
git clone https://github.com/bmad4ever/comfyui_cv
pip install "opencv-contrib-python-headless~=5.0.0.93"
Restart ComfyUI. Python ≥ 3.12, V3-API ComfyUI, no models. But there's a reason this article gets the long install section: this node needs the contrib build, and contrib-ness is the pack's single most common source of "the node isn't in the menu".
Where people get burned
The node is missing from the menu entirely. The pack generates and probes its node registry against whatever cv2 is actually installed, so contrib submodule functions appear only if the installed wheel has them. All four distributions (opencv-python, opencv-python-headless, and their contrib twins) share one site-packages/cv2. Install a non-contrib wheel over a contrib one and the contrib submodules go empty - the nodes just don't register, with no error. Diagnose and repair:
python tools/repair_opencv_contrib.py --check
python tools/repair_opencv_contrib.py --apply
A raw cv2 assertion under a type mismatch. The node passes your array straight through with no cleanliness checks. colormap wants a one-channel quantised image; hand it a BGR picture and you'll get an OpenCV assertion rather than a helpful message. Inspect CV Data tells you the shape and dtype if you're unsure what you're holding.
You're on an older OpenCV. The pack is curated against opencv-contrib-python-headless==5.0.0.93 and says outright that other versions may behave differently. Keep the pinned wheel; CV Build Information will show you what you're actually running, along with whether Eigen, non-free and OpenCL are available in your build.
One more thing worth knowing before you build anything on the linemod group: the pack only wraps top-level callable functions, so LINEMOD's class-based API - the create* factories, the detectors and matchers, the actual pose estimation - is not here, and the README is explicit that it isn't coming. This node is a visualiser, not a doorway into object detection.
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| quantized | NPARRAY,IMAGE,MASK | - - - 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 |
|---|---|---|
| nparray | NPARRAY | — |