![](http://images-20200215.ebookreading.net/11/4/4/9781568814773/9781568814773__a-hitchhikers-guide__9781568814773__bg21e.png)
i
i
i
i
i
i
i
i
18.7. Augmented Reality (AR) 525
behave as if it were lying in the marker’s frame of reference by applying the
transformation to it.
In the examples covered in Chapter 8, identification of the points around
the square marker was done manually. In the ARToolKit, this process is auto-
mated by carrying out an automatic pattern recognition to identify the four
corners of the marker. However, before t his can be done, the camera must be
calibrated. Calibration of the camera is necessary to determine any distortion
in the lens as well as the field of view and aspect ratio. The camera parameters
are stored in a file “data/camera
para.dat” in the example code. Correcting for
distortion is necessary because it helps in the recognition of the marker. By
knowing the field of view, aspect ratio and the marker ’s real-world size, one
can also get an approximate value for the distance it is away from camera.
The process of r ecognizing the marker and hence determining its corner
positions in the 2D camera’s image requires some knowledge of the pattern in
the marker. This information is stored in a file; for the basic ARToolKit pat-
tern, this file is “data/patt.hiro”.
7
The process of recognition is only explained
briefly in the ARToolKit documentation, but it suggests that there are several
stages. These are:
1. Turn the image into a binary bitmap, i.e., every pixel is represented by
a binary state—black or white. A threshold intensity level is set. Above
this threshold the pixel value is 1; below it the pixel value is 0.
2. Using the binary image, the ARToolKit attempts to identify a set of
lines in the image. (Some of these will hopefully be identified as the
edges round the m arker.)
3. Try to find the places where these lines meet to form the corners of the
possible image of the marker.
4. Read the pattern from the marker’s pattern file and, using it as a tem-
plate, attempt to match it to the region bounded by the possible corners
and edges of the putative marker.
5. When a match is detected with some degree of confidence, the homog-
raphy that maps the marker’s and camera’s frames of reference may be
determined by using an equation analogous to Equation (8.4).
7
It is possible to build this pattern information for other “custom” markers; you should
consult the ARToolKit documentation for details on how to do this. It is also possible to
instruct the ARToolKit to look for several different markers in the same image; again, consult
the documentation for information on how to do this.