16
$\begingroup$

First off, I hope this is the correct Stack Exchange board. My apologies if it is not.

I am working on something that requires me to calibrate the camera. I have successfully implemented the code to do this in OpenCV (C++). I am using the inbuilt chessboard functions and a chessboard I have printed off.

There are many tutorials on the internet which state to give more than one view of the chessboard and extract the corners from each frame.

Is there an optimum set of views to give to the function to get the most accurate camera calibration? What affects the accuracy of the calibration?

For instance, if I give it 5 images of the same view without moving anything it gives some straight results when I try and undistort the webcam feed.

FYI to anyone visiting: I've recently found out you can get must better camera calibration by using a grid of asymmetric circles and the respective OpenCV function.

$\endgroup$
8
$\begingroup$

You have to take images for calibration from different points of view and angles, with as big difference between angles as possible (all three Euler angles should vary), but so that pattern diameter was still fitting to camera field of view. The more views are you using the better calibration will be. That is needed because during the calibration you detect focal length and distortion parameters, so to get them by least square method different angles are needed. If you arn't moving camera at all you are not getting new information and calibration is useless. Be aware, that you usually need only focal length, distortion parameters are usually negligible even for consumer cameras, web cameras and cell phone cameras. If you already know focal length from the camera specification you may not even need calibration.

Distortion coefficient are more present in "special" cameras like wide-angle or 360°.

Here is the Wikipedia entry about calibration. And here is non-linear distortion, which is negligible for most cameras.

$\endgroup$
  • $\begingroup$ By Eulers angles I assume you mean rotating the camera around the chessboard (with the chessboard as pivot) in the x, y and moving the camera towards and away from the chessboard in the z? I read about someone who simply printed off transformed chessboards and keeping the camera in the same place. For instance: i.imgur.com/rYzV4.png and i.imgur.com/McG9z.png. Is using things like this a poor decision as it may not represent how things would distory in reality? $\endgroup$ – Cheetah Feb 27 '12 at 17:01
  • $\begingroup$ Yes about moving camera. Yes again about keeping in place. $\endgroup$ – mirror2image Feb 28 '12 at 7:55
  • $\begingroup$ @mirror2image You mean, in practical operations, it's better to change different angles. But that means different views will have different world coordination systems. Do I need to use a shared world coordination system to keep the object points in the same coordination system? $\endgroup$ – Richard Sep 11 '17 at 5:44
3
$\begingroup$

@Ben - number of views depends the camera and the final accuracy required.

With very high quality, low distortion lenses (high-end 35mm SLR) using lots of chessboard images to map the distortions can be unstable - since the distortions are fractions of a pixel.
You still need several shots with the board (or camera) rotated since the image centre is normally only within a couple of pixels of the nominal x/2,y/2 and will change with focus. And of course zoom changes everything.

Once you have lens-chip centre and focal length(in X and Y) you only need a single chess board in the shot to give you camera position

$\endgroup$
  • $\begingroup$ I keep getting really bad calibration and I honestly can't figure out why. I have a printed chessboard on the wall and I am moving the camera to different positions so it has different views on the chessboard but whenever I use the undistort function in opencv and it just comes out very weird and distorted compared to the original. My camera is a Microsoft LifeCam Studio 1080p. $\endgroup$ – Cheetah Mar 12 '12 at 12:18
  • $\begingroup$ @Ben Disable any autofocus. On tiny lens webcams the focal length and lens centre change with focus. Are you rotating enough that it gets a good fit for the centre? Do have squares going out to the corners? Finally check that all the targets have all the squares detected. $\endgroup$ – Martin Beckett Mar 12 '12 at 16:07
  • $\begingroup$ The autofocus has already been disabled. Define enough? I am trying as extreme angles as I can to pick up the points. Not sure what you mean by "squares going out to the corners", if you mean the function which draws the extracted corners on the image - then yes. I already also have the check to see that all the corners have been detected. I think my problem MAY lie with what I set the initial focal length to in the intrinsic matrix that I pass to the calibration function. I have tried 1:1, 16:9 (what I believe the webcam aspect ratio is) and have also tried NOTHING (which you can do) $\endgroup$ – Cheetah Mar 12 '12 at 16:20
  • $\begingroup$ @Martin Is it possible to do calibration by keeping the camera at stationery position and changing the chessboard orientation without changing the distance between the camera and chessboard?? $\endgroup$ – user4059 Mar 4 '13 at 4:15
  • $\begingroup$ @Santosh - yes that's obviously exactly equivalent. You need to make sure you have covered lots of different angles $\endgroup$ – Martin Beckett Mar 4 '13 at 5:35
3
$\begingroup$

I decided to post this answer here because a while back, this came up as the top result in Google and its suggestions helped me. So I decided to share my experience too.

Having spent countless hours trying to get the best stereo calibration on a Kinect, I shared my tips and findings in a blog post here.

Although it is geared towards stereo calibration and more specifically Kinect, I believe the tips will help anyone who is trying to calibrate a camera.

Also, in case I should die someday or forget to renew my hosting, here is a modified quote from the post:

  1. Make sure you have the largest possible calibration pattern. Follow what I said above. Get a nice pattern professionally printed. Make sure each square is at least 8cm x 8cm. Also, make sure one side of the calibration pattern has an odd number of squares and the other side has an even number of squares (e.g 9×6 or 7×8). It’s important for detecting the pose of the target correctly. Also, some toolboxes will not be able to detect the pattern in this requirement is not met. As mentioned before, the patterns I used which are suitable for printing on large sheets are uploaded here (for 9cm squares) and here (for 10cm squares).
  2. Make sure your printed pattern has enough white border around it, otherwise it may not be easily detected by most toolboxes.
  3. Make sure the Kinect does not move. I used a mount to mount my Kinect to a tripod.
  4. Try to get as many images of the calibration target as you can. My best calibration was obtained using 300 images, at distances as low as 0.5 meter to as far as 10 meters from the camera. Make sure you rotate the pattern around X, Y and Z axes. Also try to “tile” the view with images taken at the same distance: i.e take one image, move the target to the next tile in the field of view, take another one and repeat until you’ve “tiled” all of the current field of view. The goal is to cover the entire field of view at each distance as much as possible.
  5. Use MATLAB’s stereo calibration app if possible. It allows you to get rid of the outliers after each calibration phase.
$\endgroup$
2
$\begingroup$

Here is a list of 'best practices' for camera calibration which I originally posted here: https://calib.io/blogs/knowledge-base/calibration-best-practices

  • Choose the right size calibration target. Large enough to properly constrain parameters. Preferably it should cover approx. half of the total area when seen fronto-parallel in the camera images.
  • Perform calibration at the approximate working distance (WD) of your final application. The camera should be focused at this distance and focus should be unchanged after calibration.
  • The target should have a high feature count. Using fine patterns is preferable. However, at some point detection robustness suffers. Our recommendation is to use fine pattern counts for cameras above 3MPx and if the lighting is controlled and good.
  • Collect images from different areas and tilts. Move the target to fully cover the image area and aim for even coverage. Lens distortion can be properly determined from fronto-parallel images only, but focal length estimation is dependent on observing foreshortening. Include both frontoparallel images, and images taken with the board tilted up to +/- 45 degrees in both horizontal an vertical direction. Tilting more is usually not a good idea as feature localization accuracy suffers.
  • Use good lighting. This is often overlooked, but hugely important. The calibration target should preferably be diffusely lit by means of controlled photography lighting. Strong point sources give rise to uneven illumination, possibly making detection fail, and not utilizing the camera's dynamic range very well. Shadows can do the same.
  • Have enough observations. Usually, calibration should be performed on at least 6 observations (images) of a calibration target. If a higher order camera or distortion model is used, more observations are beneficial.
  • Consider using uniquely coded targets such as CharuCo boards. These allow you to gather observations from the very edges of the camera sensor and lens, and hence constrain the distortion parameters very well. Also, they allow you to collect data even when single feature points do not fulfill the other requirements.
  • Calibration is only as accurate as the calibration target used. Use laser printed targets only to validate and test.
  • Proper mounting of calibration target and camera. In order to minimize distortion and bow in larger targets, mount them either vertically, or laying flat on a rigid support. Consider moving the camera in these cases instead. Use a quality tripod, and avoid touching the camera during acquisitions.
  • Remove bad observations. Carefully inspect reprojection errors. Both per-view and per-feature. If any of these appear as outliers, exclude them and recalibrate.

An online tool to generate PDFs for calibration targets is found here: https://calib.io/pages/camera-calibration-pattern-generator

$\endgroup$
  • $\begingroup$ Hi, welcome to DSP SE. Self-promoting answers are generally not welcome here. Please consider making it higher quality answer. $\endgroup$ – jojek Oct 25 '18 at 10:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.