Move the sources to trunk
[opencv] / docs / appPage / Calibration / calibration.htm
1 <HTML>\r
2   <HEAD>\r
3     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">\r
4     <META NAME="GENERATOR" CONTENT="Microsoft FrontPage 4.0">\r
5     <TITLE>Camera Calibration Tool</TITLE>\r
6     <!-- Changed by: Jean-Yves Bouguet, 31-Dec-1999 -->\r
7   </HEAD>\r
8   <BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000CC" VLINK="#0000FF" ALINK="#FF0000">\r
9     <A NAME="TOP">\r
10     <!-- <CENTER>\r
11 \r
12   <BLOCKQUOTE>\r
13 \r
14   <table border = 3 WIDTH="70%" >\r
15 \r
16   <TR><TD>\r
17 \r
18     -->\r
19     <CENTER><TABLE CELLSPACING=0 CELLPADDING=5 WIDTH="90%" BGCOLOR="#6A9BED" NOSAVE >\r
20         <TR NOSAVE>\r
21           <TD NOSAVE>\r
22             <CENTER><I><FONT COLOR="#000000"><FONT SIZE=+4>Camera Calibration Tool</FONT></FONT></I></CENTER>\r
23           </TD>\r
24         </TR>\r
25       </TABLE></CENTER>\r
26     <!--\r
27     \r
28   </TD></TR>\r
29     \r
30   </table>\r
31 \r
32     </BLOCKQUOTE>\r
33     \r
34   </center>\r
35 \r
36     -->\r
37 \r
38     <br><br>\r
39 \r
40     <CENTER><IMG SRC="pict_calib.jpg" HEIGHT=600 WIDTH=990></CENTER>\r
41 \r
42     <H1>\r
43       Description\r
44     </H1>\r
45     The camera calibration tool lets you calibrate any video camera very accurately\r
46     and in few seconds.\r
47     \r
48     <br><br>\r
49       The user presents a flat checkerboard pattern in front of the camera,\r
50       and the program automatically acquires a number of images and uses them\r
51       to compute the intrinsic camera parameters (focal length, principal point,\r
52       distortion coefficients) as well as the extrinsic parameters (3D position\r
53       of the pattern for each image).\r
54     <br><br>\r
55     Since the corners of the pattern are located automatically on each image,\r
56       the entire procedure is fully automatic. Once calibration is done, the\r
57       program lets you undistort the video images in real time (at frame rate).\r
58       The lens distortion model consists of two terms: a radial distortion term\r
59       (up to the fourth order) and a tangential distortion term (two scalars\r
60       for encoding the angular orientation of the focal plane with respect to\r
61       the sensor plane). Consequently, the lens distortion model is parameterized\r
62       using four scalar coefficients.\r
63 <br><Br>\r
64     A complete tutorial of the algorithm with matlab code is provided, see\r
65       <A HREF="#Tutorial">Tutorial Section below</A>.\r
66     \r
67     <H2>\r
68       DirectShow Filter Application\r
69     </H2>\r
70     Note that this filter requires that you have DirectShow 6.0 or greater installed\r
71     with <B>graphedt.exe&nbsp; </B>(DirectShow 6.0 for NT4.0, DirectShow 7.0 for\r
72     Win 98 or Win2000) \r
73     (<A HREF="http://www.microsoft.com/downloads/release.asp?ReleaseID=16927">http://www.microsoft.com/downloads/release.asp?ReleaseID=16927</A> ~128MB[!]). \r
74     You will also need a video camera source filter which should\r
75     be supplied by your USB camera vendor. <!-- except most don't support NT4.0. -->\r
76 <!-- %%Some friendly advice from Uncle Gary?? -->\r
77 <!--    Win2000 is your best bet for development, for just running the filter graph, Win98 will do.. An example filter graph is shown below (with the calibration filter processing a video source from a Matrox Meteor II card that we wrote ourselves) and then passing the output to a video renderer. -->\r
78 \r
79     Microsoft* Windows* 2000 may be the most suitable operating system\r
80     for development since many vendors do not supply filters for\r
81     Windows NT 4.0. However, Windows 98 will be adequate for just\r
82     running the filter graph\r
83     <br><br>\r
84     An example filter graph is shown below. It is running our own\r
85     calibration filter that processes a video source from a Matrox\r
86     Meteor II card and then passes the output to a video renderer.\r
87 \r
88     <BR><br>\r
89     <CENTER><IMG SRC="CalibFilterGraph.png" HEIGHT=210 WIDTH=601></CENTER>\r
90 \r
91     <a name="properties">\r
92     <br>Right clicking on the CalibFilter brings up its property control page\r
93       as follows:\r
94 \r
95 \r
96     <br>\r
97     <BR>\r
98     <CENTER><IMG SRC="CalibFilterLabled.png" HEIGHT=284 WIDTH=384></CENTER>\r
99     \r
100     <H2>\r
101       Controls\r
102     </H2>\r
103     <B><FONT SIZE=+2>[1]</FONT></B> Enter the\r
104     number of columns (Squares per row)in your calibration checkerboard.\r
105     Click "Apply" [12] to enter.<br>\r
106     \r
107     <B><FONT SIZE=+2>[2]</FONT></B> Enter the\r
108       number of rows (Squares per column)in your calibration checkerboard.\r
109       Click "Apply" [12] to enter.<br>\r
110       \r
111     <B><FONT SIZE=+2>[3]</FONT></B> Actual\r
112       size of squares in your calibration checkerboard (in whatever units --\r
113       say cm). Click "Apply" [12] to enter.<br>\r
114       \r
115     <B><FONT SIZE=+2>[4]</FONT></B> Start automatic\r
116       collection of calibration frames.<br>\r
117 \r
118     <B><FONT SIZE=+2>[5]</FONT></B> Save current\r
119       set of calibration parameters to disk.<br>\r
120       \r
121     <B><FONT SIZE=+2>[6]</FONT></B> Load previously\r
122       saved calibration parameters.<br>\r
123 \r
124     <B><FONT SIZE=+2>[7]</FONT></B> If you've\r
125       just calibrated the camera, or have loaded [6] previous calibration parameters,\r
126       checking this box causes the computation of the undistorted image in real\r
127       time. If this box is not checked, the raw video frames are displayed.\r
128       You must click "Apply" [12] to register the check.<br>\r
129 \r
130     <B><FONT SIZE=+2>[8]</FONT></B> Checking\r
131       this box causes an OpenGL display to show the tracking of the calibration\r
132       checkerboard. You must click "Apply" [12] to register the check.<br>\r
133 \r
134     <B><FONT SIZE=+2>[9]</FONT></B> Set how\r
135       many frames of the calibration checkerboard you want to collect before\r
136       performing calibration (between 10 and 20 is usually enough, use more only\r
137       if high accuracy is desired). Click "Apply" [12] to enter.<br>\r
138 \r
139     <B><FONT SIZE=+2>[10]</FONT></B> Set how\r
140       number of miliseconds of delay between collecting frames of the calibration\r
141       checkerboard when you start [4] calibration. This allows you as much\r
142       time as desired to move the calibration checkerboard around the video scene\r
143       before the next frame is taken during calibration. Click "Apply"\r
144       [12] to enter.<br>\r
145       \r
146     <B><FONT SIZE=+2>[11]</FONT></B> The current\r
147       calibration parameters are displayed in this box.<br>\r
148       \r
149     <B><FONT SIZE=+2>[12]</FONT></B> You must\r
150       click "Apply" after setting any or all of [1], [2], [3], [9] and/or [10].\r
151 \r
152     <H2>\r
153       How To...\r
154     </H2>\r
155     \r
156     <h3>\r
157       Calibrate a camera\r
158     </h3>\r
159 \r
160     <B>(a)</B> Get or make a black and white checkerboard calibration object\r
161     as shown in the images above or animated gif's below.\r
162     <BR><B>(b)</B> Enter the number of columns ("squares per row") in [1] and\r
163     number of rows (squares per column) in [2]; Enter the size of a square\r
164     <!-- %%Whatever units? -->\r
165     in whatever units in [3] (optional) ; Enter the number of frames that you\r
166     want to collect in [9] (10-20 usually suffices); Enter the minimum time\r
167     between capturing frames to allow you time to move the calibration object.\r
168     <BR><B>(c)</B> Click "Apply" [12].\r
169     <BR><B>(d)</B> Click "Start" [4].\r
170     <BR><B>(e)</B> Move the checkerboard around. The number of frames\r
171     collected will display in [11]. When all frames are collected it will solve\r
172     for the calibration parameters and display them in [11].\r
173     <BR><B>(f)</B> Checking [7] followed by clicking "Apply" [12] causes the\r
174     rectified video image to be displayed as shown in the second example below.\r
175     \r
176     <br><br>Notes: When calibrating, the video image flashes when a frame is captured.\r
177       It won't capture unless the colored lines are drawn on the checkerboard\r
178       as shown in the examples below. You must move the calibration object\r
179       around -- if your views are too much alike, you will get an ill-conditioned\r
180       matrix with resultant divide by zero when the filter solves for the camera\r
181       calibration parameters.\r
182       \r
183     <h3>\r
184       Save calibration parameters to a file:\r
185     </h3>\r
186     <B>(a) </B>Click "Save" [5] and a dialog box will prompt you for\r
187     saving the calibration parameters under a text file. Click this\r
188     <a href="cam_model.htm">link</a> for information on the camera model, and the content of the text file.\r
189       \r
190     <h3>\r
191       Load previously stored calibration parameters:\r
192     </h3>\r
193     <B>(a)</B> Click "Load" [6] and a dialog box will allow you to select\r
194     a calibration parameter file.\r
195     <BR><B>(b)</B> Calibration parameters will appear in [11].\r
196       \r
197     <h3>\r
198       Turn image rectification on and off:\r
199     </h3>\r
200     <B>(a)</B> On: Check the "Undistortion" box [7]. Click "Apply" [12].\r
201     <BR><B>(b)</B> Off: Un-check the "Undistortion" box [7]. Click "Apply"\r
202     [12].\r
203       \r
204     <h3>\r
205       Turn the 3D OpenGL window on and off:\r
206     </h3>\r
207     <B>(a)</B> On: Check the "Show 3D window" box [8]. Click "Apply" [12].\r
208     <BR><B>(b)</B> Off: Un-check the "Show 3D window" box [8]. Click\r
209     "Apply" [12].\r
210 \r
211     <H1>\r
212       Examples\r
213     </H1>\r
214     The following movie shows the 3D pose of the calibration object being computed\r
215     in real time after the camera has been calibrated.\r
216     <br>\r
217     <BR>\r
218     <CENTER><IMG SRC="calibration_shot.png" HEIGHT=253 WIDTH=528></CENTER>\r
219 \r
220 \r
221     <br>\r
222     The next picture shows image undistortion performed by the filter.\r
223 \r
224     <br><BR>\r
225     <CENTER><IMG SRC="undistortion_shot.png" HEIGHT=226 WIDTH=721></CENTER>\r
226 \r
227     <H1>\r
228       <A NAME="Tutorial"></A>Tutorial and calibration toolbox</H1>\r
229     In addition to the <A HREF="../../ref/OpenCVRef_3dReconstruction.htm#ch6_calibration">\r
230     OpenCV implementation</A> of the calibration functions and tool, we provide a complete\r
231     tutorial and calibration toolbox for MATLAB. It can be downloaded from\r
232     <a href="http://www.sourceforge.net/projects/opencvlibrary">OpenCV page at Source Forge</a>\r
233     <br><br>\r
234     <hr noshade size=2 width=100%>\r
235 \r
236   </BODY>\r
237 </HTML>\r
238 \r
239 \r
240 \r