tensorbay.label.label_polyline
LabeledPolyline2D, Polyline2DSubcatalog.
Polyline2DSubcatalog
defines the subcatalog for 2D polyline type of labels.
LabeledPolyline2D
is the 2D polyline type of label,
which is often used for CV tasks such as lane detection.
- class tensorbay.label.label_polyline.Polyline2DSubcatalog(is_tracking=False, is_beizer_curve=False)[source]
Bases:
tensorbay.label.basic.SubcatalogBase
,tensorbay.label.supports.IsTrackingMixin
,tensorbay.label.supports.CategoriesMixin
,tensorbay.label.supports.AttributesMixin
This class defines the subcatalog for 2D polyline type of labels.
- Parameters
is_tracking (bool) – A boolean value indicates whether the corresponding subcatalog contains tracking information.
is_beizer_curve (bool) – A boolean value indicates whether the corresponding subcatalog contains beizer curve information.
- Return type
None
- description
The description of the entire 2D polyline subcatalog.
- Type
str
- categories
All the possible categories in the corresponding dataset stored in a
NameList
with the category names as keys and theCategoryInfo
as values.
- category_delimiter
The delimiter in category values indicating parent-child relationship.
- Type
str
- attributes
All the possible attributes in the corresponding dataset stored in a
NameList
with the attribute names as keys and theAttributeInfo
as values.
- is_tracking
Whether the Subcatalog contains tracking information.
- Type
bool
- is_beizer_curve
Whether the Subcatalog contains beizer curve information.
- Type
bool
Examples
Initialization Method 1: Init from
Polyline2DSubcatalog.loads()
method.>>> catalog = { ... "POLYLINE2D": { ... "isTracking": True, ... "isBeizerCurve": True, ... "categories": [{"name": "0"}, {"name": "1"}], ... "attributes": [{"name": "gender", "enum": ["male", "female"]}], ... } ... } >>> Polyline2DSubcatalog.loads(catalog["POLYLINE2D"]) Polyline2DSubcatalog( (is_beizer_curve): True, (is_tracking): True, (categories): NameList [...], (attributes): NameList [...] )
Initialization Method 2: Init an empty Polyline2DSubcatalog and then add the attributes.
>>> from tensorbay.label import CategoryInfo, AttributeInfo >>> from tensorbay.utility import NameList >>> categories = NameList() >>> categories.append(CategoryInfo("a")) >>> attributes = NameList() >>> attributes.append(AttributeInfo("gender", enum=["female", "male"])) >>> polyline2d_subcatalog = Polyline2DSubcatalog() >>> polyline2d_subcatalog.is_tracking = True >>> polyline2d_subcatalog.is_beizer_curve = True >>> polyline2d_subcatalog.categories = categories >>> polyline2d_subcatalog.attributes = attributes >>> polyline2d_subcatalog Polyline2DSubcatalog( (is_beizer_curve): True, (is_tracking): True, (categories): NameList [...], (attributes): NameList [...] )
- class tensorbay.label.label_polyline.LabeledPolyline2D(points=None, *, category=None, attributes=None, instance=None, beizer_point_types=None)[source]
Bases:
tensorbay.label.basic._LabelBase
,tensorbay.geometry.polyline.Polyline2D
This class defines the concept of polyline2D label.
LabeledPolyline2D
is the 2D polyline type of label, which is often used for CV tasks such as lane detection.- Parameters
points – A list of 2D points representing the vertexes of the 2D polyline.
category – The category of the label.
attributes – The attributes of the label.
instance – The instance id of the label.
beizer_point_types – The beizer point types of the label.
- category
The category of the label.
- Type
str
- attributes
The attributes of the label.
- Type
Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]
- instance
The instance id of the label.
- Type
str
- beizer_point_types
The beizer point types of the label.
- Type
str
Examples
>>> LabeledPolyline2D( ... [(1, 2), (2, 4), (2, 1)], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... beizer_point_types="LLL", ... ) LabeledPolyline2D [ Vector2D(1, 2), Vector2D(2, 4), Vector2D(2, 1) ]( (beizer_point_types): 'LLL', (category): 'example', (attributes): {...}, (instance): '123' )
- classmethod loads(contents)[source]
Loads a LabeledPolyline2D from a dict containing the information of the label.
- Parameters
contents (Dict[str, Any]) – A dict containing the information of the 2D polyline label.
- Returns
The loaded
LabeledPolyline2D
object.- Return type
tensorbay.label.label_polyline._T
Examples
>>> contents = { ... "polyline2d": [{'x': 1, 'y': 2}, {'x': 2, 'y': 4}, {'x': 2, 'y': 1}], ... "category": "example", ... "attributes": {"key": "value"}, ... "instance": "12345", ... "beizer_point_types": "LLL", ... } >>> LabeledPolyline2D.loads(contents) LabeledPolyline2D [ Vector2D(1, 2), Vector2D(2, 4), Vector2D(2, 1) ]( (beizer_point_types): 'LLL', (category): 'example', (attributes): {...}, (instance): '12345' )
- dumps()[source]
Dumps the current 2D polyline label into a dict.
- Returns
A dict containing all the information of the 2D polyline label.
- Return type
Dict[str, Any]
Examples
>>> labeledpolyline2d = LabeledPolyline2D( ... [(1, 2), (2, 4), (2, 1)], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... beizer_point_types="LLL", ... ) >>> labeledpolyline2d.dumps() { 'category': 'example', 'attributes': {'key': 'value'}, 'instance': '123', 'polyline2d': [{'x': 1, 'y': 2}, {'x': 2, 'y': 4}, {'x': 2, 'y': 1}], 'beizerPointTypes': 'LLL', }
- class tensorbay.label.label_polyline.MultiPolyline2DSubcatalog(is_tracking=False)[source]
Bases:
tensorbay.label.basic.SubcatalogBase
,tensorbay.label.supports.IsTrackingMixin
,tensorbay.label.supports.CategoriesMixin
,tensorbay.label.supports.AttributesMixin
This class defines the subcatalog for 2D multiple polyline type of labels.
- Parameters
is_tracking (bool) – A boolean value indicates whether the corresponding subcatalog contains tracking information.
- Return type
None
- description
The description of the entire 2D multiple polyline subcatalog.
- Type
str
- categories
All the possible categories in the corresponding dataset stored in a
NameList
with the category names as keys and theCategoryInfo
as values.
- category_delimiter
The delimiter in category values indicating parent-child relationship.
- Type
str
- attributes
All the possible attributes in the corresponding dataset stored in a
NameList
with the attribute names as keys and theAttributeInfo
as values.
- is_tracking
Whether the Subcatalog contains tracking information.
- Type
bool
Examples
Initialization Method 1: Init from
MultiPolyline2DSubcatalog.loads()
method.>>> catalog = { ... "MULTI_POLYLINE2D": { ... "isTracking": True, ... "categories": [{"name": "0"}, {"name": "1"}], ... "attributes": [{"name": "gender", "enum": ["male", "female"]}], ... } ... } >>> MultiPolyline2DSubcatalog.loads(catalog["MULTI_POLYLINE2D"]) MultiPolyline2DSubcatalog( (is_tracking): True, (categories): NameList [...], (attributes): NameList [...] )
Initialization Method 2: Init an empty MultiPolyline2DSubcatalog and then add the attributes.
>>> from tensorbay.label import CategoryInfo, AttributeInfo >>> multi_polyline2d_subcatalog = MultiPolyline2DSubcatalog() >>> multi_polyline2d_subcatalog.is_tracking = True >>> multi_polyline2d_subcatalog.add_category(CategoryInfo("a")) >>> multi_polyline2d_subcatalog.add_attribute( AttributeInfo("gender", enum=["female", "male"])) >>> multi_polyline2d_subcatalog MultiPolyline2DSubcatalog( (is_tracking): True, (categories): NameList [...], (attributes): NameList [...] )
- class tensorbay.label.label_polyline.LabeledMultiPolyline2D(polylines=None, *, category=None, attributes=None, instance=None)[source]
Bases:
tensorbay.label.basic._LabelBase
,tensorbay.geometry.polyline.MultiPolyline2D
This class defines the concept of multiPolyline2D label.
LabeledMultiPolyline2D
is the 2D multiple polyline type of label, which is often used for CV tasks such as lane detection.- Parameters
polylines – A list of polylines.
category – The category of the label.
attributes – The attributes of the label.
instance – The instance id of the label.
- category
The category of the label.
- Type
str
- attributes
The attributes of the label.
- Type
Dict[str, Union[str, int, float, bool, List[Union[str, int, float, bool]]]]
- instance
The instance id of the label.
- Type
str
Examples
>>> LabeledMultiPolyline2D( ... [[[1, 2], [2, 3]], [[3, 4], [6, 8]]], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... ) LabeledPolyline2D [ Polyline2D [...] Polyline2D [...] ]( (category): 'example', (attributes): {...}, (instance): '123' )
- classmethod loads(contents)[source]
Loads a LabeledMultiPolyline2D from a dict containing the information of the label.
- Parameters
contents (Dict[str, Any]) – A dict containing the information of the 2D polyline label.
- Returns
The loaded
LabeledMultiPolyline2D
object.- Return type
tensorbay.label.label_polyline._T
Examples
>>> contents = { ... "multiPolyline2d": [[{'x': 1, 'y': 1}, {'x': 1, 'y': 2}, {'x': 2, 'y': 2}], [{'x': 2, 'y': 3}, {'x': 3, 'y': 5}]], ... "category": "example", ... "attributes": {"key": "value"}, ... "instance": "12345", ... } >>> LabeledMultiPolyline2D.loads(contents) LabeledMultiPolyline2D [ Polyline2D [...] Polyline2D [...] ]( (category): 'example', (attributes): {...}, (instance): '12345' )
- dumps()[source]
Dumps the current 2D multiple polyline label into a dict.
- Returns
A dict containing all the information of the 2D polyline label.
- Return type
Dict[str, Any]
Examples
>>> labeledmultipolyline2d = LabeledMultiPolyline2D( ... [[[1, 1], [1, 2], [2, 2]], [[2, 3], [3, 5]]], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... ) >>> labeledpolyline2d.dumps() { 'category': 'example', 'attributes': {'key': 'value'}, 'instance': '123', 'polyline2d': [ [{'x': 1, 'y': 1}, {'x': 1, 'y': 2}, {'x': 2, 'y': 2}], [{'x': 2, 'y': 3}, {'x': 3, 'y': 5}], }