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: bool = 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 – A boolean value indicates whether the corresponding subcatalog contains tracking information.
- 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
Examples
Initialization Method 1: Init from
Polyline2DSubcatalog.loads()
method.>>> catalog = { ... "POLYLINE2D": { ... "isTracking": True, ... "categories": [{"name": "0"}, {"name": "1"}], ... "attributes": [{"name": "gender", "enum": ["male", "female"]}], ... } ... } >>> Polyline2DSubcatalog.loads(catalog["POLYLINE2D"]) Polyline2DSubcatalog( (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.categories = categories >>> polyline2d_subcatalog.attributes = attributes >>> polyline2d_subcatalog Polyline2DSubcatalog( (is_tracking): True, (categories): NameList [...], (attributes): NameList [...] )
- class tensorbay.label.label_polyline.LabeledPolyline2D(points: Optional[Iterable[Iterable[float]]] = None, *, category: Optional[str] = None, attributes: Optional[Dict[str, Any]] = None, instance: Optional[str] = None)[source]¶
Bases:
tensorbay.geometry.point_list.PointList2D
[tensorbay.geometry.vector.Vector2D
]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.
- 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
>>> LabeledPolyline2D( ... [(1, 2), (2, 4), (2, 1)], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... ) LabeledPolyline2D [ Vector2D(1, 2), Vector2D(2, 4), Vector2D(2, 1) ]( (category): 'example', (attributes): {...}, (instance): '123' )
- classmethod loads(contents: Dict[str, Any]) tensorbay.label.label_polyline._T [source]¶
Loads a LabeledPolyline2D from a dict containing the information of the label.
- Parameters
contents – A dict containing the information of the 2D polyline label.
- Returns
The loaded
LabeledPolyline2D
object.
Examples
>>> contents = { ... "polyline2d": [{'x': 1, 'y': 2}, {'x': 2, 'y': 4}, {'x': 2, 'y': 1}], ... "category": "example", ... "attributes": {"key": "value"}, ... "instance": "12345", ... } >>> LabeledPolyline2D.loads(contents) LabeledPolyline2D [ Vector2D(1, 2), Vector2D(2, 4), Vector2D(2, 1) ]( (category): 'example', (attributes): {...}, (instance): '12345' )
- dumps() Dict[str, Any] [source]¶
Dumps the current 2D polyline label into a dict.
- Returns
A dict containing all the information of the 2D polyline label.
Examples
>>> labeledpolyline2d = LabeledPolyline2D( ... [(1, 2), (2, 4), (2, 1)], ... category="example", ... attributes={"key": "value"}, ... instance="123", ... ) >>> labeledpolyline2d.dumps() { 'category': 'example', 'attributes': {'key': 'value'}, 'instance': '123', 'polyline2d': [{'x': 1, 'y': 2}, {'x': 2, 'y': 4}, {'x': 2, 'y': 1}], }
- class tensorbay.label.label_polyline.MultiPolyline2DSubcatalog(is_tracking: bool = 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 – A boolean value indicates whether the corresponding subcatalog contains tracking information.
- 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: Optional[Iterable[Iterable[float]]] = None, *, category: Optional[str] = None, attributes: Optional[Dict[str, Any]] = None, instance: Optional[str] = None)[source]¶
Bases:
tensorbay.geometry.point_list.MultiPointList2D
[tensorbay.geometry.polyline.Polyline2D
]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: Dict[str, Any]) tensorbay.label.label_polyline._T [source]¶
Loads a LabeledMultiPolyline2D from a dict containing the information of the label.
- Parameters
contents – A dict containing the information of the 2D polyline label.
- Returns
The loaded
LabeledMultiPolyline2D
object.
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() Dict[str, Any] [source]¶
Dumps the current 2D multiple polyline label into a dict.
- Returns
A dict containing all the information of the 2D polyline label.
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}], }