1

I am trying to do forward mapping with OpenCV, but remap() only allows inverse mapping so I need to inverse the map(s) before using them. This is the inverse map method I want to use and it only takes in a single 2 channel map.

In the convert maps docs it says that you can convert one 2 channel (x,y) map into individual x and y maps. It also says that you can do "Reverse conversion". Does this mean you can convert from x and y maps to a single (x,y) map shape?

1 Answers1

0
import cv2 as cv

(xymap, _) = cv.convertMaps(map1=xmap, map2=ymap, dstmap1type=cv.CV_32FC2)

Documentation isn't terribly obvious. The bullet list only contains the interesting cases (for fixed point math). Your case is just rearranging the values without touching them, which is not listed, but supported. You can use dstmap1type=cv.CV_32FC2.

Or simply use numpy:

xymap = np.dstack([xmap, ymap])

You are working with v2.x documentation... don't. Use current docs. You are very surely not using OpenCV v2.x.

Christoph Rackwitz
  • 11,317
  • 4
  • 27
  • 36