Skip to content

Camera Lens Calibration

PeeJay edited this page Jul 1, 2017 · 10 revisions

Camera lens calibration allows OpenPnP to learn about the parameters of the camera lens you are using and then apply a undistort algorithm to remove any distortion of the image caused by the lens. This is especially useful in fisheye lenses as it can make straight lines look straight when they would typically be curved by the lens.

The calibration process consists of showing a known pattern to the camera in a variety of positions and orientations. A set number of images are captured of the pattern and then OpenCV is used to calculate the lens parameters.

To calibrate the camera lens:

  1. Download and print a pattern from http://nerian.com/support/resources/patterns/. When printing the pattern, scale it so that it takes up the full field of view on the camera, but with enough room to rotate the pattern around a bit. (Don't worry about the warning on the download page not to scale the pattern, we only use it for undistortion. Setting the camera scale is done elsewhere)

  2. Mount the printed pattern to a piece of cardboard or stiff cardstock. It needs to stay relatively flat during the calibration process and you will be moving it around.

  3. Start the calibration process by clicking "Start Lens Calibration" button and follow the on screen instructions. You will see the pattern being recognized by the camera as you move the card around. A sample will be taken every 750 milliseconds and the screen will flash.

screen shot 2016-02-21 at 2 35 27 pm

Calibration works best when the pattern is captured in many different orientations and positions. Make sure to move the card around: turn it, angle it towards and away from the camera, move it around within the view of the camera, etc.

  1. When the process is complete OpenPnP will enable the undistort function and if all went well your camera view should now appear undistorted. You can toggle the "Apply Calibration?" checkbox back and forth to see the before and after results.

You can see a video of the process being performed at: https://www.youtube.com/watch?v=LNa2LNSpa68

References: http://docs.opencv.org/2.4/doc/tutorials/calib3d/camera_calibration/camera_calibration.html http://opencv-java-tutorials.readthedocs.org/en/latest/09-camera-calibration.html https://github.com/openpnp/openpnp/issues/226

Clone this wiki locally