Tracking your own model
Description: How to track a custom object.Tutorial Level: BEGINNER
Contents
To use the tracker with your own objects, you need to add it to the visp_tracker object database.
The object database is located in the 'models' directory. By default, two objects are provided: 'laas-box' and 'floppy-box'.
You can either add your own object to this directory or choose to put your directory elsewhere. In this case, you have to fill the '~model_path' parameter accordingly when starting the client (or initializing the object using the 'init_tracker' service).
Required files
Consider that you want to add a new object called 'my-box'. In the object directory, you will find:
my-box.wrl: tracked object VRML model.
my-box.init: initialization file used to estimate the initial pose by clicking on 2d points.
tracker.yaml: best tracking parameters for this object (optional).
Additionally, my-box.0.pos contains the last initial pose and is created automatically by the client.
Modeling the object
Any 3d modeling software can be used as long as it can export its models to the VRML format.
Keep in mind that this tracker tracks lines. Therefore, when loading an object, the lines are extracted from the 3d model and all the other information are discarded.
Warning: the surface normals are used to determine if a face is visible or not. They are taken into account and if they are not correctly oriented (normal vector toward outside the object), the tracker will fail.
It is also important to notice that the tracking frequency decreases as the number of tracked lines increases. Therefore, do not give to the tracker a full model of your object, trim all the lines which cannot be tracked precisely (bad gradient, hardly visible...).
Popular modeling software includes:
Blender - open source, powerful modeling software
AC3d - proprietary/non-free simple modeling software
Writing the initialization file
The initialization file is used by the client to compute the object initial pose.
To compute the initial pose, the client does as follow:
- grab an image
- let the user click on a predetermined object location such as a corner
- repeat for all points in the initialization file
- compute the best pose such as the 3d pose projection matches the clicked points.
To do so, we need to associate 2d points with particular 3d points in the tracked object. This association is provided by the initialization file.
Here is the initialization file for the laas-box:
4 -0.175 0.175 0.156 -0.175 -0.175 0.156 0.175 -0.175 0.156 -0.175 -0.175 -0.156
In this example, the user will click on four points. The first point coordinates are (X = -0.175, Y = 0.175, Z = 0.156).
Using your modeling software, determine the 3d coordinates of four particular points of your object (four corners for instance). They should not be on the same plane.
It is a good idea to provide an image showing in which order and where to click on the object. This file is optional.
Providing the recommended tracking parameters
Optionally, you can provide the tracker.yaml file with specific tracking parameters:
Here is a good starting point:
{
mask_size: 3,
mu1: 0.5,
mu2: 0.5,
n_mask: 180,
ntotal_sample: 800,
range: 10,
sample_step: 3.,
threshold: 2000.0
}This file is optional and not automatically read.






