I have a 1280px by 960px image with known
Camera Matrix:
[𝑓𝑥 , 0 , 𝑐𝑥 , 0 , 𝑓𝑦 , 𝑐𝑦 , 0 , 0 , 1]
Distortion Matrix:
[𝑘1, 𝑘2, 𝑝1, 𝑝2, 𝑘3]
I'm trying to undistort it by
undistort(croppedImage, undistortedImage, cameraMatrix, distortionMatrix);
however it is taking too long so I have cropped the image with boundaries x1, x2, y1, y2.
If I apply the same camera matrix and distortion matrix into undistort() the image does not become fully undistorted.
How can I undistort the new cropped image based on the original camera matrix and distortion matrix without recalibrating?
The undistort effect is applied at the cx and cy position in your Camera Matrix.
If you crop the image, all you need to do is shift the cx and cy position to where it would be on the original image. This way the undistort will be applied from that position and your cropped section will be undistorted accordingly.
All other values can stay the same
new_fx = fx
new_fy = fy
new_cx = cx - x1
new_cy = cy - y1
new_k1 = k1
new_k2 = k2
new_p1 = p1
new_p2 = p2
new_k3 = k3