I do camera calibration for a single camera with a chessboard pattern in opencv for the first time. The focus is fixed. I'm not sure how to do it, there seems to be many questions:
- How many images should be used for calibration?
- What pattern should be used? number of points, size of squares
- What transformations should be applied to the calibration target? rotated, tilted, shifted...
I came to the conclusion that none of the questions above can be answered on their own, because they all depend on each other. Say for example taking a lot of images that are very similar to each other are intuitively not as good as having less images that are better distributed in the frame.
I took a step back and thought about what's going on. (I tried) Basically, there's a mathematical model of the camera and its aberrations (focal length, distortion, etc...) and the calibration is the process of collecting data to fit the model (its values) to the hardware at hand. This appears to be mostly statistics. In order to fit the model to the entire image well, sample data should be collected from the entire image.
I conclude that all questions above boil down to how should the detectable points of the pattern be distributed in the 3D space.
I'd like to know if this thought makes any sense.
I'm tired of reading handwavy suggestions like "the more images, the better", "at least arbitrary number of images should be used", etc. that do not provide a quantifiable measure for the quality of a calibration. Sure, there's a reprojection error, that tells how good the calibration fits to the provided calibration data, but not how good that data is suited for calibration in the first place.
I came to the conclusion that it makes more sense to evaluate the quality of a calibration by the distribution of the sample data used to create it. Makes sense?
Questions 1 and 2 above are thus combined to : What should be the overall density (or density distribution) of detected calibration points among all calibration images?
Say I take all detected points from all calibration images and place them in one image, I could see how many calibration points there are per pixel area $\text{px}^{2}$.If I have a lot of images with the pattern in the center of the image, I get a higher density there.
What would be a good minimum (baseline) value for the density of calibration points per pixel area? $0.1 \ \text{px}^{-2}$ ? $0.5 \ \text{px}^{-2}$ ?
Should the distribution of calibration points per pixel area be constant over the entire image? Or do I need a higher density (read: more sample values) at the edges for example?
Question 3 is asking for the distribution in the 3rd dimension. The calibration target with the pattern can be moved back and forth (along the optical axis) or tilted. Both transformations lead to calibration points in front or behind the plane that's in focus1. Depending on the depth of field, corner points can be detected up to some distance from the focal plane. This adds a 3rd dimension to the space in which calibration points can be detected. How should calibration points be distributed with respect to distance from the plane of focus1? Should most points be around the plane of focus1 given that detection of points further away from it is not as good?
tl, dr;
In front of a camera, there's a 3D space enclosed by a frustum of a pyramid/cone in which calibration points can be detected. How should calibration points be distributed in that space in order to get a good calibration?
1 With that I mean the plane of points that will be "in focus" in the image.