class Polyline(_HasAttributesDict, _HasID, Label): (source)
A set of semantically related polylines or polygons.
Parameters | |
label | a label for the polyline |
points | a list of lists of (x, y) points in [0, 1] x [0, 1] describing the vertices of each shape in the polyline |
confidence | a confidence in [0, 1] for the polyline |
index | an index for the polyline |
closed | whether the shapes are closed, i.e., and edge should be drawn from the last vertex to the first vertex of each shape |
filled | whether the polyline represents polygons, i.e., shapes that should be filled when rendering them |
attributes | a dict mapping attribute names to Attribute
instances for the polyline |
Class Method | from |
Constructs a cuboid from its 8 vertices in the format below: |
Class Method | from |
Creates a Polyline instance with polygons describing the non-zero region(s) of the given full image mask. |
Class Method | from |
Constructs a rotated bounding box from its center, dimensions, and rotation. |
Method | to |
Returns a Detection representation of this instance whose bounding box tightly encloses the polyline. |
Method | to |
Returns a Segmentation representation of this instance. |
Method | to |
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 |
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 |
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 | |
vertices | a list of 8 (x, y) vertices in the above format |
frameNone | the (width, height) of the frame |
label:None | the label string |
**attributes | additional arguments for the Polyline |
Returns | |
a Polyline |
Creates a Polyline
instance with polygons describing the
non-zero region(s) of the given full image mask.
Parameters | |
mask | a boolean or 0/1 numpy array |
label:None | the label string |
tolerance:2 | a tolerance, in pixels, when generating approximate polygons for each region. Typical values are 1-3 pixels |
**attributes | additional attributes for the Polyline |
Returns | |
a Polyline |
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 | |
xc | the x-center coordinate |
yc | the y-center coorindate |
w | the box width |
h | Undocumented |
theta | the counter-clockwise rotation of the box in radians |
frameNone | the (width, height) of the frame |
label:None | the label string |
y | the box height |
**attributes | additional arguments for the Polyline |
Returns | |
a Polyline |
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 | |
maskNone | an optional (width, height) at which to render an instance mask for the polyline |
frameNone | used 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 |
Returns a Segmentation
representation of this instance.
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 objects |
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 |
thickness:1 | the thickness, in pixels, at which to render (non-filled) polylines |
Returns | |
a Segmentation |
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 | |
frameNone | the (width, height) of the image. If provided, the returned geometry will use absolute coordinates |
filled:None | whether to treat the shape as filled (True) or
hollow (False) regardless of its filled attribute |
Returns | |
one of the following |
|