PointcloudObject

class PointcloudObject[source]

Bases: supervisely.video_annotation.video_object.VideoObject

PointcloudObject object for PointcloudAnnotation. PointcloudObject object is immutable.

Parameters
obj_class : ObjClass

class object.

tags : VideoTagCollection, optional

tags object.

key : KeyIdMap, optional

KeyIdMap object.

class_id : int, optional

ID of ObjClass to which PointcloudObject belongs.

labeler_login : str, optional

Login of the user who created PointcloudObject.

updated_at : str, optional

Date and Time when PointcloudObject 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 PointcloudObject was created. Date Format is the same as in “updated_at” parameter.

Usage example
import supervisely as sly
from supervisely.geometry.cuboid_3d import Cuboid3d

obj_class_car = sly.ObjClass('car', Cuboid3d)
pointcloud_obj_car = sly.PointcloudObject(obj_class_car)
pointcloud_obj_car_json = pointcloud_obj_car.to_json()
print(pointcloud_obj_car_json)
# Output: {
#     "key": "6b819f1840f84d669b32cdec225385f0",
#     "classTitle": "car",
#     "tags": []
# }

Methods

add_tag

Adds VideoTag to the current VideoObject.

add_tags

Adds VideoTags to the current VideoObject.

clone

Makes a copy of VideoObject with new fields, if fields are given, otherwise it will use fields of the original VideoObject.

from_json

Convert PointcloudObject from json format to PointcloudObject class object.

key

Object key.

to_json

Convert the VideoObject to a json dict.

Attributes

class_id

Object class ID.

obj_class

ObjClass of the current VideoObject.

tags

VideoTagCollection of the current VideoObject.

tag_collection_type

alias of supervisely.pointcloud_annotation.pointcloud_tag_collection.PointcloudTagCollection

add_tag(tag)

Adds VideoTag to the current VideoObject.

Parameters
tag : VideoTag

VideoTag to be added.

Returns

VideoObject object

Return type

VideoObject

Usage example
import supervisely as sly

# Create VideoObject
obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)

# Create VideoTag
meta_car = sly.TagMeta('car_tag', sly.TagValueType.ANY_STRING)
from supervisely.video_annotation.video_tag import VideoTag
car_tag = VideoTag(meta_car, value='acura')

# Add VideoTag
new_obj_car = video_obj_car.add_tag(car_tag)
new_obj_car_json = new_obj_car.to_json()
print(new_obj_car_json)
# Output: {
#     "key": "1ab52285ee634c93b724fa655b785eae",
#     "classTitle": "car",
#     "tags": [
#         {
#             "name": "car_tag",
#             "value": "acura",
#             "key": "d9e52b275e074c538f162a6d679aed9e"
#         }
#     ]
# }
add_tags(tags)

Adds VideoTags to the current VideoObject.

Parameters
tag : List[VideoTag]

List of VideoTags to be added.

Returns

VideoObject object

Return type

VideoObject

Usage example
import supervisely as sly

# Create VideoObject
obj_class_vehicle = sly.ObjClass('vehicle', sly.Rectangle)
video_obj_vehicle = sly.VideoObject(obj_class_vehicle)

# Create VideoTags
from supervisely.video_annotation.video_tag import VideoTag
meta_car = sly.TagMeta('car_tag', sly.TagValueType.ANY_STRING)
car_tag = VideoTag(meta_car, value='acura')
meta_bus = sly.TagMeta('bus_tag', sly.TagValueType.ANY_STRING)
bus_tag = VideoTag(meta_bus, value='volvo')

# Add VideoTags
new_obj_vehicle = video_obj_vehicle.add_tags([car_tag, bus_tag])
new_obj_vehicle_json = new_obj_vehicle.to_json()
print(new_obj_vehicle_json)
# Output: {
#     "key": "94055c5e8cb146368f627fc608fb6b44",
#     "classTitle": "vehicle",
#     "tags": [
#         {
#             "name": "car_tag",
#             "value": "acura",
#             "key": "6679f47c96734565919fbffc278532a1"
#         },
#         {
#             "name": "bus_tag",
#             "value": "volvo",
#             "key": "d0a60dc929de491a85a09fea59adb818"
#         }
#     ]
# }
clone(obj_class=None, tags=None, key=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)

Makes a copy of VideoObject with new fields, if fields are given, otherwise it will use fields of the original VideoObject.

Parameters
obj_class : ObjClass, optional

VideoObject class.

tags : VideoTagCollection, optional

VideoObject tags.

key : KeyIdMap, optional

KeyIdMap object.

class_id : int, optional

ID of ObjClass to which VideoObject belongs.

labeler_login : str, optional

Login of the user who created VideoObject.

updated_at : str, optional

Date and Time when VideoObject 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 VideoObject was created. Date Format is the same as in “updated_at” parameter.

Returns

VideoObject object

Return type

VideoObject

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('vehicle', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)

# New ObjClass to clone
obj_class_bus = sly.ObjClass('bus', sly.Rectangle)

# New VideoTagCollection to clone
from supervisely.video_annotation.video_tag import VideoTag
meta_car = sly.TagMeta('car_tag', sly.TagValueType.ANY_STRING)
car_tag = VideoTag(meta_car, value='acura')
from supervisely.video_annotation.video_tag_collection import VideoTagCollection
tags = VideoTagCollection([car_tag])
# Clone
new_obj_vehicle = video_obj_car.clone(obj_class=obj_class_bus, tags=tags)
new_obj_vehicle_json = new_obj_vehicle.to_json()
print(new_obj_vehicle_json)
# Output: {
#     "key": "39ae5b9ce1ca405c9f53544374b3f5be",
#     "classTitle": "bus",
#     "tags": [
#         {
#             "name": "car_tag",
#             "value": "acura",
#             "key": "3119b6e38fe24fe7a220e881154fd9ba"
#         }
#     ]
# }
classmethod from_json(data, project_meta, key_id_map=None)[source]

Convert PointcloudObject from json format to PointcloudObject class object. Raise error if object class name is not found in the given project meta.

Parameters
data : dict

PointcloudObject in json format.

project_meta : ProjectMeta

Project metadata.

key_id_map : KeyIdMap, optional

KeyIdMap object.

Returns

PointcloudObject object.

Return type

PointcloudObject

Usage example
import supervisely as sly
from supervisely.geometry.cuboid_3d import Cuboid3d, Vector3d

key_id_map = KeyIdMap()
project_id = 19441
obj_class_car = sly.ObjClass('car', Cuboid3d)
project_meta = sly.ProjectMeta([obj_class_car])
api.project.update_meta(id=project_id, meta=project_meta)
pointcloud_obj_car = sly.PointcloudObject(obj_class_car)
pointcloud_obj_car_json = pointcloud_obj_car.to_json()
new_pointcloud_obj_car = sly.PointcloudObject.from_json(
    data=pointcloud_obj_car_json,
    project_meta=project_meta,
    key_id_map=key_id_map
)
pprint(new_pointcloud_obj_car)
# <supervisely.pointcloud_annotation.pointcloud_object.PointcloudObject object at 0x7f97e0ba8ed0>
key()

Object key.

Returns

Object key

Return type

uuid.UUID

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)
key = video_obj_car.key()
print(key)
# Output: 158e6cf4f4ac4c639fc6994aad127c16
to_json(key_id_map=None)

Convert the VideoObject to a json dict. Read more about Supervisely format.

Parameters
key_id_map : KeyIdMap, optional

KeyIdMap object.

Returns

Json format as a dict

Return type

dict

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('vehicle', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)

obj_car_json = video_obj_car.to_json()
print(obj_car_json)
# Output: {
#     "key": "ce26e77a45bc45e88e3e17da1672d01f",
#     "classTitle": "vehicle",
#     "tags": []
# }
property class_id

Object class ID.

Returns

Object class ID.

Return type

int

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)
class_id = video_obj_car.class_id
property obj_class

ObjClass of the current VideoObject.

Returns

ObjClass object

Return type

ObjClass

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)
obj_car_json = video_obj_car.obj_class.to_json()
print(obj_car_json)
# Output: {
#     "title": "car",
#     "shape": "rectangle",
#     "color": "#8A0F7B",
#     "geometry_config": {},
#     "hotkey": ""
# }
property tags

VideoTagCollection of the current VideoObject.

Returns

VideoTagCollection object

Return type

VideoTagCollection

Usage example
import supervisely as sly

# Create VideoTagCollection
meta_car = sly.TagMeta('car_tag', sly.TagValueType.ANY_STRING)
from supervisely.video_annotation.video_tag import VideoTag
car_tag = VideoTag(meta_car, value='acura')
from supervisely.video_annotation.video_tag_collection import VideoTagCollection
video_tags = VideoTagCollection([car_tag])

# Create VideoObject
obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car, video_tags)

# Get VideoTagCollection
tags = video_obj_car.tags
tags_json = tags.to_json()
print(tags_json)
# Output: [
#     {
#         "name": "car_tag",
#         "value": "acura",
#         "key": "4f82fbcab74c44259d7a0e29d604602e"
#     }
# ]