Hi, I have a fisheye camera which is calibrated. I am now trying to undistort the image to a larger image to keep all original image content. Below is my code. The original image is 640x480 and I would like to undistort it to a 1200x1200 image. However, when I ran the code, the output image “rview” was always 640x480. WHy?
Mat frame =.../my input image, size(640x480)
Mat output;
Mat newK;
Mat view, map1, map2;
Size newSize(1200, 1200); //I want to undistort to a 1200x1200 image
Mat rview(newSize, frame.type()); //rview size is 1200x1200
fisheye::estimateNewCameraMatrixForUndistortRectify(K, D, frame.size(), Matx33d::eye(), newK, 1);
fisheye::initUndistortRectifyMap(K, D, Matx33d::eye(), newK, frame.size(), CV_16SC2, map1, map2); //as input, frame size is 640x480, as output map1, map2 size were 640x480
remap(frame, rview, map1, map2, INTER_LINEAR); //rview image size changed to 640x480
imwrite("rview.png", rview);