How to write a .cal file for fisheye lens distortion

Hello everybody,
I’m trying to create the .cal file to do the fisheye lens projection distortion. I have a Sigma 4.5mm and f2.8. The manufacturer points out that it is an equisolid projection lens. I’d like to make the distortion to an equidistant -vta, but I’m having trouble creating the fisheye_corr.cal file. I do not know how to do it. I just know that it is a file with a .txt extension that must be changed to a .cal extension. I don’t know how this file should be written. Could someone explain it to me in detail? Thank you in advance.

Hi Eliana,

The fisheye_corr.cal file should be installed with the standard distribution, and can be accessed without specifying the full path using:

pcomb -f fisheye_corr.cal -o fisheye.hdr > corrected.hdr

This is explained in the comments at the top of fisheye_corr.cal, which should be installed in your Radiance library folder, wherever that is on your system.

Hope this helps!
-Greg

Thank you very much for the help, it works now.

Yours sincerely

Eliana

Hi @Greg_Ward,

Thanks for answering the same question.

Does the fisheye_corr.cal file work on all lens type? As far as I understand, different lenses may need different correction functions (Section 2.3.4 of this paper) so I am not sure this command will universally apply.

Just a bit more context, the lens I have is ArduCam LN074 fitted on RPi High Quality camera.

Thanks.

No, as the fisheye_corr.cal file comments state, you can define your own radius mapping function. Here are the comments:

{
        Correct fisheye image using a distortion function:

                rad(r) =        function of r in [0,.5] range, returing same

        This function takes the pixel distance from the image center, where
        1.0 is the full width of the image constituting 180-degrees of view.
        The output is the corrected distance from the center for the output.
        (If your function is the inverse of this, set map_inverse=1.)

                pcomb -f fisheye_corr.cal -e 'rad(r)=my_function(r)' \
                        -o fisheye.hdr > corrected.hdr

        We also clear the region outside the r=[0,.5] circle to black.
        If this is all you want to do, use "rad(r)=r".

        If you know you have a solid-angle preserving distortion, use
        "rad(r)=mapsolid(r)" or leave off definition, as this is the default.
}

I hope this helps.
-Greg

P.S. I should add that the tabfunc program with the -i option is a good way to create a mapping function from measurements.

1 Like

Thanks @Greg_Ward for your help!

And it was nice seeing you in person this Wednesday!