Camera Calibration Toolbox for Matlab

Second calibration example - Calibration using Zhengyou Zhang's data

The previous example showed you how to run calibration from raw images. It is worth noticing that our toolbox may also be used in case where some calibration data have been previously computed. As an illustration, let us use our calibration engine on Zhengyou Zhang's calibration data that he made available on his calibration page at Microsoft Research. Do not bother downloading the data from there, we have it all ready for you right here just one mouse click away: (621Kb zipped). After download, retrieve all the files present in the package in a directory called zhang_data (this should be automatic). This directory contains the original calibration images (five of them) used by Zhang (in tif format), together with the planar calibration rig model and the extracted corner coordinate files that Zhengyou Zhang distributes on his web page. In addition, you will find a small matlab script file called demo_script.m.
Under Matlab, run that script file demo_script.m. This script converts all Zhang's data into my calibration format, reads in the images, runs through the main calibration engine, shows the results (intrinsic + extrinsic), and saves them under a file called Calib_Results.mat. This small script demonstrates that our calibration toolbox may easily be used in cases where some data have already been extracted (in this case, the corner coordinates). Observe that setting the variable dont_ask to one lets you use the main toolbox functions (optimization + graphical display) in script mode without being prompted. This is also quite useful for including calibration calls in your own matlab script files. In this present example, compare our calibration results (fc, cc, kc, Rc_1, Tc_1, Rc_2, Tc_2, ... , Rc_5, Tc_5) with Zhang's. Quite similar no? (observe that our distortion model includes two additional terms accounting for tangential distortion. The other terms are defined in the exact same way. For more information, visit the page describing the calibration parameters.

Once the script is finished running, we may want to try to include the skew coefficient alpha_c in the optimization. For that purpose, set the binary variable est_alpha to 1 (est_alpha = 1), and click on Calibration. Observe that the final computed skew coefficient alpha_c is very close to zero (i.e. pixels are rectangular). For more information, visit the page describing the calibration parameters.

As a final ultimate comparison, you may want to run the estimation is the exact same configuration as Zhang. For that, disable the tangential distortion part of the model and limit the radial distortion model up to the 4th degree (est_dist = [1;1;0;0;0]), and activate the skew estimation (est_alpha = 1). After calibration, you should observe that our results are exactly the same as Zhang's. To compare skew estimation, look at the camera matrix KK. Zhang's skew coefficient is defined as fc(1)*alpha_c, which is the (1,2) entry of the camera matrix KK. For more information, visit the page describing the calibration parameters.

You may also try to re-extract the square corners on the calibration images, by clicking on Recomp. corners. Select all the images, the window size of your choice (for example wintx = 6,winty = 6), and the automatic mode (required here). Then run calibration again, and compare the results. As a general advice, we recommend NOT to use such a pattern for calibration (disjoint squares generating asymmetric corner features) . It is better to use symmetric corner features such as the corners of a checkerboard pattern (the pattern used in the first example). To retrieve that pattern, visit that link.

Back to main calibration page