Search code examples
opencvroscamera-calibration

Will bad camera calibration affect pixel coordinates?


I am working with Turtlebots and ROS, and using a camera to find the pixel positions of a marker in the camera. I've moved over from simulations to a physical system. The issue I'm having is that the pixel positions in my physical system did not match the pixel positions in the physical system despite the marker and everything else being in the same position as in the simulations. There was a shift in the vertical pixel position by about 40 pixels when everything else like the height between the camera and marker, the marker position, and the distance between the marker and camera were the same in both the physical and simulated system. The simulated system does not need a camera calibration matrix, it is assumed to be ideal.

The resolution I'm using is 640x480, so the center pixels should be cx=320 and cy=240, but what I noticed in the camera calibration matrix I was using in the physical system was that the cx was around 318, which is pretty accurate, but the cy was around 202, which is far from what it should be. This also made me think that the shift in pixel positions in the vertical direction is shifted with about the same amount of pixels that I'm getting as an error.

So is it right to assume that the error in the center pixel in the calibration could be causing the error in the pixel positions?

I have been trying to calibrate a USB camera (Logitech C920 I think) and I've been using the camera_calibrator ROS package found here http://wiki.ros.org/camera_calibration to calibrate the camera. I think the camera calibration did not go that well, seeing as I always have a pretty big error in either cx or cy. Here are the calibration matrices.

First calibration matrix, used 15x10 vertices with size 0.25

Recalibrated but did not actually use this yet, calibrated with 8x6 size 0.25

Same as previous, some difference between the two

The checkerboards were on A4 papers.

Thanks in advance.


Solution

  • I believe the answer to your question is to answer how to perform a better camera calibration.


    Quoting from Calib.io enter link description here:

    • Choose the right size calibration target.
    • Perform calibration at the approximate working distance (WD) of your final application.
    • The target should have a high feature count.
    • Collect images from different areas and tilts.
    • Use good lighting.
    • Calibration is only as accurate as the calibration target used. Use laser or inkjet printed targets only to validate and test.
    • Per sample, proper mounting of calibration target and camera.
    • Remove bad observations. Carefully inspect reprojection errors.
    • Obtaining a low re-projection error does not equal a good camera calibration. Be careful of over fitting.