Repository navigation
Conversation
makeRadialPeak solved 5 k2 u^2 + 3 k1 u + 1 = 0 with the quadratic formula, which divides by 5 k2, so k2 === 0 returned no peak even though r (1 + k1 r^2) peaks at sqrt(-1 / (3 k1)) for k1 < 0. Points past the peak then folded back into the image. Handle the linear case in makeRadialPeak and in SliderTransform._getRadialPeak.
|
Thanks for the clear explanation and regression tests. The fix looks sensible from code inspection. Could you add a reproducible visual example showing the issue this fixes?
Given your note that Mapillary-reconstructed images normally have nonzero k2, a custom-provider example using a synthetic grid image is fine if there is no affected production image. This would help us verify the rendered result alongside the numerical tests. |
|
Added a runnable custom provider and four screenshots. With the same perspective camera, viewport and zoom, the vertical field of view changes from 63.91° to 81.04° in both the viewer and the slider. |
|
Thanks! The images show a real change, but not a clear “broken image becomes correct” demonstration. These screenshots support a change in how far you can zoom out for this custom calibration. They don’t directly show the originally described problem of out-of-view content folding back into the image. The “after” also has sharp bends near the sides that need explaining. The mathematical fix still looks valid, but the visual evidence is incomplete. Can you confirm whether this came from a real camera calibration or was found only with synthetic parameters. Also, could you attach real raw images from the camera so we could get a better sense? |
|
To confirm: this was found only with synthetic parameters. I found it by reading On the sharp bends in the "after" view: that is the clamp from 8a8f04d being applied, not something new in this change. Past You're right that the screenshots show the wider field of view more clearly than the fold-back. If the change isn't worth taking without a real affected camera, I understand, and I'm fine with closing it. |
Motivation
makeRadialPeak(k1, k2)finds the radius where the distorted radiusr * (1 + k1 r^2 + k2 r^4)stops increasing. Projection clamps at that radius so that points past it do not fold back into the image (see 8a8f04d, "handle peaking radial distortion function"). It gets the radius by solving5 k2 u^2 + 3 k1 u + 1 = 0with the quadratic formula, which divides bya = 5 k2. Whenk2 === 0the roots come out asNaN/Infinityand the function returns "no peak", even thoughy = r (1 + k1 r^2)withk1 < 0clearly peaks atr = sqrt(-1 / (3 k1)).[focal, k1, 0]is a valid perspective/fisheye parameter set, and it is what a single-coefficient radial calibration produces (SliderTransformalso pads[focal, k1]tok2 = 0). For a camera like[0.85, -0.2, 0]:radialPeakisInfinity, whilek2 = 1e-12gives 1.29099. The closed form and a brute-force argmax also give 1.29099.x = 0.383, which is inside the image. The clamped value is0.85 * tan(63°) * 2/3 = 1.112.[0.55, -0.28, 0], unprojecting and then projecting the image corner[-0.5, -0.375]returns[124.3, 93.2].The same value goes to the
radialPeakshader uniform, and the slider transform has its own copy of the computation with the same problem.Images reconstructed by the Mapillary platform normally have a nonzero
k2, so this mostly affects camera parameters from other sources, e.g. a k1-only calibration passed in through a customDataProviderBase.Have you read the Contributing Guidelines?
Yes. I have completed the CLA.
Contribution
makeRadialPeakinsrc/geometry/Common.ts: whenk2 === 0, returnsqrt(-1 / (3 k1))for negativek1andInfinityotherwise.SliderTransform._getRadialPeak: same branch, keeping that file'sundefinedfor "no peak".The
k2 !== 0path is unchanged.Test Plan
PerspectiveCamera.radialPeak,FisheyeCamera.radialPeakandSliderTransform radial peaktests:k2 = 0k2 = 1e-12k1 >= 0still has no peakmainand all pass with the change.yarn test: 129 suites, 1745 tests pass.tslintwith the repo's config (config/tslint.json, as used byyarn lint) passes on the changed files.The visual example includes a runnable provider and matching before-and-after screenshots for the main camera and slider.