Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions about lens distortion parameters #190

Open
AdrianEddy opened this issue May 14, 2024 · 1 comment
Open

Questions about lens distortion parameters #190

AdrianEddy opened this issue May 14, 2024 · 1 comment

Comments

@AdrianEddy
Copy link

AdrianEddy commented May 14, 2024

Hi :)
I'd like to use the POLY values to implement the lens distortion model, but I have a few questions:

  1. POLY - are r0-r4 the radial coefficients and r5-r6 the tangential coefficients, or are all 7 radial?
  2. POLY - coefficients are for distortion or undistortion? It seems like they are for undistortion, is this correct?
  3. Are the POLY coefficients for any specific model, or just generic polynomial? They are supposed to be used to distort the radius?
  4. I understand that the ZFOV is diagonal FOV that can be used to calculate the camera intrinsic matrix. However, when calculating focal length and horizontal/vertical FOV, I have different values than listed here
  5. What's ZMPL?
  6. Are there any other GPMF fields relevant for lens distortions?

Code for 4.:

function focalLengthFromFOV(diagonalFOV, width, height) {
    const diagonalFOVRadians = diagonalFOV * Math.PI / 180;
    const diagonal = Math.sqrt(width * width + height * height);
    return diagonal / (2 * Math.tan(diagonalFOVRadians / 2));
}
function calculateFOVs(fovDiag, width, height) {
    const fovDiagRadians = fovDiag * Math.PI / 180;
    const diagonal = Math.sqrt(width * width + height * height);
    const horizontalFOVRadians = 2 * Math.atan((width / 2) / (diagonal / 2 / Math.tan(fovDiagRadians / 2)));
    const verticalFOVRadians = 2 * Math.atan((height / 2) / (diagonal / 2 / Math.tan(fovDiagRadians / 2)));

    return [ horizontalFOVRadians * 180 / Math.PI, verticalFOVRadians * 180 / Math.PI ];
}

for ZFOV = 133.39 and 5312x2988 this yields 1312 pixel focal length and 127 HFOV and 97 VFOV, but the specs page lists 118 and 69 when the diagonal fov is 133. What am I missing here?

@dnewman-gpsw
Copy link
Collaborator

POLY r0-r7 are all radial coefficients of increasingly powers.

The curve is normalized radius to world angle. ZMPL is required to normalize the input. It is little odd. r = x.ZMPL

In desmos
Screenshot_20240519-125127

If you set x=1 the output will be half ZFOV.

If you set x=0.752 (if a calculated correctly) this would be HFOV position, and I get 122 degrees. Matching the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants