class documentation

An object detection.

Parameters
labelthe label string
bounding_box

a list of relative bounding box coordinates in [0, 1] in the following format:

[<top-left-x>, <top-left-y>, <width>, <height>]
maskan instance segmentation mask for the detection within its bounding box, which should be a 2D binary or 0/1 integer numpy array
mask_paththe absolute path to the instance segmentation image on disk, which should be a single-channel PNG image where any non-zero values represent the instance's extent
confidencea confidence in [0, 1] for the detection
indexan index for the object
instancean instance of Instance to link this detection label to other similar labels
attributesa dict mapping attribute names to Attribute instances
Class Method from_mask Creates a Detection instance with its mask attribute populated from the given full image mask.
Method export_mask Exports this instance's mask to the given path.
Method get_mask Returns the detection mask for this instance.
Method import_mask Imports this instance's mask from disk to its mask attribute.
Method to_polyline Returns a Polyline representation of this instance.
Method to_segmentation Returns a Segmentation representation of this instance.
Method to_shapely Returns a Shapely representation of this instance.
Class Variable bounding_box Undocumented
Class Variable confidence Undocumented
Class Variable index Undocumented
Class Variable label Undocumented
Instance Variable mask Undocumented
Instance Variable mask_path Undocumented
Property has_mask Whether this instance has a mask.
Constant _MEDIA_FIELD Undocumented

Inherited from _HasAttributesDict:

Method delete_attribute Deletes the attribute with the given name.
Method get_attribute_value Gets the value of the attribute with the given name.
Method has_attribute Determines whether the label has an attribute with the given name.
Method iter_attributes Returns an iterator over the custom attributes of the label.
Method set_attribute_value Sets the value of the attribute with the given name.

Inherited from _HasID (via _HasAttributesDict):

Class Variable tags Undocumented
Instance Variable id Undocumented
Method _id.setter Undocumented
Property _id Undocumented

Inherited from _HasInstance (via _HasAttributesDict, _HasID, _HasMedia):

Property instance_id The label's instance ID, or None if it does not have one.
@classmethod
def from_mask(cls, mask, label=None, **attributes): (source)

Creates a Detection instance with its mask attribute populated from the given full image mask.

The instance mask for the object is extracted by computing the bounding rectangle of the non-zero values in the image mask.

Parameters
maska boolean or 0/1 numpy array
label:Nonethe label string
**attributesadditional attributes for the Detection
Returns
a Detection
def export_mask(self, outpath, update=False): (source)

Exports this instance's mask to the given path.

Parameters
outpaththe path to write the mask
update:Falsewhether to clear this instance's mask attribute and set its mask_path attribute when exporting in-database segmentations
def get_mask(self): (source)

Returns the detection mask for this instance.

Returns
a numpy array, or None
def import_mask(self, update=False): (source)

Imports this instance's mask from disk to its mask attribute.

Parameters
update:Falsewhether to clear this instance's mask_path attribute after importing
def to_polyline(self, tolerance=2, filled=True): (source)

Returns a Polyline representation of this instance.

If the detection has a mask, the returned polyline will trace the boundary of the mask; otherwise, the polyline will trace the bounding box itself.

Parameters
tolerance:2a tolerance, in pixels, when generating an approximate polyline for the instance mask. Typical values are 1-3 pixels
filled:Truewhether the polyline should be filled
Returns
a Polyline
def to_segmentation(self, mask=None, frame_size=None, target=255): (source)

Returns a Segmentation representation of this instance.

The detection must have an instance mask, i.e., its mask attribute must be populated.

You must provide either mask or frame_size to use this method.

Parameters
mask:Nonean optional numpy array to use as an initial mask to which to add this object
frame_size:Nonethe (width, height) of the segmentation mask to render. This parameter has no effect if a mask is provided
target:255the pixel value or RGB hex string to use to render the object
Returns
a Segmentation
def to_shapely(self, frame_size=None): (source)

Returns a Shapely representation of this instance.

Parameters
frame_size:Nonethe (width, height) of the image. If provided, the returned geometry will use absolute coordinates
Returns
a shapely.geometry.polygon.Polygon
bounding_box: None = (source)

Undocumented

confidence: None = (source)

Undocumented

Undocumented

Undocumented

Undocumented

mask_path: None = (source)

Undocumented

Whether this instance has a mask.

_MEDIA_FIELD: str = (source)

Undocumented

Value
'mask_path'