class Detection(_HasAttributesDict, _HasID, _HasMedia, Label): (source)
An object detection.
Parameters | |
label | the label string |
bounding | a list of relative bounding box coordinates in [0, 1] in the following format: [<top-left-x>, <top-left-y>, <width>, <height>] |
mask | an instance segmentation mask for the detection within its bounding box, which should be a 2D binary or 0/1 integer numpy array |
mask | the 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 |
confidence | a confidence in [0, 1] for the detection |
index | an index for the object |
attributes | a dict mapping attribute names to Attribute
instances |
Class Method | from |
Creates a Detection instance with its mask attribute populated from the given full image mask. |
Method | export |
Exports this instance's mask to the given path. |
Method | get |
Returns the detection mask for this instance. |
Method | import |
Imports this instance's mask from disk to its mask attribute. |
Method | to |
Returns a Polyline representation of this instance. |
Method | to |
Returns a Segmentation representation of this instance. |
Method | to |
Returns a Shapely representation of this instance. |
Class Variable | bounding |
Undocumented |
Class Variable | confidence |
Undocumented |
Class Variable | index |
Undocumented |
Class Variable | label |
Undocumented |
Instance Variable | mask |
Undocumented |
Instance Variable | mask |
Undocumented |
Property | has |
Whether this instance has a mask. |
Constant | _MEDIA |
Undocumented |
Inherited from _HasAttributesDict
:
Method | delete |
Deletes the attribute with the given name. |
Method | get |
Gets the value of the attribute with the given name. |
Method | has |
Determines whether the label has an attribute with the given name. |
Method | iter |
Returns an iterator over the custom attributes of the label. |
Method | set |
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 |
Undocumented |
Property | _id |
Undocumented |
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 | |
mask | a boolean or 0/1 numpy array |
label:None | the label string |
**attributes | additional attributes for the Detection |
Returns | |
a Detection |
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:2 | a tolerance, in pixels, when generating an approximate polyline for the instance mask. Typical values are 1-3 pixels |
filled:True | whether the polyline should be filled |
Returns | |
a Polyline |
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:None | an optional numpy array to use as an initial mask to which to add this object |
frameNone | the (width, height) of the segmentation mask to render. This parameter has no effect if a mask is provided |
target:255 | the pixel value or RGB hex string to use to render the object |
Returns | |
a Segmentation |
Returns a Shapely representation of this instance.
Parameters | |
frameNone | the (width, height) of the image. If provided, the returned geometry will use absolute coordinates |
Returns | |
a shapely.geometry.polygon.Polygon |