PointcloudTag¶
- class PointcloudTag[source]¶
Bases:
supervisely.annotation.tag.Tag
PointcloudTag object for
PointcloudAnnotation
.PointcloudTag
object is immutable.- Parameters
- meta :
TagMeta
General information about Pointcloud Tag.
- value :
str
orint
orfloat
orNoneType
, optional Pointcloud Tag value. Depends on
TagValueType
ofTagMeta
.- key : uuid.UUID, optional
uuid.UUID object.
- sly_id :
int
, optional Video Tag ID in Supervisely.
- labeler_login :
str
, optional Login of user who created PointcloudTag.
- updated_at :
str
, optional Date and Time when PointcloudTag was modified last. Date Format: Year:Month:Day:Hour:Minute:Seconds. Example: ‘2021-01-22T19:37:50.158Z’.
- created_at :
str
, optional Date and Time when PointcloudTag was created. Date Format is the same as in “updated_at” parameter.
- meta :
- Raises
ValueError
, If PointcloudTag value is incompatible toTagMeta
value type.- Usage example
import supervisely as sly meta_dog = sly.TagMeta('dog', sly.TagValueType.NONE) # Now we can create a PointcloudTag using our TagMeta tag_dog = sly.PointcloudTag(meta_dog) # When you are creating a new Tag # Tag.value is automatically cross-checked against your TagMeta value type to make sure the value is valid. # If we now try to add a value to our newly created Tag, we receive "ValueError", because our TagMeta value type is "NONE" tag_dog = sly.PointcloudTag(meta_dog, value="Husky") # Output: ValueError: Tag dog can not have value Husky # Let's create another Tag with a string value type meta_cat = sly.TagMeta('cat', sly.TagValueType.ANY_STRING) tag_cat = sly.PointcloudTag(meta_cat, value="Fluffy") # Now let's create a Tag using TagMeta with "ONEOF_STRING" value type # In order to use "oneof_string value type", you must initialize a variable with possible values(see class TagMeta for more information) colors = ["brown", "white", "black", "red", "chocolate", "gold", "grey"] meta_coat_color = sly.TagMeta('coat color', sly.TagValueType.ONEOF_STRING, possible_values=colors) tag_coat_color = sly.PointcloudTag(meta_coat_color, value="white") # If given value is not in a list of possible Tags, ValueError will be raised tag_coat_color = sly.PointcloudTag(meta_coat_color, value="yellow") # Output: ValueError: Tag coat color can not have value yellow
Methods
Clone makes a copy of Pointcloud Tag with new fields, if fields are given, otherwise it will use original Tag fields.
Convert a json dict to VideoTag.
Get string with information about PointcloudTag name and value.
Get header of the table with tags.
Get row with tag properties.
Get PointcloudTag key value.
Convert the PointcloudTag to a json dict.
Attributes
General information about Tag.
Name property.
Tag value.
-
clone(meta=
None
, value=None
, key=None
, sly_id=None
, labeler_login=None
, updated_at=None
, created_at=None
)[source]¶ Clone makes a copy of Pointcloud Tag with new fields, if fields are given, otherwise it will use original Tag fields.
- Parameters
- meta :
TagMeta
, optional TagMeta object.
- value :
str
orint
orfloat
orNoneType
, optional Pointcloud Tag value. Depends on
TagValueType
ofTagMeta
.- key : uuid.UUID, optional
uuid.UUID object.
- sly_id :
int
, optional Pointcloud Tag ID in Supervisely server.
- labeler_login :
str
, optional Login of user who created Pointcloud Tag.
- updated_at :
str
, optional Date and Time when Pointcloud Tag was modified last. Date Format: Year:Month:Day:Hour:Minute:Seconds. Example: ‘2021-01-22T19:37:50.158Z’.
- created_at :
str
, optional Date and Time when Pointcloud Tag was created. Date Format is the same as in “updated_at” parameter.
- meta :
- Returns
New instance of Pointcloud Tag
- Return type
- Raises
ValueError
, If PointcloudTag value is incompatible toTagMeta
value type.- Usage Example
import supervisely as sly # Original Pointcloud Tag weather_conditions = ["Sunny", "Cloudy", "Snowy", "Foggy", "Rainy"] meta_weather = sly.TagMeta("weather", sly.TagValueType.ONEOF_STRING, possible_values=weather_conditions) tag_weather = sly.PointcloudTag(meta_weather, value="Sunny") # Let's create some more tags by cloning our original Pointcloud Tag # Remember that PointcloudTag class object is immutable, and we need to assign new instance of PointcloudTag to a new variable clone_weather_1 = tag_weather.clone(value="Snowy") clone_weather_2 = tag_weather.clone(value="Cloudy") clone_weather_3 = tag_weather.clone(value="Rainy")
-
classmethod from_json(data, tag_meta_collection, key_id_map=
None
)[source]¶ Convert a json dict to VideoTag. Read more about Supervisely format.
- Parameters
- data :
dict
PointcloudTag in json format as a dict.
- tag_meta_collection :
TagMetaCollection
: TagMetaCollection TagMetaCollection object.
- key_id_map :
KeyIdMap
, optional KeyIdMap object.
- data :
- Returns
PointcloudTag object
- Return type
- Usage example
import supervisely as sly tag_cat_json = { "name": "cat", "value": "Fluffy" } meta_cat = sly.TagMeta('cat', sly.TagValueType.ANY_STRING) meta_collection = sly.TagMetaCollection([meta_cat]) tag_cat = sly.PointcloudTag.from_json(tag_cat_json, meta_collection)
- get_compact_str()[source]¶
Get string with information about PointcloudTag name and value.
- Returns
Information about PointcloudTag object
- Return type
- Usage example
import supervisely as sly meta_cat = sly.TagMeta('cat', sly.TagValueType.ANY_STRING) tag_cat = sly.PointcloudTag(meta_cat, value="Fluffy") compact_tag_cat = tag_cat.get_compact_str() print(compact_tag_cat) # cat:Fluffy
- classmethod get_header_ptable()¶
Get header of the table with tags.
- Returns
List of table header values.
- Return type
List[str]
- Usage example
import supervisely as sly header = sly.Tag.get_header_ptable() print(header) # Output: ['Name', 'Value type', 'Value']
- get_row_ptable()¶
Get row with tag properties.
- Returns
List of tag properties.
- Return type
List[str]
- Usage example
import supervisely as sly weather_conditions = ["Sunny", "Cloudy", "Snowy", "Foggy", "Rainy"] meta_weather = sly.TagMeta("weather", sly.TagValueType.ONEOF_STRING, possible_values=weather_conditions) tag_weather = sly.Tag(meta_weather, value="Sunny") row = tag_weather.get_row_ptable() print(row) # Output: ['weather', 'oneof_string', 'Sunny']
- key()[source]¶
Get PointcloudTag key value.
- Returns
PointcloudTag key value
- Return type
- Usage example
import supervisely as sly weather_conditions = ["Sunny", "Cloudy", "Snowy", "Foggy", "Rainy"] meta_weather = sly.TagMeta("weather", sly.TagValueType.ONEOF_STRING, possible_values=weather_conditions) tag_weather = sly.Tag(meta_weather, value="Sunny") key = tag_weather.key() print(key) # Output: 5c7988e0-eee4-4eb1-972c-b1e3e879f78c
-
to_json(key_id_map=
None
)[source]¶ Convert the PointcloudTag to a json dict. Read more about Supervisely format.
- Parameters
- key_id_map :
KeyIdMap
, optional KeyIdMap object.
- key_id_map :
- Returns
Json format as a dict
- Return type
- Usage example
import supervisely as sly meta_dog = sly.TagMeta('dog', sly.TagValueType.NONE) tag_dog = sly.PointcloudTag(meta_dog) tag_dog_json = tag_dog.to_json() print(tag_dog_json) # Output: { # "name": "dog", # "key": "058ad7993a534082b4d94cc52542a97d" # }
- property meta¶
General information about Tag. When creating a new Tag, it’s value is automatically cross-checked against
TagValueType
to make sure that value is valid.- Returns
TagMeta object
- Return type
- Usage example
meta_dog = sly.TagMeta('dog', sly.TagValueType.NONE) tag_dog = sly.Tag(meta_dog) # Our TagMeta has value type 'NONE', if we try to add value to our Tag, "ValueError" error will be raised tag_dog = sly.Tag(meta_dog, value="Husky") # Output: ValueError: Tag dog can not have value Husky
- property name¶
Name property.
- Returns
Name
- Return type
- Usage example
meta_dog = sly.TagMeta('dog', sly.TagValueType.ANY_STRING) tag_dog = sly.Tag(meta_dog, value="Husky") print(tag_dog.name) # Output: "dog"
- property value¶
Tag value. Return type depends on
TagValueType
.- Returns
Tag value
- Return type
- Usage example
meta_dog = sly.TagMeta('dog', sly.TagValueType.ANY_STRING) tag_dog = sly.Tag(meta_dog, value="Husky") meta_age = sly.TagMeta('age', sly.TagValueType.ANY_NUMBER) tag_age = sly.Tag(meta_age, value=9) colors = ["Black", "White", "Golden", "Brown"] meta_color = sly.TagMeta('coat color', sly.TagValueType.ONEOF_STRING, possible_values=colors) tag_color = sly.Tag(meta_color, value="White") type(tag_dog.value) # 'str' type(tag_age.value) # 'int' type(tag_color.value) # 'str'