I am a software developer with focus on computer graphics but being poor in the topic of camera hardware. I try to implement a physical camera for simulation purposes and having some parameters to define the camera:
- Focal length
- Focal distance
- Multiple radial distortion coefficients
- Sensor resolution
- Sensor size
I found a formula to calculate the field of view as follow:
imagePlaneDistance = focalDistance * focalLength / (focalDistance - focalLength)
fovHorizontal = 2.0 * atan(sensorWidth / (2.0 * imagePlaneDistance))
This works very well! But now I want to add radial distortion by
Brown Conrady and
Kannala Brandt algorithm which also works very well.
Both algorithms convert the angle between the view direction and the pixel outgoing direction to the distorted angle offset. When applying one of the two algorithms on top of my rendered (Perspective projection) image which is rendered with a field of view calculated by the formula above. The barrel distortion at the edges and corners points me to a larger field of view than the formula. The pincushion distortion at the edges and corners points me to a smaller field of view than the formula. (See figure 1)
Figure 1: Left: Barrel distortion. Right: Pincushion distortion. The green border in the left image points to higher field of view than the formula above defines. The fine black lines in the right image are projection issues, which will be corrected later.
I totally understand why this happens. But I'm confused, how the "real" field of view gets calculated when having these parameters.
I think, that there are two ways:
- Add the maximum distortion offset on top of the field of view calculation to render with a larger frustum.
- The output image is a cut out from the distorted edges (like in figure1 the red box).
Which way to choose to be realistic? Or is there another better solution? How to get the real field of view?