Loading...
 

CFTechno

PutPi : Camera Calibration

Published by admin on 2014-06-05

Objective


As mentioned in the "PutPi : The Camera" blog entry it's possible (even very likely) that the lens will cause a distortion of the image.
Image
As the goal is to measure the exact position of the TOMI clip (it's four LEDs) any image distortion will also cause errors in the position measurements.

The objective of this blog entry is to explain how one can calibrate the camera. The final result of this procedure are two files that contains specific lens data with which the distortion can be corrected. Those two files are unique for each and every camera/lens. The PutPi software will load those files and uses them to correct all images received from the camera before try to measure the position of the TOMI clip in those images.

If you want to know more about the theory behind the calibration procedure please visit this link : Camera calibration With OpenCV

The procedure


Step 1 : Preparing the hardware

Print the following image
Image
Use a good printer, white paper, slightly heavier then standard. Print as large as possible.

Find yourself something flat, thick and large enough on which you could glue the chessboard pattern printout. I used a wooden board and by using a metal ruler checked its flatness in all direction.
Image
You could also use glass or a metal sheet, just make sure it's flat!

Place\stick 4 or 5 strokes of double-sided tape on the board. Place them close to each other, not overlapping.
Image
Remove the other protection layer and glue the chessboard pattern printout to the board.
Image

Step 2 : Preparing the software

Download the calibration software from this link : PutPi calibration and run this setup. It will install the calibration software on your system. I assume that you already installed the drivers for the camera as mentioned in "PutPi : The camera" blog entry.

Step 3 : Running the software

As soon as you start the calibration software you just installed it will show a text window and a image window. The text window will inform you about the calibration progress. The image window shows the image recorded by the camera.

If you point the camera in the direction of your chessboard board it will try to "find" all the squares. If it found them it will start drawing dots and lines. This will inform you that the software saw the chessboard and was able to find all the marks.
Image
It will show this image for around 1.5 second before showing a newly recorded image. Because of that 1.5 seconds it seems like the camera is recording very slow.

If the dots are all in the correct position (in between the black and white spaces ) and the lines connection the dots are straight as shown in the image above, press Y or y. This will tell the software that you inspected the image and that it was good enough to be used in the calibration procedure.

Move the camera to record the chessboard pattern from another angle, again check the quality of the dots and lines and press Y or y. You have to do this 10 times. Makes sure that you record images from as much angles as possible and make sure that the pattern is not only placed in one side of the image. Use enough light!

Step 4 : Inspecting the result

After accepting 10 images the software will inform you via the text window that it's calculating the calibration result. This could take some time. When the calculation is finished two things will happen.

In the text window a value with the name "RMS" will be show. This value needs to be as close to zero as possible. Values below 0.3 are good, below 0.2 are better and lower are great. If that value is high then press "escape" and start again!

The image below shows a bad RMS value
Image
At the same time the software shows the RMS value it will also show a second image window. This window is the recalculated and hopefully undistorted image. If the RMS values is high some weird results can be seen biggrin
Image

But with a good RMS value you will see that the distortion is almost gone
Image
Image

You're done and can stop the software by pressing "escape"

Step 5 : The final files

The result of a calibration are two files: putpi_Distortion.xml and putpi_Intrinsics.xml These are saved in the same directory as where you have installed the calibration software. PutPi will use those two files to correct any recorded image.

Powered by Tiki Wiki CMS Groupware | Theme: Jqui