2
votes

I'm doing camera calibration using the calibration.cpp sample provided in the OpenCV 3.4 release. I'm using a simple 9x6 chessboard, with square length = 3.45 mm.

Command to run the code:

Calib.exe -w=9 -h=6 -s=3.45 -o=camera.yml -oe imgList.xml

imgList.xml

I'm using a batch of 28 images available here

camera.yml (output)

Image outputs from drawChessboardCorners: here

There are 4 images without the chessboard overlay drawn, findChessboardCorners has failed for these.

Results look kind of strange (if I understand them correctly). I'm taking focal length value for granted, but the principal point seems way off at c = (834, 1513). I was expecting a point closer to the image center at (1280, 960) since the orientation of the camera to the surface viewed is very close to 90 degrees.

Also if I place an object at the principal point and move it in the Z axis I shouldn't see it move along x and y in the image, is this correct?

I suspect I should add images with greater tilt of the chessboard with respect to the camera to get better results (z-angle). But the camera has a really narrow depth of field, and this prevents the chessboard corners from being detected.

2
is it really (834,1513) vs. (1280,960) or (1513,834) vs. (1280,960)? If thr first is the case, maybe your calibration image coordinates are swapped x and y coordinates?Micka
It must be the first case. The camera matrix doesn't make much sense otherwise. I also tried with -w=6 -h=9 and the camera matrix looks very similar. PS: edited the post to add the calibration.cpp linkRemus Pop

2 Answers

1
votes

The main issue you have is you don't feed the camera software enough information to get the right estimation of different parameters.

In all the 28 images you changed only the orientation of the chessboard around the z axis in the same plane. You don't need to take that much photos, for me around 15 is okay. You need to add more ddl to your images: change the distance of the chessboard from the camera and tilt the chessboard around its X and Y axis. Re calibrate the camera and you should get the right parameters.

0
votes

It really depends on the camera and lens you use. More specifically on things like:

  • precision of chip deployment
  • attachment of screw thread of lens
  • manufacturing of lens itself

Some cheap webcam with small chip could even have the principal point out of the image size (means it could be also a negative number). So in your case C could be both - (834,1513) or (1513,834). If you are using industrial cam or something similar, C should be in range of tens of percent around the centre of the image ->e.g. (1280,960)+-25%.

About the problem with narrow DOF (in nutshell) - to make it wider you need to get aperture as small as possible, prolong the exposure and add some extra light behind the camera to compensate the aperture. Also you could refocus to get sharp shots from different distances, only your accuracy gets lower as refocusing is slightly changing the focal length. But in most cases you do not need this super extra ultra accuracy so this should not be the problem.