openCV distortion calibration resolution scaling

opencv, python

Solution

The GoPro camera has different field of view at different resolutions. Take a look at the specs. This is probably what's causing your problems.

Problem

I am using a camera matrix and undistortion coefficients that I found here for some GoPro footage (because I unfortunatly no longer have access to a GoPro to calibrate the footage myself), and it seems to work well enough for 1280 * 960 (4:3), however, I am running into some issues with larger resolutions (3840 * 2880 (4:3)). According to the openCV documentation: While the distortion coefficients are the same regardless of the camera resolutions used, these should be scaled along with the current resolution from the calibrated resolution. Is `these` referring to the camera matrix? What is the exact procedure to scale the camera matrix? I tried linear interpolation (scalar multiplication of row X with width ratio and row Y with height ratio), the image is better but still doesn't look quite right. Could this be because the video aspect ratio of the calibration footage (16:9) isn't quite the same as my footage? If so, why would the error not scale linearly as well? E.g. ``` f_x_target = f_x_calibration * targetWidth / calibrationWidth c_x_target = c_x_calibration * targetWidth / calibrationWidth f_y_target = f_y_calibration * targetHeight / calibrationHeight c_y_target = c_y_calibration * targetHeight / calibrationHeight ```

Original source