<!-- # hard line break macro for HTML -->

# fiftyone.utils.openlabel

Utilities for working with datasets in
[OpenLABEL format](https://www.asam.net/index.php?eID=dumpFile&t=f&f=3876&token=413e8c85031ae64cc35cf42d0768627514868b2f).

Copyright 2017-2026, Voxel51, Inc.
<br/>
[voxel51.com](https://voxel51.com/)
<br/>
<br/>

**Classes:**

| [`SegmentationType`](#fiftyone.utils.openlabel.SegmentationType)(\*values)                                     | The FiftyOne label type used to store segmentations                                                               |
|----------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------|
| [`OpenLABELImageDatasetImporter`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter)([dataset_dir, ...]) | Importer for OpenLABEL image datasets stored on disk.                                                             |
| [`OpenLABELVideoDatasetImporter`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter)([dataset_dir, ...]) | Importer for OpenLABEL video datasets stored on disk.                                                             |
| [`OpenLABELAnnotations`](#fiftyone.utils.openlabel.OpenLABELAnnotations)()                                     | Annotations parsed from OpenLABEL format able to be converted to FiftyOne labels.                                 |
| [`OpenLABELStreamInfos`](#fiftyone.utils.openlabel.OpenLABELStreamInfos)([infos])                              | A collection of multiple [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo) objects.          |
| [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo)([frame_numbers, stream, ...])           | Information about a stream used to gather specific objects for a media file.                                      |
| [`OpenLABELGroup`](#fiftyone.utils.openlabel.OpenLABELGroup)()                                                 | A utility for parsing groups of OpenLABEL elements                                                                |
| [`OpenLABELObjects`](#fiftyone.utils.openlabel.OpenLABELObjects)()                                             | A collection of [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) and corresponding utility methods. |
| [`OpenLABELStreams`](#fiftyone.utils.openlabel.OpenLABELStreams)()                                             | A collection of OpenLABEL streams.                                                                                |
| [`AttributeParser`](#fiftyone.utils.openlabel.AttributeParser)()                                               | Methods used to parse attributes from OpenLABEL annotations.                                                      |
| [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)(coords[, attributes, stream])                     | A single OpenLABEL shape like a bounding box or polygon.                                                          |
| [`OpenLABELBBox`](#fiftyone.utils.openlabel.OpenLABELBBox)(coords[, attributes, stream])                       | An OpenLABEL bounding box.                                                                                        |
| [`OpenLABELPoly2D`](#fiftyone.utils.openlabel.OpenLABELPoly2D)(coords[, attributes, stream])                   | An OpenLABEL polyline.                                                                                            |
| [`OpenLABELPoint`](#fiftyone.utils.openlabel.OpenLABELPoint)(coords[, attributes, stream])                     | An OpenLABEL keypoint.                                                                                            |
| [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes)([shapes, attributes, stream])                   | A collection of OpenLABEL shapes.                                                                                 |
| [`OpenLABELStream`](#fiftyone.utils.openlabel.OpenLABELStream)(name[, type, properties, ...])                  | An OpenLABEL stream corresponding to one uri or file_id.                                                          |
| [`OpenLABELMetadata`](#fiftyone.utils.openlabel.OpenLABELMetadata)(metadata_dict)                              | A parser and storage for OpenLABEL metadata.                                                                      |
| [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject)(key[, name, type, bboxes, ...])                 | An object parsed from OpenLABEL labels.                                                                           |

### *class* fiftyone.utils.openlabel.SegmentationType(\*values)

Bases: `Enum`

The FiftyOne label type used to store segmentations

**Attributes:**

| [`INSTANCE`](#fiftyone.utils.openlabel.SegmentationType.INSTANCE)   |    |
|---------------------------------------------------------------------|----|
| [`POLYLINE`](#fiftyone.utils.openlabel.SegmentationType.POLYLINE)   |    |
| [`SEMANTIC`](#fiftyone.utils.openlabel.SegmentationType.SEMANTIC)   |    |

#### INSTANCE *= 1*

#### POLYLINE *= 2*

#### SEMANTIC *= 3*

### *class* fiftyone.utils.openlabel.OpenLABELImageDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, label_types=None, use_polylines=False, shuffle=False, seed=None, max_samples=None, skeleton=None, skeleton_key=None)

Bases: [`LabeledImageDatasetImporter`](fiftyone.utils.data.importers.md#fiftyone.utils.data.importers.LabeledImageDatasetImporter), [`ImportPathsMixin`](fiftyone.utils.data.importers.md#fiftyone.utils.data.importers.ImportPathsMixin)

Importer for OpenLABEL image datasets stored on disk.

See [this page](../user_guide/import_datasets.md#openlabelimagedataset-import) for format details.

* **Parameters:**
  * **dataset_dir** (*None*) – the dataset directory. If omitted, `data_path`
    and/or `labels_path` must be provided
  * **data_path** (*None*) – 

    an optional parameter that enables explicit control
    over the location of the media. Can be any of the following:
    - a folder name like `"data"` or `"data/"` specifying a
      subfolder of `dataset_dir` where the media files reside
    - an absolute directory path where the media files reside. In
      this case, the `dataset_dir` has no effect on the location of
      the data
    - a filename like `"data.json"` specifying the filename of the
      JSON data manifest file in `dataset_dir`
    - an absolute filepath specifying the location of the JSON data
      manifest. In this case, `dataset_dir` has no effect on the
      location of the data
    - a dict mapping file_ids to absolute filepaths

    If None, this parameter will default to whichever of `data/` or
    `data.json` exists in the dataset directory
  * **labels_path** (*None*) – 

    an optional parameter that enables explicit control
    over the location of the labels. Can be any of the following:
    - a filename like `"labels.json"` specifying the location of
      the labels in `dataset_dir`
    - a folder name like `"labels"` or `"labels/"` specifying a
      subfolder of `dataset_dir` where the multiple label files
      reside
    - an absolute filepath to the labels. In this case,
      `dataset_dir` has no effect on the location of the labels

    If None, the parameter will default to looking for `labels.json`
    and `label/`
  * **label_types** (*None*) – a label type or list of label types to load. The
    supported values are
    `("detections", "segmentations", "keypoints")`.
    By default, all labels are loaded
  * **use_polylines** (*False*) – whether to represent segmentations as
    [`fiftyone.core.labels.Polylines`](fiftyone.core.labels.md#fiftyone.core.labels.Polylines) instances rather than
    [`fiftyone.core.labels.Detections`](fiftyone.core.labels.md#fiftyone.core.labels.Detections) with dense masks
  * **shuffle** (*False*) – whether to randomly shuffle the order in which the
    samples are imported
  * **seed** (*None*) – a random seed to use when shuffling
  * **max_samples** (*None*) – a maximum number of samples to load
  * **skeleton** (*None*) – a [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton)
    to reference when loading keypoints
  * **skeleton_key** (*None*) – the key in the OpenLABEL annotations pointing to
    the label of each keypoint matching the labels defined in the given
    `skeleton`

**Attributes:**

| [`has_dataset_info`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.has_dataset_info)     | Whether this importer produces a dataset info dictionary.                                                                                                         |
|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`has_image_metadata`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.has_image_metadata) | Whether this importer produces [`fiftyone.core.metadata.ImageMetadata`](fiftyone.core.metadata.md#fiftyone.core.metadata.ImageMetadata) instances for each image. |
| [`label_cls`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.label_cls)                   | The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this importer.                                       |

**Methods:**

| [`setup`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.setup)()                         | Performs any necessary setup before importing the first sample in the dataset.                      |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| [`get_dataset_info`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.get_dataset_info)()   | Returns the dataset info for the dataset.                                                           |
| [`close`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.close)(\*args)                   | Performs any necessary actions after the last sample has been imported.                             |
| [`get_media_sources`](#fiftyone.utils.openlabel.OpenLABELImageDatasetImporter.get_media_sources)() | Returns the media-source entries the importing dataset records before any sample is added, or None. |

#### *property* has_dataset_info

Whether this importer produces a dataset info dictionary.

#### *property* has_image_metadata

Whether this importer produces
[`fiftyone.core.metadata.ImageMetadata`](fiftyone.core.metadata.md#fiftyone.core.metadata.ImageMetadata) instances for each image.

#### *property* label_cls

The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this
importer.

This can be any of the following:

- a [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class. In this case, the
  importer is guaranteed to return labels of this type
- a list or tuple of [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes. In
  this case, the importer can produce a single label field of any of
  these types
- a dict mapping keys to [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes.
  In this case, the importer will return label dictionaries with keys
  and value-types specified by this dictionary. Not all keys need be
  present in the imported labels
- `None`. In this case, the importer makes no guarantees about the
  labels that it may return

#### setup()

Performs any necessary setup before importing the first sample in
the dataset.

This method is called when the importer’s context manager interface is
entered, `DatasetImporter.__enter__()`.

#### get_dataset_info()

Returns the dataset info for the dataset.

By convention, this method should be called after all samples in the
dataset have been imported.

* **Returns:**
  a dict of dataset info

#### close(\*args)

Performs any necessary actions after the last sample has been
imported.

This method is called when the importer’s context manager interface is
exited, `DatasetImporter.__exit__()`.

* **Parameters:**
  **\*args** – the arguments to `DatasetImporter.__exit__()`

#### get_media_sources()

Returns the media-source entries the importing dataset records
before any sample is added, or None.

Only importers of media-reference-backed samples provide these; see
[`fiftyone.utils.lerobot.LeRobotDatasetImporter`](fiftyone.utils.lerobot.md#fiftyone.utils.lerobot.LeRobotDatasetImporter).

### *class* fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter(dataset_dir=None, data_path=None, labels_path=None, label_types=None, use_polylines=False, shuffle=False, seed=None, max_samples=None, skeleton=None, skeleton_key=None)

Bases: [`LabeledVideoDatasetImporter`](fiftyone.utils.data.importers.md#fiftyone.utils.data.importers.LabeledVideoDatasetImporter), [`ImportPathsMixin`](fiftyone.utils.data.importers.md#fiftyone.utils.data.importers.ImportPathsMixin)

Importer for OpenLABEL video datasets stored on disk.

See [this page](../user_guide/import_datasets.md#openlabelvideodataset-import) for format details.

* **Parameters:**
  * **dataset_dir** (*None*) – the dataset directory. If omitted, `data_path`
    and/or `labels_path` must be provided
  * **data_path** (*None*) – 

    an optional parameter that enables explicit control
    over the location of the media. Can be any of the following:
    - a folder name like `"data"` or `"data/"` specifying a
      subfolder of `dataset_dir` where the media files reside
    - an absolute directory path where the media files reside. In
      this case, the `dataset_dir` has no effect on the location of
      the data
    - a filename like `"data.json"` specifying the filename of the
      JSON data manifest file in `dataset_dir`
    - an absolute filepath specifying the location of the JSON data
      manifest. In this case, `dataset_dir` has no effect on the
      location of the data
    - a dict mapping file_ids to absolute filepaths

    If None, this parameter will default to whichever of `data/` or
    `data.json` exists in the dataset directory
  * **labels_path** (*None*) – 

    an optional parameter that enables explicit control
    over the location of the labels. Can be any of the following:
    - a filename like `"labels.json"` specifying the location of
      the labels in `dataset_dir`
    - a folder name like `"labels"` or `"labels/"` specifying a
      subfolder of `dataset_dir` where the multiple label files
      reside
    - an absolute filepath to the labels. In this case,
      `dataset_dir` has no effect on the location of the labels

    If None, the parameter will default to looking for `labels.json`
    and `labels/`
  * **label_types** (*None*) – a label type or list of label types to load. The
    supported values are
    `("detections", "segmentations", "keypoints")`.
    By default, all labels are loaded
  * **use_polylines** (*False*) – whether to represent segmentations as
    [`fiftyone.core.labels.Polylines`](fiftyone.core.labels.md#fiftyone.core.labels.Polylines) instances rather than
    [`fiftyone.core.labels.Detections`](fiftyone.core.labels.md#fiftyone.core.labels.Detections) with dense masks
  * **shuffle** (*False*) – whether to randomly shuffle the order in which the
    samples are imported
  * **seed** (*None*) – a random seed to use when shuffling
  * **max_samples** (*None*) – a maximum number of samples to load
  * **skeleton** (*None*) – a [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton)
    to reference when loading keypoints
  * **skeleton_key** (*None*) – the key in the OpenLABEL annotations pointing to
    the label of each keypoint matching the labels defined in the given
    `skeleton`

**Attributes:**

| [`has_dataset_info`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.has_dataset_info)     | Whether this importer produces a dataset info dictionary.                                                                                                                   |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [`has_video_metadata`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.has_video_metadata) | Whether this importer produces [`fiftyone.core.metadata.VideoMetadata`](fiftyone.core.metadata.md#fiftyone.core.metadata.VideoMetadata) instances for each video.           |
| [`label_cls`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.label_cls)                   | The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this importer within the sample-level labels that it produces. |
| [`frame_labels_cls`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.frame_labels_cls)     | The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this importer within the frame labels that it produces.        |

**Methods:**

| [`setup`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.setup)()                         | Performs any necessary setup before importing the first sample in the dataset.                      |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| [`get_dataset_info`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.get_dataset_info)()   | Returns the dataset info for the dataset.                                                           |
| [`close`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.close)(\*args)                   | Performs any necessary actions after the last sample has been imported.                             |
| [`get_media_sources`](#fiftyone.utils.openlabel.OpenLABELVideoDatasetImporter.get_media_sources)() | Returns the media-source entries the importing dataset records before any sample is added, or None. |

#### *property* has_dataset_info

Whether this importer produces a dataset info dictionary.

#### *property* has_video_metadata

Whether this importer produces
[`fiftyone.core.metadata.VideoMetadata`](fiftyone.core.metadata.md#fiftyone.core.metadata.VideoMetadata) instances for each video.

#### *property* label_cls

The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this
importer within the sample-level labels that it produces.

This can be any of the following:

- a [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class. In this case, the
  importer is guaranteed to return sample-level labels of this type
- a list or tuple of [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes. In
  this case, the importer can produce a single sample-level label
  field of any of these types
- a dict mapping keys to [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes.
  In this case, the importer will return sample-level label
  dictionaries with keys and value-types specified by this
  dictionary. Not all keys need be present in the imported labels
- `None`. In this case, the importer makes no guarantees about the
  sample-level labels that it may return

#### setup()

Performs any necessary setup before importing the first sample in
the dataset.

This method is called when the importer’s context manager interface is
entered, `DatasetImporter.__enter__()`.

#### get_dataset_info()

Returns the dataset info for the dataset.

By convention, this method should be called after all samples in the
dataset have been imported.

* **Returns:**
  a dict of dataset info

#### close(\*args)

Performs any necessary actions after the last sample has been
imported.

This method is called when the importer’s context manager interface is
exited, `DatasetImporter.__exit__()`.

* **Parameters:**
  **\*args** – the arguments to `DatasetImporter.__exit__()`

#### *property* frame_labels_cls

The [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class(es) returned by this
importer within the frame labels that it produces.

This can be any of the following:

- a [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) class. In this case, the
  importer is guaranteed to return frame labels of this type
- a list or tuple of [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes. In
  this case, the importer can produce a single frame label field of
  any of these types
- a dict mapping keys to [`fiftyone.core.labels.Label`](fiftyone.core.labels.md#fiftyone.core.labels.Label) classes.
  In this case, the importer will return frame label dictionaries
  with keys and value-types specified by this dictionary. Not all
  keys need be present in each frame
- `None`. In this case, the importer makes no guarantees about the
  frame labels that it may return

#### get_media_sources()

Returns the media-source entries the importing dataset records
before any sample is added, or None.

Only importers of media-reference-backed samples provide these; see
[`fiftyone.utils.lerobot.LeRobotDatasetImporter`](fiftyone.utils.lerobot.md#fiftyone.utils.lerobot.LeRobotDatasetImporter).

### *class* fiftyone.utils.openlabel.OpenLABELAnnotations

Bases: `object`

Annotations parsed from OpenLABEL format able to be converted to
FiftyOne labels.

**Methods:**

| [`parse_labels`](#fiftyone.utils.openlabel.OpenLABELAnnotations.parse_labels)(base_dir, labels_path)         | Parses a single OpenLABEL labels file.                                   |
|--------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------|
| [`get_dimensions`](#fiftyone.utils.openlabel.OpenLABELAnnotations.get_dimensions)(file_id)                   | Get the width and height of a given URI or file id                       |
| [`get_labels`](#fiftyone.utils.openlabel.OpenLABELAnnotations.get_labels)(uri, label_types, frame_size, ...) | Get the FiftyOne labels corresponding to the annotations of a given URI. |

#### parse_labels(base_dir, labels_path)

Parses a single OpenLABEL labels file.

* **Parameters:**
  * **base_dir** – path to the directory containing the labels file
  * **labels_path** – path to the labels json file
* **Returns:**
  a list of potential file_ids that the parsed labels correspond to

#### get_dimensions(file_id)

Get the width and height of a given URI or file id

* **Parameters:**
  **file_id** – the unique identifier to a media file
* **Returns:**
  (width, height) of the given file

#### get_labels(uri, label_types, frame_size, seg_type, skeleton=None, skeleton_key=None)

Get the FiftyOne labels corresponding to the annotations of a given
URI. The results are two dictionaries, sample- and frame-level, mapping
field names to values and label objects.

* **Parameters:**
  * **uri** – the unique identifier to a media file
  * **label_types** – a list of label types to load. The
    supported values are
    `("detections", "segmentations", "keypoints")`.
  * **frame_size** – the (width, height) tuple for the media frame
  * **seg_type** – the [`SegmentationType`](#fiftyone.utils.openlabel.SegmentationType) to use for segmentation
    annotations
  * **skeleton** (*None*) – a
    [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton) to use as a
    reference when loading keypoints
  * **skeleton_key** (*None*) – the name of the field in the OpenLABEL
    annotations containing the labels of keypoints matching the
    labels of the given skeleton
* **Returns:**
  a dictionary of sample level fields and label objects and a
  dictionary of frame numbers to frame level fields and label objects

### *class* fiftyone.utils.openlabel.OpenLABELStreamInfos(infos=None)

Bases: `object`

A collection of multiple [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo) objects.

**Methods:**

| [`get_stream_attributes`](#fiftyone.utils.openlabel.OpenLABELStreamInfos.get_stream_attributes)([frame_number])   | Aggregates attributes from all streams in this collection.   |
|-------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------|

**Attributes:**

| [`frame_numbers`](#fiftyone.utils.openlabel.OpenLABELStreamInfos.frame_numbers)   | All frame numbers existing in the [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo) objects in this collection.   |
|-----------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------|

#### get_stream_attributes(frame_number=None)

Aggregates attributes from all streams in this collection.

* **Parameters:**
  **frame_number** (*None*) – a specific frame number for which to get
  stream attributes
* **Returns:**
  a dictionary of attributes from all streams in this collection

#### *property* frame_numbers

All frame numbers existing in the [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo)
objects in this collection.

### *class* fiftyone.utils.openlabel.OpenLABELStreamInfo(frame_numbers=None, stream=None, label_file_id=None, is_sample_level=None)

Bases: `object`

Information about a stream used to gather specific objects for a media
file.

* **Parameters:**
  * **frame_numbers** (*None*) – frame numbers related to this stream info
  * **stream** (*None*) – an [`OpenLABELStream`](#fiftyone.utils.openlabel.OpenLABELStream)
  * **label_file_id** (*None*) – a label file id related to this stream info
  * **is_sample_level** (*None*) – whether this stream info corresponds to
    sample-level or frame-level

**Attributes:**

| [`is_streamless`](#fiftyone.utils.openlabel.OpenLABELStreamInfo.is_streamless)   | Whether there exists a stream corresponding to this info.   |
|----------------------------------------------------------------------------------|-------------------------------------------------------------|

**Methods:**

| [`get_stream_attributes`](#fiftyone.utils.openlabel.OpenLABELStreamInfo.get_stream_attributes)()   | Get a dictionary of attributes for the stream in this object.   |
|----------------------------------------------------------------------------------------------------|-----------------------------------------------------------------|

#### *property* is_streamless

Whether there exists a stream corresponding to this info.

#### get_stream_attributes()

Get a dictionary of attributes for the stream in this object.

* **Returns:**
  a dictionary of attributes from the corresponding stream

### *class* fiftyone.utils.openlabel.OpenLABELGroup

Bases: `object`

A utility for parsing groups of OpenLABEL elements

### *class* fiftyone.utils.openlabel.OpenLABELObjects

Bases: [`OpenLABELGroup`](#fiftyone.utils.openlabel.OpenLABELGroup)

A collection of [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) and corresponding utility
methods.

**Attributes:**

| [`streams`](#fiftyone.utils.openlabel.OpenLABELObjects.streams)         | Get streams corresponding to any object in this collection.                                            |
|-------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| [`all_objects`](#fiftyone.utils.openlabel.OpenLABELObjects.all_objects) | A list of [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) instances in this collection. |

**Methods:**

| [`parse_objects_dict`](#fiftyone.utils.openlabel.OpenLABELObjects.parse_objects_dict)(objects_dict, label_file_id)   | Parses the OpenLABEL annotations corresponding to a specific dictionary of objects.                    |
|----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------|
| [`add_object`](#fiftyone.utils.openlabel.OpenLABELObjects.add_object)(obj_key, label_file_id, obj)                   | Adds an [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) to this collection.             |
| [`get_objects`](#fiftyone.utils.openlabel.OpenLABELObjects.get_objects)(stream_infos)                                | Gets any objects that correspond to an info in the given stream infos.                                 |
| [`to_labels`](#fiftyone.utils.openlabel.OpenLABELObjects.to_labels)(frame_size, label_types, seg_type, ...)          | Converts the stored [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) to FiftyOne labels. |

#### *property* streams

Get streams corresponding to any object in this collection.

#### *property* all_objects

A list of [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) instances in this collection.

#### parse_objects_dict(objects_dict, label_file_id, frame_number=None)

Parses the OpenLABEL annotations corresponding to a specific
dictionary of objects.

* **Parameters:**
  * **objects_dict** – the dict of OpenLABEL object annotations
  * **label_file_id** – the name of the annotations file containing these
    objects
  * **frame_number** (*None*) – an optional frame that this `objects_dict`
    is in

#### add_object(obj_key, label_file_id, obj)

Adds an [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) to this collection.

* **Parameters:**
  * **obj_key** – the name of the object in the OpenLABEL annotations
  * **label_file_id** – the filename of the annotations file containing this
    label
  * **obj** – the [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) to add

#### get_objects(stream_infos)

Gets any objects that correspond to an info in the given stream
infos.

* **Parameters:**
  **stream_infos** – a [`OpenLABELStreamInfos`](#fiftyone.utils.openlabel.OpenLABELStreamInfos) used to get
  corresponding objects
* **Returns:**
  an [`OpenLABELObjects`](#fiftyone.utils.openlabel.OpenLABELObjects) with objects that correspond to any of
  the given stream infos

#### to_labels(frame_size, label_types, seg_type, stream_infos, skeleton=None, skeleton_key=None)

Converts the stored [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) to FiftyOne labels.

* **Parameters:**
  * **frame_size** – the size of the image frame in pixels (width, height)
  * **label_types** – a list of label types to load
  * **seg_type** – the [`SegmentationType`](#fiftyone.utils.openlabel.SegmentationType) to use to store
    segmentations
  * **stream_infos** – the [`OpenLABELStreamInfos`](#fiftyone.utils.openlabel.OpenLABELStreamInfos) containing
    sample-level attributes to parse into labels
  * **skeleton** (*None*) – a
    [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton) to use when
    loading keypoint annotations
  * **skeleton_key** (*None*) – the name of the field in the OpenLABEL
    annotations containing the labels of keypoints matching the
    labels of the given skeleton
* **Returns:**
  a dictionary of sample level fields and label objects and a
  dictionary of frame numbers to frame level fields and label objects

### *class* fiftyone.utils.openlabel.OpenLABELStreams

Bases: [`OpenLABELGroup`](#fiftyone.utils.openlabel.OpenLABELGroup)

A collection of OpenLABEL streams.

**Attributes:**

| [`uris`](#fiftyone.utils.openlabel.OpenLABELStreams.uris)   | All unique media file identifiers corresponding to streams in this collection.   |
|-------------------------------------------------------------|----------------------------------------------------------------------------------|

**Methods:**

| [`parse_streams_dict`](#fiftyone.utils.openlabel.OpenLABELStreams.parse_streams_dict)(streams_dict, label_file_id)   | Parses the OpenLABEL annotations corresponding to a specific dictionary of streams.                   |
|----------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------|
| [`get_dimensions`](#fiftyone.utils.openlabel.OpenLABELStreams.get_dimensions)(uri)                                   | Get the width and height of a given URI or file id.                                                   |
| [`get_stream_info`](#fiftyone.utils.openlabel.OpenLABELStreams.get_stream_info)(uri)                                 | Get all stream infos, including stream and relevant frame numbers, for a given media file identifier. |

#### *property* uris

All unique media file identifiers corresponding to streams in this
collection.

#### parse_streams_dict(streams_dict, label_file_id, frame_number=None)

Parses the OpenLABEL annotations corresponding to a specific
dictionary of streams.

* **Parameters:**
  * **streams_dict** – the dict of OpenLABEL stream annotations
  * **label_file_id** – the name of the annotations file containing these
    streams
  * **frame_number** (*None*) – an optional frame that this `streams_dict`
    is in

#### get_dimensions(uri)

Get the width and height of a given URI or file id.

* **Parameters:**
  **file_id** – the unique identifier to a media file
* **Returns:**
  the `(width, height)` of the given file

#### get_stream_info(uri)

Get all stream infos, including stream and relevant frame numbers,
for a given media file identifier.

* **Parameters:**
  **uri** – the unique media file identifier for which to get all stream
  infos
* **Returns:**
  the [`OpenLABELStreamInfos`](#fiftyone.utils.openlabel.OpenLABELStreamInfos) corresponding to the given uri

### *class* fiftyone.utils.openlabel.AttributeParser

Bases: `object`

Methods used to parse attributes from OpenLABEL annotations.

### *class* fiftyone.utils.openlabel.OpenLABELShape(coords, attributes=None, stream=None)

Bases: [`AttributeParser`](#fiftyone.utils.openlabel.AttributeParser)

A single OpenLABEL shape like a bounding box or polygon.

**Methods:**

| [`from_shape_dict`](#fiftyone.utils.openlabel.OpenLABELShape.from_shape_dict)(d)   | Constructs a shape from a dictionary of information.   |
|------------------------------------------------------------------------------------|--------------------------------------------------------|

#### *classmethod* from_shape_dict(d)

Constructs a shape from a dictionary of information.

* **Parameters:**
  **d** – a dictionary containing information about a shape
* **Returns:**
  an [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

### *class* fiftyone.utils.openlabel.OpenLABELBBox(coords, attributes=None, stream=None)

Bases: [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

An OpenLABEL bounding box.

**Methods:**

| [`to_label`](#fiftyone.utils.openlabel.OpenLABELBBox.to_label)(label, attributes, width, height)   | Convert this shape to a FiftyOne label.              |
|----------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [`from_shape_dict`](#fiftyone.utils.openlabel.OpenLABELBBox.from_shape_dict)(d)                    | Constructs a shape from a dictionary of information. |

#### to_label(label, attributes, width, height)

Convert this shape to a FiftyOne label.

* **Parameters:**
  * **label** – the class label for this shape
  * **attributes** – a dictionary of attributes for this shape
  * **width** – the width of the frame in pixels
  * **height** – the height of the frame in pixels
* **Returns:**
  an [`fiftyone.core.labels.Detection`](fiftyone.core.labels.md#fiftyone.core.labels.Detection)

#### *classmethod* from_shape_dict(d)

Constructs a shape from a dictionary of information.

* **Parameters:**
  **d** – a dictionary containing information about a shape
* **Returns:**
  an [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

### *class* fiftyone.utils.openlabel.OpenLABELPoly2D(coords, attributes=None, stream=None)

Bases: [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

An OpenLABEL polyline.

**Methods:**

| [`to_label`](#fiftyone.utils.openlabel.OpenLABELPoly2D.to_label)(label, attributes, width, height)   | Convert this shape to a FiftyOne label.              |
|------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [`from_shape_dict`](#fiftyone.utils.openlabel.OpenLABELPoly2D.from_shape_dict)(d)                    | Constructs a shape from a dictionary of information. |

#### to_label(label, attributes, width, height)

Convert this shape to a FiftyOne label.

* **Parameters:**
  * **label** – the class label for this shape
  * **attributes** – a dictionary of attributes for this shape
  * **width** – the width of the frame in pixels
  * **height** – the height of the frame in pixels
* **Returns:**
  an [`fiftyone.core.labels.Polyline`](fiftyone.core.labels.md#fiftyone.core.labels.Polyline)

#### *classmethod* from_shape_dict(d)

Constructs a shape from a dictionary of information.

* **Parameters:**
  **d** – a dictionary containing information about a shape
* **Returns:**
  an [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

### *class* fiftyone.utils.openlabel.OpenLABELPoint(coords, attributes=None, stream=None)

Bases: [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

An OpenLABEL keypoint.

**Methods:**

| [`to_label`](#fiftyone.utils.openlabel.OpenLABELPoint.to_label)(label, attributes, width, height[, ...])   | Convert this shape to a FiftyOne label.              |
|------------------------------------------------------------------------------------------------------------|------------------------------------------------------|
| [`from_shape_dict`](#fiftyone.utils.openlabel.OpenLABELPoint.from_shape_dict)(d)                           | Constructs a shape from a dictionary of information. |

#### to_label(label, attributes, width, height, skeleton=None, skeleton_key=None)

Convert this shape to a FiftyOne label.

* **Parameters:**
  * **label** – the class label for this shape
  * **attributes** – a dictionary of attributes for this shape
  * **width** – the width of the frame in pixels
  * **height** – the height of the frame in pixels
  * **skeleton** (*None*) – a
    [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton) used to
    sort list attributes based on the labels in the skeleton. Used
    only if `skeleton_key` is provided
  * **skeleton_key** (*None*) – the string key into the attributes dictionary
    containing the label of each point, used to sort list attribute
    fields based on the labels in the skeleton. Used only if
    `skeleton` is provided
* **Returns:**
  an [`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint)

#### *classmethod* from_shape_dict(d)

Constructs a shape from a dictionary of information.

* **Parameters:**
  **d** – a dictionary containing information about a shape
* **Returns:**
  an [`OpenLABELShape`](#fiftyone.utils.openlabel.OpenLABELShape)

### *class* fiftyone.utils.openlabel.OpenLABELShapes(shapes=None, attributes=None, stream=None)

Bases: [`AttributeParser`](#fiftyone.utils.openlabel.AttributeParser)

A collection of OpenLABEL shapes.

**Attributes:**

| [`streams`](#fiftyone.utils.openlabel.OpenLABELShapes.streams)   | A list of streams corresponding to any object in this collection.   |
|------------------------------------------------------------------|---------------------------------------------------------------------|

**Methods:**

| [`from_object_data_list`](#fiftyone.utils.openlabel.OpenLABELShapes.from_object_data_list)(shape_type, l[, ...])   | Construct an [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) from a list of shape dictionaries.   |
|--------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [`merge_shapes`](#fiftyone.utils.openlabel.OpenLABELShapes.merge_shapes)(shapes)                                   | Merges another [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) into this one.                     |
| [`to_labels`](#fiftyone.utils.openlabel.OpenLABELShapes.to_labels)(label, attributes, width, height)               | Convert this shape to a FiftyOne label.                                                                          |

#### *property* streams

A list of streams corresponding to any object in this collection.

#### *classmethod* from_object_data_list(shape_type, l, attributes=None)

Construct an [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) from a list of shape
dictionaries.

* **Parameters:**
  * **shape_type** – the type of the shape being loaded. Options are
    ([`OpenLABELBBox`](#fiftyone.utils.openlabel.OpenLABELBBox), [`OpenLABELPoly2D`](#fiftyone.utils.openlabel.OpenLABELPoly2D),
    [`OpenLABELPoint`](#fiftyone.utils.openlabel.OpenLABELPoint))
  * **l** – a list of shape dictionaries parsed from OpenLABEL object
    annotations
  * **attributes** (*None*) – a dictionary of attributes corresponding to all
    shapes in this collection
* **Returns:**
  a [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes)

#### merge_shapes(shapes)

Merges another [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) into this one.

* **Parameters:**
  **shapes** – another [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) to merge into this
  object

#### to_labels(label, attributes, width, height, is_points=False, skeleton=None, skeleton_key=None)

Convert this shape to a FiftyOne label.

* **Parameters:**
  * **label** – the class label for this shape
  * **attributes** – a dictionary of attributes for this shape
  * **width** – the width of the frame in pixels
  * **height** – the height of the frame in pixels
  * **is_points** (*False*) – whether the labels being converted are keypoints
  * **skeleton** (*None*) – a
    [`fiftyone.core.odm.dataset.KeypointSkeleton`](fiftyone.core.odm.dataset.md#fiftyone.core.odm.dataset.KeypointSkeleton) used to
    sort list attributes based on the labels in the skeleton. Used
    only if `is_points` and `skeleton_key` is provided
  * **skeleton_key** (*None*) – the string key into the attributes dictionary
    containing the label of each point, used to sort list attribute
    fields based on the labels in the skeleton. Used only if
    `is_points` and `skeleton` is provided
* **Returns:**
  an [`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint)

### *class* fiftyone.utils.openlabel.OpenLABELStream(name, type=None, properties=None, uris=None, other_attrs=None)

Bases: `object`

An OpenLABEL stream corresponding to one uri or file_id.

* **Parameters:**
  * **name** (*None*) – the name of the stream
  * **type** (*None*) – the type of the stream
  * **description** (*None*) – a string description for this stream
  * **properties** (*None*) – a dict of properties for this stream
  * **uri** (*None*) – the uri or file_id of the media corresponding to this
    stream
  * **other_attrs** (*None*) – a dictionary of other attributes corresponding to
    this stream

**Methods:**

| [`update_dict`](#fiftyone.utils.openlabel.OpenLABELStream.update_dict)(d[, frame_number])                  | Updates this stream with additional information.                   |
|------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------|
| [`get_frame_numbers`](#fiftyone.utils.openlabel.OpenLABELStream.get_frame_numbers)(uri)                    | Get frame numbers corresponding to the given uri.                  |
| [`from_anno_dict`](#fiftyone.utils.openlabel.OpenLABELStream.from_anno_dict)(stream_name, d, frame_number) | Create an OpenLABEL stream from the stream information dictionary. |

**Attributes:**

| [`uris`](#fiftyone.utils.openlabel.OpenLABELStream.uris)   | Get uris corresponding to any stream in this collection.   |
|------------------------------------------------------------|------------------------------------------------------------|

#### update_dict(d, frame_number=None)

Updates this stream with additional information.

* **Parameters:**
  * **d** – a dict containing additional stream information
  * **frame_number** (*None*) – the frame number from which this stream
    information dict was parsed, ‘None’ if from the top-level
    streams

#### *property* uris

Get uris corresponding to any stream in this collection.

#### get_frame_numbers(uri)

Get frame numbers corresponding to the given uri.

#### *classmethod* from_anno_dict(stream_name, d, frame_number)

Create an OpenLABEL stream from the stream information dictionary.

* **Parameters:**
  * **stream_name** – the name of the stream
  * **d** – a dict containing information about this stream
  * **frame_number** – the frame number from which this stream
    information dict was parsed, ‘None’ if from the top-level
    streams
* **Returns:**
  An [`OpenLABELStream`](#fiftyone.utils.openlabel.OpenLABELStream)

### *class* fiftyone.utils.openlabel.OpenLABELMetadata(metadata_dict)

Bases: `object`

A parser and storage for OpenLABEL metadata.

**Methods:**

| [`parse_potential_file_ids`](#fiftyone.utils.openlabel.OpenLABELMetadata.parse_potential_file_ids)()   | Parses metadata for any fields that may correspond to a label-wide media file_id.   |
|--------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------|

#### parse_potential_file_ids()

Parses metadata for any fields that may correspond to a label-wide
media file_id.

* **Returns:**
  a list of potential file_id strings

### *class* fiftyone.utils.openlabel.OpenLABELObject(key, name=None, type=None, bboxes=None, segmentations=None, keypoints=None, stream=None, other_attrs=None, is_frame_level=False)

Bases: [`AttributeParser`](#fiftyone.utils.openlabel.AttributeParser)

An object parsed from OpenLABEL labels.

* **Parameters:**
  * **key** – the OpenLABEL key string for this object
  * **name** (*None*) – the name string of the object
  * **type** (*None*) – the type string of the object
  * **bboxes** (*None*) – an :class\`OpenLABELShapes\` of bounding boxes for this
    object
  * **segmentations** (*None*) – an :class\`OpenLABELShapes\` of polygon
    segmentations for this object
  * **keyponts** (*None*) – an [`OpenLABELShapes`](#fiftyone.utils.openlabel.OpenLABELShapes) of keypoints for this
    object
  * **stream** (*None*) – the [`OpenLABELStream`](#fiftyone.utils.openlabel.OpenLABELStream) this object corresponds to
  * **other_attrs** (*None*) – a dict of attributes and their values for this
    object
  * **is_frame_level** (*False*) – whether this object is sample-level or
    frame-level

**Attributes:**

| [`streams`](#fiftyone.utils.openlabel.OpenLABELObject.streams)             | Get streams corresponding to this object.                                              |
|----------------------------------------------------------------------------|----------------------------------------------------------------------------------------|
| [`is_streamless`](#fiftyone.utils.openlabel.OpenLABELObject.is_streamless) | Whether any streams are connected to this object or corresponding frame-level objects. |

**Methods:**

| [`filter_stream`](#fiftyone.utils.openlabel.OpenLABELObject.filter_stream)(stream_info)                  | Filters this object to contain only frame labels specified in the given stream info                                                               |
|----------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------|
| [`to_detections`](#fiftyone.utils.openlabel.OpenLABELObject.to_detections)(frame_size)                   | Converts the bounding boxes in this object to [`fiftyone.core.labels.Detection`](fiftyone.core.labels.md#fiftyone.core.labels.Detection) objects. |
| [`to_polylines`](#fiftyone.utils.openlabel.OpenLABELObject.to_polylines)(frame_size)                     | Converts the segmentations in this object to [`fiftyone.core.labels.Polyline`](fiftyone.core.labels.md#fiftyone.core.labels.Polyline) objects.    |
| [`to_keypoints`](#fiftyone.utils.openlabel.OpenLABELObject.to_keypoints)(frame_size[, skeleton, ...])    | Converts the keypoints in this object to [`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint) objects.        |
| [`from_anno_dict`](#fiftyone.utils.openlabel.OpenLABELObject.from_anno_dict)(obj_key, d[, frame_number]) | Create an [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) from the raw label dictionary.                                           |
| [`update_dict`](#fiftyone.utils.openlabel.OpenLABELObject.update_dict)(d[, frame_number])                | Updates this [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) given the raw label dictionary.                                       |

#### *property* streams

Get streams corresponding to this object.

#### *property* is_streamless

Whether any streams are connected to this object or corresponding
frame-level objects.

#### filter_stream(stream_info)

Filters this object to contain only frame labels specified in the
given stream info

* **Parameters:**
  **stream_info** – the [`OpenLABELStreamInfo`](#fiftyone.utils.openlabel.OpenLABELStreamInfo) to use to filter this
  object
* **Returns:**
  an [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) containing only frames related to the
  given stream info

#### to_detections(frame_size)

Converts the bounding boxes in this object to
[`fiftyone.core.labels.Detection`](fiftyone.core.labels.md#fiftyone.core.labels.Detection) objects.

* **Parameters:**
  **frame_size** – the size of the frame in pixels (width, height)
* **Returns:**
  a list of [`fiftyone.core.labels.Detection`](fiftyone.core.labels.md#fiftyone.core.labels.Detection) objects for each
  bounding box in this object

#### to_polylines(frame_size)

Converts the segmentations in this object to
[`fiftyone.core.labels.Polyline`](fiftyone.core.labels.md#fiftyone.core.labels.Polyline) objects.

* **Parameters:**
  **frame_size** – the size of the frame in pixels (width, height)
* **Returns:**
  a list of [`fiftyone.core.labels.Polyline`](fiftyone.core.labels.md#fiftyone.core.labels.Polyline) objects for each
  polyline in this object

#### to_keypoints(frame_size, skeleton=None, skeleton_key=None)

Converts the keypoints in this object to
[`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint) objects.

* **Parameters:**
  **frame_size** – the size of the frame in pixels (width, height)
* **Returns:**
  a list of [`fiftyone.core.labels.Keypoint`](fiftyone.core.labels.md#fiftyone.core.labels.Keypoint) objects for each
  keypoint in this object

#### *classmethod* from_anno_dict(obj_key, d, frame_number=None)

Create an [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) from the raw label dictionary.

* **Parameters:**
  * **anno_id** – id of the object
  * **d** – dict containing the information for this object
* **Returns:**
  a tuple containing the [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) and the frame
  numbers the object corresponds to, if any.

#### update_dict(d, frame_number=None)

Updates this [`OpenLABELObject`](#fiftyone.utils.openlabel.OpenLABELObject) given the raw label
dictionary.

* **Parameters:**
  **d** – dict containing the information for this object
* **Returns:**
  newly parsed frame numbers the object corresponds to, if any
