0

Let's begin by saying that i have a static image, called it leftFrame.

This frame is passed to method cv2.remap(leftFrame, map1, map2, cv2.INTER_LANCZ0S4,0), so that every pixel from original image (leftFrame) is reallocated to a new position. Given that map1 and map2 is output from cv2.initUndistortRectifyMap(MLS, dLS, RL, PL,imgShape,cv2.CV_16SC2), with MLS, dLS, RL, PL had been calculated before.

Things are done well,

HOWEVER, now I just want to get the corresponding pixel coordinate of a single point in the new frame, given the original pixel coordinate of that point in the initial, original frame (leftFrame).

How can I achieve it?

The code is simplified to be like this:

Left_Stereo_Map = cv2.initUndistortRectifyMap(MLS, dLS, RL, PL,imgShape,cv2.CV_16SC2)
leftCap = cv2.VideoCapture(PORT)
 while (True):
   # Collect image continously
   ret1, leftFrame = leftCap.read()
   Left_nice = cv2.remap(leftFrame, Left_Stereo_Map[0], Left_Stereo_Map[1], cv2.INTER_LANCZOS4, cv2.BORDER_CONSTANT, 0)
   original_x = PREDEFINED_X
   original_y = PREDEFINED_Y
   x_after = ?
   y_after = ?

   cv2.waitkey(1)


Thanks everyone for spending your time reading this question. Wish you safe in this time!

  • Did you look at the [link](https://stackoverflow.com/questions/46520123/how-do-i-use-opencvs-remap-function)? – Ahmet Aug 30 '20 at 16:56

1 Answers1

0

Simplest solution is to separately call initUndistortRectifyMap in the opposite direction. The returned map1/2 contain the mapping you need, respectively for the x and y coordinates.

Francesco Callari
  • 11,300
  • 2
  • 25
  • 40