undistort
This OpenGL program uses a fragment program to compensate for pincushion distortion in real time. This software is particularly useful for head-mounted displays (HMDs) which frequently have a significant amount of pincushion distortion.
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 vizlensThe program was written by Scott Kuhl, now on the computer science faculty at Michigan Technological University.
pincushion = vizlens.PincushionDistortion(k1=0.1,scaleToFit=True)
Demonstration:
- View of checkerboard in HMD without correction
- View of checkerboard in HMD with correction
- Note: Although the images above are not antialiased, you can easily toggle antialiasing on and off in the OpenGL code below.
Download:
Source code for real-time pincushion correction
Additional Information:
S.A. Kuhl, W.B. Thompson, and S.H. Creem-Regehr, “HMD Calibration and Its Effects on Distance Judgments,” ACM Transactions on Applied Perception, 6(3), 2009. [pdf]
The work of the Visual Perception and Spatial Cognition research group is made possible by the generous support of the National Science Foundation, the National Institutes of Health, and the University of Utah.

