class documentation

A set of semantically related polylines or polygons.

Parameters
labela label for the polyline
pointsa list of lists of (x, y) points in [0, 1] x [0, 1] describing the vertices of each shape in the polyline
confidencea confidence in [0, 1] for the polyline
indexan index for the polyline
closedwhether the shapes are closed, i.e., and edge should be drawn from the last vertex to the first vertex of each shape
filledwhether the polyline represents polygons, i.e., shapes that should be filled when rendering them
attributesa dict mapping attribute names to Attribute instances for the polyline
Class Method from_cuboid Constructs a cuboid from its 8 vertices in the format below:
Class Method from_mask Creates a Polyline instance with polygons describing the non-zero region(s) of the given full image mask.
Class Method from_rotated_box Constructs a rotated bounding box from its center, dimensions, and rotation.
Method to_detection Returns a Detection representation of this instance whose bounding box tightly encloses the polyline.
Method to_segmentation Returns a Segmentation representation of this instance.
Method to_shapely Returns a Shapely representation of this instance.
Class Variable closed Undocumented
Class Variable confidence Undocumented
Class Variable filled Undocumented
Class Variable index Undocumented
Class Variable label Undocumented
Class Variable points 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
@classmethod
def from_cuboid(cls, vertices, frame_size=None, label=None, **attributes): (source)

Constructs a cuboid from its 8 vertices in the format below:

   7--------6
  /|       /|
 / |      / |
3--------2  |
|  4-----|--5
| /      | /
|/       |/
0--------1

If a frame_size is provided, vertices must be absolute pixel coordinates; otherwise vertices should be normalized coordinates in [0, 1] x [0, 1].

Parameters
verticesa list of 8 (x, y) vertices in the above format
frame_size:Nonethe (width, height) of the frame
label:Nonethe label string
**attributesadditional arguments for the Polyline
Returns
a Polyline
@classmethod
def from_mask(cls, mask, label=None, tolerance=2, **attributes): (source)

Creates a Polyline instance with polygons describing the non-zero region(s) of the given full image mask.

Parameters
maska boolean or 0/1 numpy array
label:Nonethe label string
tolerance:2a tolerance, in pixels, when generating approximate polygons for each region. Typical values are 1-3 pixels
**attributesadditional attributes for the Polyline
Returns
a Polyline
@classmethod
def from_rotated_box(cls, xc, yc, w, h, theta, frame_size=None, label=None, **attributes): (source)

Constructs a rotated bounding box from its center, dimensions, and rotation.

If a frame_size is provided, the provided box coordinates must be absolute pixel coordinates; otherwise they should be normalized coordinates in [0, 1]. Note that rotations in normalized coordinates only make sense when the source aspect ratio is square.

Parameters
xcthe x-center coordinate
ycthe y-center coorindate
wthe box width
hUndocumented
thetathe counter-clockwise rotation of the box in radians
frame_size:Nonethe (width, height) of the frame
label:Nonethe label string
ythe box height
**attributesadditional arguments for the Polyline
Returns
a Polyline
def to_detection(self, mask_size=None, frame_size=None): (source)

Returns a Detection representation of this instance whose bounding box tightly encloses the polyline.

If a mask_size is provided, an instance mask of the specified size encoding the polyline's shape is included.

Alternatively, if a frame_size is provided, the required mask size is then computed based off of the polyline points and frame_size.

Parameters
mask_size:Nonean optional (width, height) at which to render an instance mask for the polyline
frame_size:Noneused when no mask_size is provided. an optional (width, height) of the frame containing this polyline that is used to compute the required mask_size
Returns
a Detection
def to_segmentation(self, mask=None, frame_size=None, target=255, thickness=1): (source)

Returns a Segmentation representation of this instance.

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 objects
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
thickness:1the thickness, in pixels, at which to render (non-filled) polylines
Returns
a Segmentation
def to_shapely(self, frame_size=None, filled=None): (source)

Returns a Shapely representation of this instance.

The type of geometry returned depends on the number of shapes (points) and whether they are polygons or lines (filled).

Parameters
frame_size:Nonethe (width, height) of the image. If provided, the returned geometry will use absolute coordinates
filled:Nonewhether to treat the shape as filled (True) or hollow (False) regardless of its filled attribute
Returns
one of the following
  • shapely.geometry.polygon.Polygon: if filled is True and points contains a single shape
  • shapely.geometry.multipolygon.MultiPolygon: if filled is True and points contains multiple shapes
  • shapely.geometry.linestring.LineString: if filled is False and points contains a single shape
  • shapely.geometry.multilinestring.MultiLineString: if filled is False and points contains multiple shapes

Undocumented

confidence: None = (source)

Undocumented

Undocumented

Undocumented

Undocumented

Undocumented