limbo.data module
Functionality for working with Limbo Data Format datasets.
- class limbo.data.Cryptomatte(sample, synthetic)[source]
Bases:
objectProvides access to extra information provided by synthetic samples.
The
Cryptomattehas access to high quality masking information created for synthetic samples at render time, and can convert that information into many different representations, including contours and rectangular bounding boxes.There is no reason to create an instance of this class yourself, callers should obtain instances from the
Synthetic.cryptomatte()property.- bbox(instances=None)[source]
Compute a bounding box.
Note that bounding boxes are computed from contour information.
- Parameters:
instances (
str,listofstr, orNone, optional) – IfNone, computes a bounding box that contains every object in the sample. Otherwise, computes a bounding box that contains just the given object instances.- Returns:
bbox – Returns the bounding box using absolute pixel values.
- Return type:
(left, top, width, height) tuple
- contours(instances=None)[source]
Compute polygon contours.
Note that contours are computed from matte information.
- Parameters:
instances (
str,listofstr, orNone, optional) – IfNone, returns contours for every object in the sample. Otherwise, returns contours that contain just the given object instances.- Returns:
contours – Returns a \(N \times 2\)
numpy.ndarrayfor each contour, containing absolute pixel values.- Return type:
- property image
Return the Cryptomatte data for this sample.
The Cryptomatte for a sample contains masking information for every instance. All mattes, contours, and bounding boxes are derived from this information.
- Returns:
cryptomatte – Imagecat image containing the Cryptomatte data for this sample.
- Return type:
- property instances
Return the set of visible object instances for this sample.
Note that an instance label can be any string - any semantics encoded in instance labels are dataset-specific.
- materialize_bounds()[source]
Warning
method ‘limbo.data.Cryptomatte.materialize_bounds’ undocumented
- matte(instances=None)[source]
Compute matte images.
Note that mattes are computed from Cryptomatte data, and are subpixel accurate: where an object covers a fraction of a pixel’s area, the matte will contain a value between 0 and 1.
- preview(show_bboxes=False, show_contours=False, instances=None)[source]
Warning
method ‘limbo.data.Cryptomatte.preview’ undocumented
- resized_matte(instances, res)[source]
Compute a resized matte image.
- Returns:
image – Imagecat image containing the resized matte.
- Return type:
- segmentation(instances=None)[source]
Compute segmentation images.
A segmentation image contains a distinct color for each visible instance in the image.
Note that segmentation images are only accurate to a single pixel: each pixel can only be one color, and each color represents a single object instance.
- class limbo.data.Dataset(paths)[source]
Bases:
objectProvides access to one-or-more Limbo Data Format datasets.
Use
len(dataset)to retrieve the number of samples in the dataset.Use
dataset[index]to retrieve theSampleat the given integer index.Use
for sample in dataset:to iterate oversamples.- Parameters:
paths (
strorlistofstr, required) – Paths to one-or-more directories containing data in Limbo Data Format. The resulting dataset object can be used to access the union of the data from the given paths.
- class limbo.data.Sample(path)[source]
Bases:
objectProvides access to one sample within a Limbo Data Format dataset.
Although callers are free to create
Sampleobjects directly, they are typically returned from an instance ofDataset.- Parameters:
path (
str, required) – Absolute path to the JSON metadata file for a sample.
- property categories
All categories that have been applied to this sample, regardless of annotation type.
- property default_cryptomatte_path
Warning
property ‘limbo.data.Sample.default_cryptomatte_path’ undocumented
- property default_image_path
Warning
property ‘limbo.data.Sample.default_image_path’ undocumented
- property default_synthetic_path
Warning
property ‘limbo.data.Sample.default_synthetic_path’ undocumented
- property graph
Graphcat network used for image processing.
This is used by the rest of the API and should be of little interest to callers.
- Returns:
graph
- Return type:
- property image
Reference image for this sample, if it exists.
- Returns:
image
- Return type:
- property image_path
Filesystem path of the reference image for this sample, if it exists.
- property path
Metadata path for this sample.
- Returns:
path – Absolute path to the metadata file for this sample.
- Return type:
- preview(show_bboxes=False, show_contours=False, include=None)[source]
Generate an annotated preview image from the sample.
Note
This method only displays annotations that are stored in the sample metadata; annotations provided by a
Cryptomatteobject will not be visible, unless they have been materialized usingCryptomatte.materialize_bounds().- Parameters:
show_bboxes (
bool, optional) – IfTrue, the preview will include bounding box annotations.show_contours (
bool, optional) – IfTrue, the preview will include contour annotations.include (callable object, optional) – If specified, the given callable object will be called once per sample annotation. If it returns
True, the annotation will be included in the preview.
- Returns:
surface – Skia drawing library surface containing the preview that can be converted into a bitmap or other image format.
- Return type:
- resized_image(res)[source]
Resized reference image for this sample, if it exists.
- Returns:
image
- Return type:
- property synthetic
Optional synthetic data for this sample.
Samples that are generated synthetically contain information that isn’t present in samples gathered from more traditional sources (like photographs), and the object returned by this property (if any) provides access to that information.
- class limbo.data.Synthetic(sample)[source]
Bases:
objectProvides access to extra information provided by synthetic samples.
There is no reason to create an instance of this class yourself, callers should obtain instances from the
Sample.synthetic()property.- property cryptomatte
Optional cryptomatte data for this sample.
Samples that are generated synthetically typically include masking information that is stored using a cryptomatte, and the object returned by this property (if any) provides access to the cryptomatte data.
- Returns:
cryptomatte
- Return type:
CryptomatteorNone
- property depth
Rendered depth (LIDAR) image for this sample.
- Returns:
image
- Return type:
- property image
Rendered image for this sample.
Note that the rendered image for the sample is a high-dynamic-range image with floating-point pixel values. Thus, it is higher-quality than the reference image for the sample, which is clipped and stored in PNG format using unsigned bytes.
- Returns:
image
- Return type: