Print the pattMulti.pdf pattern shown in Figure 1.
Run multiTest from the bin directory.
Try to turn the pattern in different directions and observe the color of the individaul cubes. You will notice that red cubes are displayed where a marker is occluded. How is this possible?
We use the multiMarker tracking principle: a set of markers are defined based on their relative positions. When at least one marker is visible we can compute the position of the marker set in the camera CS.
We now look at the code of multiTest to understand how to program this feature. Open multiTest.c from the examples/multi directory.
if( (config = arMultiReadConfigFile(config_name)) == NULL ) { printf("config data load error !!\n"); exit(0); }
We now have config (a ARMultiMarkerInfoT structure) and config_name (a specific file, here: Data/multi/marker.dat). The MultiMarker Configuration File contains the list of all patterns and their exact positions within the fixed CS (this can be with respect to the corner of one marker, the middle of the plane of the set of markers, or an arbitrary position).
The detection step remains the same, but the computing of the transformation is different:
if( (err=arMultiGetTransMat(marker_info, marker_num, config)) < 0 ) { argSwapBuffers(); return; }
The arMultiGetTransMat function doesn't give the position of each marker in the camera CS, but the position of the fixed CS in the camera CS, and the relative position of each marker in the fixed CS. You can employ the resulting transformations to directly display object on any part of the set (for a flat sheet, in any part of that sheet).
In the multiTest example, the draw function used the position of the fixed CS (config->trans), and also the position of marker (config->marker[i].trans) to display the cube.
for( i = 0; i < config->marker_num; i++ ) { if( config->marker[i].visible >= 0 ) draw( config->trans, config->marker[i].trans, 0 ); else draw( config->trans, config->marker[i].trans, 1 ); }
You can easily combine this multiMarker tracking with distinct marker tracking to realize more complex applications.