ljson_importer

ljson_importer(filepath)[source]

Importer for the Menpo JSON format. This is an n-dimensional landmark type for both images and meshes that encodes semantic labels in the format. Landmark set label: JSON Landmark labels: decided by file

Parameters:filepath (str) – Absolute filepath of the file.
Returns:loaded landmarks
Return type:np.ndarray

pts_importer

pts_importer(filepath, image_origin=True, z=False, **kwargs)[source]

Importer for the PTS file format. Assumes version 1 of the format. Implementations of this class should override the _build_points() which determines the ordering of axes. For example, for images, the x and y axes are flipped such that the first axis is y (height in the image domain). Note that PTS has a very loose format definition. Here we make the assumption (as is common) that PTS landmarks are 1-based. That is, landmarks on a 480x480 image are in the range [1-480]. As Menpo is consistently 0-based, we subtract 1 off each landmark value automatically. If you want to use PTS landmarks that are 0-based, you will have to manually add one back on to landmarks post importing. Landmark set label: PTS

Parameters:
  • filepath (str) – Absolute filepath of the file.
  • image_origin (bool, optional) – If True, assume that the landmarks exist within an image and thus the origin is the image origin.
  • **kwargs (dict, optional) – Any other keyword arguments.
Returns:

imported points

Return type:

np.ndarray

ljson_exporter

ljson_exporter(lmk_points, filepath, **kwargs)[source]

Given a file handle to write in to (which should act like a Python file object), write out the landmark data. No value is returned. Writes out the LJSON format which is a verbose format that closely resembles the labelled point graph format. It describes semantic labels and connectivity between labels. The first axis of the format represents the image y-axis and is consistent with ordering within Menpo.

Parameters:
  • lmk_points (np.ndarray) – The shape to write out.
  • filepath (str) – The file to write in to

pts_exporter

pts_exporter(pts, file_handle, **kwargs)[source]

Given a file handle to write in to (which should act like a Python file object), write out the landmark data. No value is returned. Writes out the PTS format which is a very simple format that does not contain any semantic labels. We assume that the PTS format has been created using Matlab and so use 1-based indexing and put the image x-axis as the first coordinate (which is the second axis within Menpo). Note that the PTS file format is only powerful enough to represent a basic pointcloud. Any further specialization is lost.

Parameters:
  • pts (np.ndarray) – points to save
  • file_handle (file-like object) – The file to write in to