How does opencv camera calibration work?


#1

Im using java and want to use solvePnP
I also would like to figure out how to find my objectPoints


#2

Yes, for solvePnP(), you need to calibrate the camera. It is in Python, but you can see our utility routine here:


The Java would be pretty similar, or you could just use the Python, since you just need the output numbers. There is also a tutorial here: https://docs.opencv.org/3.4/dc/dbb/tutorial_py_calibration.html

The other thing you need is a checkerboard image: https://github.com/ligerbots/VisionServer/blob/master/data/calibration/chessboard_9x6.png
You will want to print a copy with an accurate size of the square. 1 inch should work on US Letter paper. Double check the size on the printed copy. Mount the paper to a flat board and make sure that there is a small white border visible all the way around.

The procedure would be:

  1. set up camera to capture images. Make sure the resolution is the same as for competition.
  2. capture lots of images of the checkerboard. You actually want to be pretty close in for many of the shots. Get images with the checkerboard in all areas of the picture. You need 20 or more good images, more is better.
  3. Run all the images through the calibration routine and make sure to output copies with the found corners drawn on.
  4. Look through all the output images from #3, and remove any input files that are not clean and have the corners found correctly.
  5. Run the good images through again, and save the numbers.

In terms of finding the corners, there are lots of techniques. Our white paper might be helpful:


#3

so how exacly does solvePnP in java work?
how does cameraCalibration work?
like what should i put in and what do i get out? its not very clear to me


#4

One other question - will I need to calibrate for each individual camera (i.e. would there be significant differences between the same camera type mounted on both comp and practice bots) or is it reasonable to assume that the calibration would be “close enough” to the same?