cv::remap on a pre-rotated image
I am undistorting images from my camera, based on calibration data, using code such as this:
cv::fisheye::estimateNewCameraMatrixForUndistortRectify(cameraMatrix, calibCoeffs, imgSize, cv::Matx33d::eye(), newCamMat, 1);
cv::fisheye::initUndistortRectifyMap(cameraMatrix, calibCoeffs, cv::Matx33d::eye(), newCamMat, imgSize, CV_16SC2, map1, map2);
cv::remap(imgSrc, imgDst, map1, map2, cv::INTER_LINEAR);
Works great. However, I would like to use a hardware feature of my camera to allow image rotation by 90 degrees. For example, if the original image (for which the undistortion works) is 1920x1080, then I would also like to apply the undistortion to rotated frames from the camera (1080x1920).
I (very naively) tried to simply rotate the transformation matrix before using it on the rotated frames, as in:
cv::rotate(map1, map1, cv::ROTATE_90_CLOCKWISE);
cv::rotate(map2, map2, cv::ROTATE_90_CLOCKWISE);
cv::remap(imgSrc, imgDst, map1, map2, cv::INTER_LINEAR);
But this did not provide the expected results.
Any pointers in the right direction would be appreciated.