Nodes/opencv-comfyui/OpenCV convertMaps_0
ComfyUI Node

OpenCV convertMaps_0

Remap map plumbing, for the geometry nerds

By geroldmeisinger·Created about a year ago·Updated about a year ago· 35
OpenCV convertMaps_0
  • map1
  • map2
  • dstmap1
  • dstmap2
  • nparray_0
  • nparray_1
dstmap1type
nninterpolation

convertMaps_0 converts a remapping map from one format to another, so you can feed it to remap_0 or cv2.remap in the format that function actually wants. It's not a glamorous node - it doesn't touch a single pixel - and if you're not doing camera-style image warping you will never need it. But the moment you're building an undistortion or warp pipeline in ComfyUI, this is the missing connector that makes the whole thing work.

Mechanically it's a straight cv2.convertMaps call from the opencv-comfyui pack. The inputs: map1 and map2 (NPARRAYs, the coordinate maps describing where each output pixel reads from), dstmap1type (an INT - the target map type), and nninterpolation (a boolean: True drops accuracy and uses nearest-neighbor when converting fixed-point maps). Two optional out-parameters (dstmap1, dstmap2) exist because that's how OpenCV's signature is typed - the pack README's standing advice applies: leave them empty.

It outputs two NPARRAYs (nparray_0, nparray_1): the converted maps, ready for remap_0.

The one number you actually set

dstmap1type is where people stall, because OpenCV speaks in constants. The three values you'll plausibly use:

  • 5 - CV_32FC1: two separate single-channel float32 maps (this is often what you start from)
  • 13 - CV_32FC2: one two-channel float32 map (what remap usually wants)
  • 3 - CV_16SC2: fixed-point signed int16, with nninterpolation deciding whether to keep the sub-pixel precision

The classic move: you have map1 + map2 as two single-channel float32 arrays, and remap wants a single two-channel map. dstmap1type = 13 converts 2-in-1, and nparray_0 is your remap-ready map. It's pure plumbing - the kind of invisible data-flow glue the modidex plumbing docs describe - but the geometry it enables is real (barrel distortion correction, fisheye unwarping, wide-angle fixes).

Install

Same as every node in this pack - ComfyUI Manager, search opencv-comfyui, or:

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

Restart. No model downloads.

Troubleshooting

  • Maps are nparrays, not images - don't try to view them with Nparrays2Image as if they were photos; they're coordinate arrays and the pack's "output isn't an image" error is the usual way you find out.
  • Keep the conversion chain straight: Image2Nparray (batch 1 only) → geometry nodes → Nparrays2Image to get back to a viewable IMAGE.
  • If dstmap1type produces an assertion error, you've fed a map with the wrong channel count for the type you asked for. Check what your upstream map-producing node actually emits.
  • Confusingly, convertMaps_0 and convertMaps_1 are the same function twice - the two overloads from the type definitions (MatLike vs UMat) generated into identical nodes. Use either.
Categoryimage/OpenCV

Inputs (6)

NameTypeDefaultDescription
map1NPARRAY
map2NPARRAY
dstmap1typeINT
nninterpolationBOOLEAN
dstmap1optNPARRAY
dstmap2optNPARRAY

Outputs (2)

NameTypeDescription
nparray_0NPARRAY
nparray_1NPARRAY