0

I used the CameraCalibration node in Meshroom 2021.1.0 using a checkerboard grid to do a camera calibration. From what I understand, Meshroom is using OpenCV, so this question indirectly relates to the calibration process in OpenCV as well.

The lens I'm using is advertised as an 8mm lens, so I was expecting a focal length of something between 7 and 9 mm, but the fx value was 2541.273 and fy value was 2641.111 and I know the sensor pixel size is 6 microns, so when converting from pixels to mm, I'm getting focal lengths of 15.247 mm and 15.847 mm respectively which is right around double what I would expect.

The checkerboard I'm using has 50 mm squares, and I specified the size of the square in the camera calibration, and I double checked the printed dimensions with calipers. I also verified that the size of my images were full resolution compared to the expected size based on sensor specifications, so it wasn't a case where the resolution was half or double the original sensor size or something like that.

Curious if there is anything obvious I may have missed that would cause the focal length in the calibration to come out double what is expected.

I went through a similar calibration process with my smartphone and the camera I was testing with advertised a focal length of 7 mm and the camera calibration returned in that case an fx of 7.21 mm and an fy of 7.20 mm. The only difference was the grid I was using in that test was using 30 mm squares and was 7 x 5 instead of 4 x 3, but the process to get those values was essentially the same.

Update:

I reran a camera calibration with a different set of images, and this time I got an fx of 23.07 mm and fy of 23.23 mm, so it would seem that the previous run that was off by a factor of 2 may have been a coincidence that it was off by 2. Given how inconsistent the focal length values are from one run to the next and how far off they are from expected values, I'm guessing that the errors that I'm seeing are due to poor calibration images being used in the process? The camera is fixed, so I'm moving the checkerboard on a surface, so mostly in a single plane. To get a good calibration do I just need a better variety of orientations that the checkerboard is captured in like different distances and different angles?

example calibration shot example calibration shot 2

Is the size of the grid just too small for the field of view to get good calibration values from it? I calibrated with 80 calibration shots similar to the two above moving the board from one edge to the other.

I got a larger calibration target using the ChAruco pattern, and it looks like the values are more stable now, but every now and then if I repeat the calibration, I can get very far out numbers. Should the board below be large enough to get stable calibration values?

enter image description here

TJ Rockefeller
  • 3,178
  • 17
  • 43
  • https://stackoverflow.com/questions/69159247/camera-calibration-focal-length-value-seems-too-large/69161589#69161589 -- are you getting full resolution images? or half resolution images? focal length [px] = focal length [mm] / pixel pitch [µm/px]. your calibration might be junk. good reprojection error only means it's not obvious junk, but it can still be junk. show your calibration images. I predict your calibration images show topdown/frontal views of the checkerboard, which is bad. for a useful calibration, the board MUST show foreshortening, i.e. never be parallel to the image/sensor plane – Christoph Rackwitz Jan 09 '23 at 22:28
  • @ChristophRackwitz the images are full resolution images, and most of the shots have some foreshortening (~30 degrees to parallel), but most of them are shot at the same angle to the camera. I'll have to try again in a couple of days when I can test with the camera again to see if I can get a better calibration. – TJ Rockefeller Jan 09 '23 at 22:42
  • how do you know it's 6 microns? why could it not be 3 microns? what's the sensor resolution? would that resolution, at 6 microns/pixel, still fit in the camera? the sensor would be double the expected size. – Christoph Rackwitz Jan 09 '23 at 23:17
  • @ChristophRackwitz I know it's 6 microns based on documentation from the camera manufacturer. I'm intentionally being vague on the hardware because it's for my work. – TJ Rockefeller Jan 10 '23 at 13:49
  • could the focal length of your lens happen to be something other than what you believe it is? can you swap lenses and try a different one? are you sure it's positioned to be that distance away from the sensor? sensor positioned at focal length gives you a sharp picture of infinity. if you focus on something closer, the distance will have to be greater. -- is there _any_ resampling happening anywhere? anything funky going on with debayering? can you present a [mre] at all? – Christoph Rackwitz Jan 10 '23 at 17:05
  • yes, that's way too small an area of image covered by pattern. you can delete all that data for sure. -- is that an image aspect ratio of 3.21? why? is that just cropped? or is that synthetic panorama? – Christoph Rackwitz Jan 10 '23 at 22:23
  • It's a 3D camera, and in use it's only extracting pixel data from the laser line going down the middle of the image, so the sensor is very wide and short for exactly this use case. In practice, the top and the bottom of the image are usually cropped even more than this to increase the processing rate. – TJ Rockefeller Jan 10 '23 at 22:54
  • you should switch to a "charuco" board. that thing allows you to cover the image area better because it doesn't have to be entirely in view. there was some major reconstruction of the aruco stuff in OpenCV (also moved from contrib to main repo), so if you encounter any issues, don't be surprised. I think they changed how charuco is laid out, and also coordinate systems/origins. -- or use any other pattern for which you can easily establish correspondence between measured coordinates and model coordinates. – Christoph Rackwitz Jan 11 '23 at 10:56
  • that new board is barely enough to maybe calibrate focal length but it's not presented obliquely (no foreshortening) and it covers a mere quarter of the image width. it looks unwieldy though, so feel free to get closer to the camera. the only problem with that could be insufficient focus. you _might_ be able to get away with narrowing the aperture to improve that situation during calibration. aperture adjustments don't affect the lens. -- perhaps make a board with a denser grid of corners/markers so you can still have more than 2-3 corners along the height of the image. – Christoph Rackwitz Jan 13 '23 at 14:52
  • you said this was going to be used like a line scan camera. there are probably specific calibration approaches for those, which don't require a 2D view. – Christoph Rackwitz Jan 13 '23 at 14:57

0 Answers0