Simulation of Lens Distortion
Cameras have lenses and do usually not resemble perfect pinhole cameras. Therefore, lens distortion models have been developed that allow a lens correction on the input images of a camera and warp them to undistorted cameras of the corresponding pinhole camera.
A widely used distortion model is described on the documentation page of the OpenCV library and the homepage of the Camera Calibration Toolbox for Matlab of Jean-Yves Bouguet.
To generate synthetic images containing lens distortion, one usually has to apply the distortion after the rendering process, at least with POV-Ray. To overcome this drawback, I have written a patch to POV-Ray 3.6.1 that introduces a new camera type.
To install the patch, download the source archive of POV-Ray 3.6.1 and extract it:
Then download the patch into the same directory and execute:
Now you can build and install your own version of POV-Ray:
To use the new camera, take a look at the following example snippet:
The pixel coordinate system is assumed to have its origin at the center of the upper left pixel!