Ask Your Question

Results of camera calibration vary

asked 2013-02-17 14:18:26 -0600

Martin gravatar image

Hi, I have a problem during camera calibration using chess board. I'm using C++ calibrateCamera method to find out the intrinsic matrix. The problem is the fx, fy are varying from 700 to 1100 depending on the distance from camera the cx, cy vary as well. My question is, can it be caused by poor camera quality(using some no-name webcam with resolution 640x480). Can this poor resolution be the only problem??

I need to have really accurate intrinsic matrix and in this case it seems I will need to calculate it by myself:(

Just to be sure for webcam with fixed focus length, the intrinsic matrix should be always the same isn't right???

Thanks for clarification.


edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2013-02-18 08:14:59 -0600

matt.hammer gravatar image

First, get fx and fy nailed down - as long as they are moving around, cx and cy won't be consistent. Some things i've tried to get good results on bad cameras:

  1. Did you use the program in the Code examples or roll your own? If you programmed your own, use the example program to make sure you are getting EXACTLY the same numbers and error values in yours before trusting it.

  2. Turn off Auto focus and zoom - they will both mess with the physical focal length and vary fx and fy.

  3. Use lots of samples - I think the books say 10 as a minimum. Use at least 20, I've used as many as 100.

  4. Make sure that your chessboard is rigid - tape it tightly to some wood or cardboard - if it's wrinkled or flopping around it will affect calibration.

  5. Do you have a proper chessboard? - the book says the chessboard should be at least several corners in each direction - and that one dimension should have an odd number of corners and the other should be even. I use a 9 X 6 corner chessboard printed on a 8 1/2 X 11 sheet of paper taped to some cardboard.

  6. Make sure your chessboard is taking up as much of the camera view as possible - especially with your low resolution. Don't be afraid to rotate and skew, but when you do make it big - remember you only need inside corners within the camera frame. (not having smaller sectional views might affect the distortion correction numbers - but your basic matrix is probably the first step.)

  7. Finally, use the drawChessboardCorners function (or use the Example Code program's show chessboards option) to pop-up the chessboard-by-chessboard results. Take a close look at where OpenCV thinks the corners are. With low-res video stills I've seen chessboards that OpenCV thinks are good where the corners are drawn 1/2 square off where they should be. Don't use bad corners in your calibration.

Good Luck!

edit flag offensive delete link more


Thank you very for your advices. I switched to OpenCV from JavaCV to try out with the original calibration demo. Now I'm playing with it and hope will get better results. Just small question it is not important to place the chessboard far away from camera? You said that it is important to cover as much as possible of the image with the chessboard I thought the difference in position(depth) are making the results better:-/

Martin gravatar imageMartin ( 2013-02-19 12:48:43 -0600 )edit

Well, I am still learning as well, so if you find a trustworthy source that tells you that far away chessboards are important, listen to them first. But if you pull up the far away chessboards intermeadiate results (the red/rainbow circles and lines drawn on the frames), you'll see a ton of error on low-res, if you get detects at all. You could do a bunch of these and pick out the good ones. However, my intution, based on my moderate-level understanding of what's going on under the hood is that for the "main" camera cal matrix parameters, fx, fy, cx, and cy, should be OK with only big chessboard views (make sure to remember to tilt/turn). I think the smaller views might help pick out lens and translation distorion.

matt.hammer gravatar imagematt.hammer ( 2013-02-20 10:43:18 -0600 )edit

Sounds reasonable. With chessboard closer to the camera the result seems to be better. I'm still having big avg.backprojection error, so I have some more questions please: 1) the cx,cy values are not very often referring to the exact middle of the sensor, is there any way how I can find them and use them as fixed afterwards? 2)What exactly is the "CV_CALIB_SAME_FOCAL_LENGTH" is it just to simplify the calculation of the calibration? 3)Is it at all possible to get backprojection errors really close to zero with such a bad camera? 4) can I somehow check manually the correctness of the intrinsic matrix? Let say I will use the points on the chessboard using real size in mm and than for known distance of some point from the camera calculate it's projection and compare them with real picture?

Martin gravatar imageMartin ( 2013-02-21 01:42:33 -0600 )edit
  1. cx & cy are the point that the camera's principal axis intersects the image frame. In a perfect camera, they would be in the middle. In a cheap webcam, if they were in the middle it would be pure luck,
  2. I think "CV_CALIB_SAME_FOCAL_LENGTH" just means that all the test chessboards were taken with the camera at the same focal length. I've never messed around with this off, but I'd imagine it lets you calibrate with images of chessboards taken with different focal lengths - probably by adding some more information as well.
  3. I don't have the error info on me, but the program is telling me I am getting less than 2 pixels of error with a pretty horrible camera.
matt.hammer gravatar imagematt.hammer ( 2013-02-26 13:27:26 -0600 )edit
  1. Possibly. Going directly into the camera matrix is hard, if not impossible. The focal lengths fx, and fy are actually a combination (multiplication?) of the physical focal length of the optical lens and the length and width of the individual CMOS sensor elements. The units on a camera matrix are some weird pixel/mm thing. You might be able to indirectly calculate based on multiple views of a known object from known distances or something - but then you're really doing the same sort of thing as the OpenCV anyways.
matt.hammer gravatar imagematt.hammer ( 2013-02-26 13:30:55 -0600 )edit

Question Tools



Asked: 2013-02-17 14:18:26 -0600

Seen: 7,478 times

Last updated: Feb 18 '13