Modeling wideangle lenses in Webots

Hello everyone!
This is a forwarding of my question on V-HL 2021 discord channel https://discord.com/channels/462951096374132736/727240540273508473/826726775785783317

So, which virtual camera model should we use in webots to properly emulate wide-angle lenses on robot’s camera?
In robot’s PROTO we can set “spherical” property to TRUE. Using this, I expect the camera model to be well calibrated as an real-world fisheye/wideangle lenses (i.e. with moderate radial distortion). But currently from webots camera with “spherical=true” I will get this:

This is not an image which we can model with radial distortion. It looks like an image captured from camera with cylindrical imaging surface, not spherical. With proper radial distortion I expect something like this:

As the reminder, classic radial distortion model has a form of:

Xdistorted = Xideal (1 + k1r + k2r^2 + …)
Ydistorted = Yideal (1 + k1r + k2r^2 + …)
where r is the distance of the current pixel from the center of an image (i.e. radius of a pixel)
Note that the distortion modeling coefficients k1, k2, … are same for both X and Y image axes.

But webots simulated image looks like we need to do correction on Y image axis, but we don’t need to do the correction on X axis. To take this into account, we need to implement custom distortion model, which is possible but very undesirable. Or use undistorted image from webots camera (using spherical=false), which is unrealistic if we trying to model a real-life robot with wideangle lenses.

Yes, this is known issue, see https://github.com/cyberbotics/webots/issues/2295.
It will be addressed in Webots as soon as possible.
Meanwhile, I would recommend you to start working with the cylindrical projection.

Hi,
This is a forwarding of my question on V-HL 2021 discord channel


We set “spherical” to TRUE.
We added radialcoeffcients, and the result is as follows:
ari
And,Without radialcoeffcients :
nasi
In our settings, the garbage looks more significant. Also, we don’t understand why images are already distorted with radialcoefficients are zero.

By using a spherical projection to the camera, the image already gets distorted according to the field of view: a smaller field of view will induce a smaller distortion. The radial coefficients of the Lens node should add even more distortion to the resulting image.

This is “spherical” to FALSE.
mojiari
And,This is real-world image:


Even if we do not set spherical, it is too different from reality .

I believe you should set spherical to TRUE to have a realistic camera image and maybe remove the Lens effects as it combines poorly with spherical TRUE.

We have the same problem, and setting “spherical=TRUE” is not a solution.
When “spherical=TRUE” in webots, image is properly distorted in vertical direction and not distorted at all in horisontal direction - please see my very first message in this topic above for example images - this questions is still unanswered.
As can be seen from this examples, “spherical” image in webots is even more unrealistic than “non-spherical”. This “spherical” mode is actually a “cylindrical” mode, and will ruin any attempt to calibrate this synthetic camera using opencv/matlab/etc. This classic calibration software can’t support such cylindrical camera model as in webots - with distortion only in one direction but not in the other.