cv2.detail.createWeightMap
The stitcher's feathering weights, exposed
- mask
- weight
- nparray
This one is a look inside the panorama stitcher. When OpenCV blends warped frames together, each frame gets a weight map built from the mask of pixels it actually contributed - full weight in the middle of the frame, tapering to nothing at the edges - and the blend is a weighted average across all of them. cv2.detail.createWeightMap is the function that turns a mask into that map, and this pack's wrapper generator found it and wrapped it.
What it's doing in the pipeline
The stitcher's job, once warping and seam-finding are done, is to composite several overlapping frames into one canvas. Do that with a hard cut and you get a visible seam line; do it with a naive average and moving objects smear into ghosts. The standard fix is feathering: build a per-frame weight that's high where the frame has good data and falls off near its borders, accumulate image × weight and the weights themselves per pixel, then divide one by the other at the end. That's why these functions come in pairs in this pack - createWeightMap on the way in, and cv2.detail.normalizeUsingWeightMap for the division on the way out.
sharpness is the knob that decides how steeply the weight ramps: a soft value spreads the blend over a wide band (smoother, more chance of ghosting), a sharper one concentrates the transition near where the frame is most central.
Inputs and output, as this node declares them
There are three inputs: mask (the frame's valid region - an NPARRAY, or an IMAGE/MASK linked directly), sharpness (a FLOAT), and weight, an image-ish input. That third one looks odd for an "input" and it is: cv2's signature takes the weight map as an InputOutputArray - the caller supplies the buffer and OpenCV writes into it - so in Python it surfaces as an argument you pass rather than a return value, and the pack exposes it as a socket because that's how the argument appears. The node declares one NPARRAY output.
Be aware that this is exactly the kind of wrapper the pack is honest about: the low-level cv2.* nodes are auto-generated and uncurated, and for the stitching internals OpenCV ships essentially no parameter documentation - which is why the tooltips in this node's UI read as blank placeholder text rather than the useful explanations the curated nodes have.
Should you use it?
Almost certainly not directly. If you want a panorama, use CV Stitch or CV Stitch (Advanced) from the same pack (the advanced one exposes the estimator and blender knobs) and let the blender do the weighting internally. Nobody assembles a stitcher by hand because they enjoy debugging weight maps.
Where it's worth opening is when you're building your own blend - a manual two-image composite where you want a soft transition and you'd rather compute a proper feathering weight than fake it with a blur on a mask. Even then, in ComfyUI the mask domain is usually the easier place to work: a mask plus FeatherMask-style blur gets you 90% of the way with far less fuss. This node is for the case where you want the result to be exactly what OpenCV's blender would produce, or where you're studying how the stitching pipeline actually works. If you're in that second camp, this node and its three siblings in the image/CV/low-level/detail folder are a decent guided tour of the module's internals.
Install
Manager → Install Custom Nodes → ComfyUI CV (publisher bmad4ever), 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 and a recent V3-API ComfyUI are required. The contrib headless OpenCV wheel is the only dependency, and this node needs no model whatsoever. If the neighbouring cv2.detail.* nodes are missing from your menu entirely, the pack resolves every generated wrapper against your installed cv2 at import time and silently drops what isn't there - a plain opencv-python install over the contrib build is the usual cause (python tools/repair_opencv_contrib.py --check, then --apply). The pack is GPL-3.0, a fork of geroldmeisinger/opencv-comfyui, written with heavy LLM involvement, and the author states plainly that it isn't production-ready.
Common issues
- Empty tooltips and no docs. Expected for this entire
detailgroup - OpenCV documents the stitcher's public API, not its internals. Work from the stitcher's own behaviour rather than the parameter text. - An assertion on the mask type. Feed a uint8 single-channel mask; a colour image is not a mask.
- The output doesn't change when you alter
sharpness. Check the mask is doing something first - a mask that's already 0-or-255 everywhere has no border for the ramp to soften.
Inputs (3)
| Name | Type | Default | Description |
|---|---|---|---|
| mask | 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. | |
| sharpness | FLOAT | 0.0000-1e+38–1e+38 | - - - |
| weight | 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 | — |