Skip to content

Template specification

James Booth edited this page Oct 19, 2015 · 1 revision

Templates are YAML files which formalise a landmark set by specifying it's size, connectivity and labels.

The file must contain a groups array containing dictionaries. Each dictionary describe a group of landmarks with the fields:

  • label - the name of the group (required)
  • points - the number of points in the group (required)
  • connectivity - an array of tuples that can be of the form (where a and b are between 0 and the group size)
    • a b - a is connected to b
    • a:b - a is connected to a+1, which is connected to a+2, and so on until b

In order to get all points to be connected in a cycle, you can use the shortcut connectivity: cycle, which is equivalent to:

connectivity:
  - 0:size-1
  - size-1 0

json files following the same structure are also valid templates for the landmarker client (although not for the server)

Landmark files

Ordering is important: the template is used to generate / validate landmarks files, as such it is important to maintain consistency i.e if order of the groups is changed, the landmarks files will not correspond anymore.

As landmarks files contain all the information necessary, the landmarker will also accept ljson file as templates by inferring the template.

A cli script is available in meta/template, you can use it as such:

./meta/template convert asset01.ljson dummy_template.yaml

to convert an ljson file into a valid yaml template. Read the top comment in the script file for more detailed usage information.

Examples

A minimal template with no groups:

groups:
  - label: all
    points: 36

A simple facial landmarks templates:

groups:
  - label: mouth
    points: 6
  - label: nose
    points: 3
    connectivity:
      - 0 1
      - 1 2
  - label: left_eye
    points: 8
    connectivity:
      - 0:7
      - 7 0
  - label: right_eye
    points: 8
    connectivity: cycle
  - label: chin
    points: 1