chili-epfl / chilitags

Robust Fiducial Markers for Augmented Reality And Robotics
http://chili.epfl.ch/software
121 stars 57 forks source link

Add 3D localization of markers/set of markers #7

Closed severin-lemaignan closed 11 years ago

severin-lemaignan commented 11 years ago

This pull-request introduces 3D (actually, 6D) localization of markers. It also introduces a simple YAML-based configuration file that allows users to define 'objects' as a set of markers.

Sample usage (extracted from samples/objects/objects.cpp):

//...

cv::Mat tInputImage;
chilitags::DetectChilitags detector(&tInputImage);

chilitags::Objects objects(cameraMatrix, distCoeffs, configFilename);

while(true) {

    // [update input image]

    detector.update();

    for (auto& kv : objects.all()) {
        // name of the object
        cout << kv.first;
        // 4x4 transformation matrix in camera's frame
        cout << " at " << kv.second << endl;
    }

}

The constructor takes (optionally) the name of the YAML configuration file. Here a sample:

myobject:
    - marker: 0
      size: 27
      translation: [-72.75, -112.5, 0.]
      keep: true
    - marker: 1
      size: 27
      translation: [72.75, -112.5, 0.]
      rotation: [0., 0., 90.]

This sample defines an object 'myobject' that contains 2 markers (id 0 and 1). You can specify the size, translation and rotation of each markers, relative to the object origin.

Refer to `share/markers_configuration_sample.yml for the full documentation.

The algorithm computes the position of the object with as many markers as possible, but some may be missing. By specifying several markers for a single object, robust (and stable) localization can be achieved.

The 6D localization relies on OpenCV's 'solvePnP' implementation. The commit also provides an estimator to smooth the localization. The gain of the estimator (from 1.0 -> no filtering, to 0.0 -> strong damping) can be set when calling the chilitags::Objects constructor.

Note that: