I have input array that I use to remap my image and then perform one translation affine transform and one rotation affine transform. I believe this is computationally more intensive and can be simplified by changing the remap function's input array(s) to reflect the translation and rotation transforms. So that all can be applied to image in one go.
Need help with some code to go ahead with this, as I am not sure how to get this done.
// In C++
// Remap
remap(rightCamImage, rightCamImage, camMapX, camMapY, cv::INTER_LINEAR);
// Translation (Translation needs to be done along y axis only)
Mat warp_matrix_translation = Mat::eye(2, 3, CV_64F);
warp_matrix_translation.at<double>(1, 2) = -finalDeltaY;
warpAffine(rightCamImage, rightCamImage, warp_matrix_translation, rightCamImage.size());
// Rotation
Mat warp_matrix_rotation = getRotationMatrix2D(Point(0, 0), -finalThetaRadian*180/PI, 1.0); // This function expects angle in degree
warpAffine(rightCamImage, rightCamImage, warp_matrix_rotation, rightCamImage.size());
// Remap
remap(rightCamImage, rightCamImage, camMapX, camMapY, cv::INTER_LINEAR);
// # In Python
// Translation
M = np.float32([[1,0,0],[0,1,-delYIntercept]])
res = cv2.warpAffine(imgR,M,(w,h))
// Rotation
M = cv2.getRotationMatrix2D((0,0),-theta,1)
res1 = cv2.warpAffine(res,M,(w,h))
// # Remap
undistorted_img_right = cv2.remap(imgRight, rightMapX, rightMapY, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)
# Translation
M = np.float32([[1,0,0],[0,1,-delYIntercept]])
res = cv2.warpAffine(imgR,M,(w,h))
# Rotation
M = cv2.getRotationMatrix2D((0,0),-theta,1)
res1 = cv2.warpAffine(res,M,(w,h))