-2

I'm trying to implement some form of a stereo vision. I have 2 images of the same scene, taken from different positions. I calculated the rotation + translation matrix between each other (3x4 matrix) I want to activate the rotation part of the matrix (first 3x3 block) on one image (2D RGB matrix) to rectify it. so it will be rotated and appear to be from the same angle as the other image (without the translation, same angle of the camera, but different position).

I am using python, I tried to look in open cv - here but I couldn't find the function that does this.

any ideas?

thanks!

Yanir
  • 21
  • 2
  • did you have a look at https://docs.opencv.org/3.4/d9/d0c/group__calib3d.html#ga617b1685d4059c6040827800e72ad2b6 – Micka Jun 01 '21 at 05:56
  • @Micka yes, the answer was there, thanks! I updated the solution – Yanir Jun 14 '21 at 18:59

1 Answers1

2

Update - I found the solution:

import cv2
def rectify(img, R):
    map1, map2 = cv2.initUndistortRectifyMap(cam_mat, None, R, cam_mat, 
    img.shape[1::-1], cv2.CV_32FC1)
    rectifiedImg = cv2.remap(img, map1, map2, cv2.INTER_NEAREST)

    return rectifiedImg 
Yanir
  • 21
  • 2