Pincushion distortion correction

This OpenGL program uses a fragment program to compensate for pincushion distortion in real time. This basic approach to pincushion distortion can be applied to eliminate or reduce pincushion distortion in head-mounted displays (HMDs) which have a significant amounts of pincushion distortion such as some nVis HMDs and the Oculus Rift.

Recent versions of Vizard include lens distortion correction software that is based on this software. The Vizard documentation includes a description of this feature. The following two lines of code enable lens correction in Vizard (the k1 parameter should be changed to approximate the amount of distortion in your display):

import vizlens
pincushion = vizlens.PincushionDistortion(k1=0.1,scaleToFit=True)

Demonstration:

Note: Although the images above are not antialiased, you can easily toggle antialiasing on and off in the OpenGL code.

Download:

Source code for real-time pincushion correction

If you improve this software and would like your changes to be considered for included in this code, please email me

Michigan Tech Logo