PointcloudFigure

class PointcloudFigure[source]

Bases: supervisely.video_annotation.video_figure.VideoFigure

PointcloudFigure object for PointcloudAnnotation or PointcloudEpisodeAnnotation. PointcloudFigure objects is immutable.

Parameters
parent_object : Union[PointcloudObject, PointcloudEpisodeObject]

PointcloudObject or PointcloudObject object.

geometry : Geometry

Label geometry.

frame_index : int

Index of Frame to which PointcloudFigure belongs.

key : KeyIdMap, optional

KeyIdMap object.

class_id : int, optional

ID of PointcloudObject (or PointcloudEpisodeObject) to which PointcloudFigure belongs.

labeler_login : str, optional

Login of the user who created PointcloudFigure.

updated_at : str, optional

Date and Time when PointcloudFigure 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 PointcloudFigure 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, Vector3d

obj_class_car = sly.ObjClass('car', Cuboid3d)
pointcloud_obj_car = sly.PointcloudObject(obj_class_car)

position, rotation, dimension = Vector3d(-3.4, 28.9, -0.7), Vector3d(0., 0, -0.03), Vector3d(1.8, 3.9, 1.6)
cuboid = Cuboid3d(position, rotation, dimension)
frame_index = 10
figure = sly.PointcloudFigure(pointcloud_obj_car, cuboid, frame_index=frame_index)

print(figure.to_json())
# Output: {
#     "geometry": {
#         "dimensions": { "x": 1.8, "y": 3.9, "z": 1.6 },
#         "position": { "x": -3.4, "y": 28.9, "z": -0.7 },
#         "rotation": { "x": 0.0, "y": 0, "z": -0.03 }
#     },
#     "geometryType": "cuboid_3d",
#     "key": "4beae1be12624b70ad533c8be7477605",
#     "objectKey": "c1e1965efc0d4ae9b0b39367b04d637a"
# }

Methods

clone

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

from_json

Convert a json dict to PointcloudFigure.

get_meta

Get metadata for the video figure.

key

Figure key.

to_json

Convert the VideoFigure to a json dict.

validate_bounds

Not supported for pointcloud.

Attributes

frame_index

Frame index of the current VideoFigure.

geometry

Geometry of the current VideoFigure.

parent_object

PointcloudObject of current PointcloudFigure.

video_object

Not supported for pointcloud.

clone(parent_object=None, geometry=None, frame_index=None, key=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]

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

Parameters
parent_object : PointcloudObject or PointcloudEpisodeObject, optional

PointcloudObject (or PointcloudEpisodeObject) object.

geometry : Geometry, optional

Label geometry.

frame_index : int, optional

Index of Frame to which PointcloudFigure belongs.

key : KeyIdMap, optional

KeyIdMap object.

class_id : int, optional

ID of ObjClass to which PointcloudFigure belongs.

labeler_login : str, optional

Login of the user who created PointcloudFigure.

updated_at : str, optional

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

Returns

PointcloudFigure object

Return type

PointcloudFigure

Usage example
import supervisely as sly

from supervisely.geometry.cuboid_3d import Cuboid3d, Vector3d

obj_class_car = sly.ObjClass('car', Cuboid3d)
pointcloud_obj_car = sly.PointcloudObject(obj_class_car)

position, rotation, dimension = Vector3d(-3.4, 28.9, -0.7), Vector3d(0., 0, -0.03), Vector3d(1.8, 3.9, 1.6)
cuboid = Cuboid3d(position, rotation, dimension)
frame_index = 10
figure = sly.PointcloudFigure(pointcloud_obj_car, cuboid, frame_index=frame_index)

# Remember that PointcloudFigure object is immutable, and we need to assign new instance of PointcloudFigure to a new variable
pointcloud_figure_clone = figure.clone(parent_object=pointcloud_obj_car, frame_index=11)

print(pointcloud_figure_clone.to_json())
# Output: {
#     "geometry": {
#         "dimensions": { "x": 1.8, "y": 3.9, "z": 1.6 },
#         "position": { "x": -3.4, "y": 28.9, "z": -0.7 },
#         "rotation": { "x": 0.0, "y": 0, "z": -0.03 }
#     },
#     "geometryType": "cuboid_3d",
#     "key": "4beae1be12624b70ad533c8be7477605",
#     "objectKey": "c1e1965efc0d4ae9b0b39367b04d637a"
# }
classmethod from_json(data, objects, frame_index=None, key_id_map=None)[source]

Convert a json dict to PointcloudFigure. Read more about Supervisely format.

Parameters
data : dict

Dict in json format.

objects : PointcloudObjectCollection or PointcloudEpisodeObjectCollection

PointcloudObjectCollection or PointcloudEpisodeObjectCollection object.

frame_index : int

Index of Frame to which PointcloudFigure belongs.

key_id_map : KeyIdMap, optional

KeyIdMap object.

Raises

RuntimeError, if point cloudobject ID and pointcloud object key are None, if pointcloud object key and key_id_map are None, if pointcloud object with given id not found in key_id_map

Returns

PointcloudFigure object

Return type

PointcloudFigure

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

obj_class_car = sly.ObjClass('car', Cuboid3d)
pointcloud_obj_car = sly.PointcloudObject(obj_class_car)

position, rotation, dimension = Vector3d(-3.4, 28.9, -0.7), Vector3d(0., 0, -0.03), Vector3d(1.8, 3.9, 1.6)
cuboid = Cuboid3d(position, rotation, dimension)
frame_index = 10
figure = sly.PointcloudFigure(pointcloud_obj_car, cuboid, frame_index=frame_index)
pointcloud_figure_json = figure.to_json(save_meta=True)

new_pointcloud_figure = sly.PointcloudFigure.from_json(
    pointcloud_figure_json,
    sly.PointcloudObjectCollection([pointcloud_obj_car]),
    frame_index
)
get_meta()

Get metadata for the video figure.

Returns

Dictionary with metadata for the video figure.

Return type

Dict[str, int]

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)
fr_index = 7
geometry = sly.Rectangle(0, 0, 100, 100)
video_figure_car = sly.VideoFigure(video_obj_car, geometry, fr_index)

print(video_figure_car.get_meta()) # {'frame': 7}
key()

Figure key.

Returns

Figure key.

Return type

UUID

Usage example
key = video_figure_car.key
print(key) # 158e6cf4f4ac4c639fc6994aad127c16
to_json(key_id_map=None, save_meta=False)

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

Parameters
key_id_map : KeyIdMap, optional

KeyIdMap object.

save_meta : bool, optional

Save frame index or not.

Returns

Json format as a dict

Return type

dict

Usage example
import supervisely as sly

obj_class_car = sly.ObjClass('car', sly.Rectangle)
video_obj_car = sly.VideoObject(obj_class_car)
fr_index = 7
geometry = sly.Rectangle(0, 0, 100, 100)
video_figure_car = sly.VideoFigure(video_obj_car, geometry, fr_index)
video_figure_json = video_figure_car.to_json(save_meta=True)
print(video_figure_json)
# Output: {
#     "key": "591d0511ba28462c8cd657691743359c",
#     "objectKey": "e061bc50bd464c23a008b712d195570a",
#     "geometryType": "rectangle",
#     "geometry": {
#         "points": {
#             "exterior": [
#                 [
#                     0,
#                     0
#                 ],
#                 [
#                     100,
#                     100
#                 ]
#             ],
#             "interior": []
#         }
#     },
#     "meta": {
#         "frame": 7
#     }
# }
validate_bounds(img_size, _auto_correct=False)[source]

Not supported for pointcloud.

property frame_index

Frame index of the current VideoFigure.

Returns

Index of Frame to which VideoFigure belongs

Return type

int

Usage example
fr_index = video_figure_car.frame_index
print(fr_index) # 7
property geometry

Geometry of the current VideoFigure.

Returns

Geometry object

Return type

Geometry

Usage example
geometry = video_figure_car.geometry
print(geometry.to_json())
# Output: {
#     "points": {
#         "exterior": [
#             [
#                 0,
#                 0
#             ],
#             [
#                 100,
#                 100
#             ]
#         ],
#         "interior": []
#     }
# }
property parent_object

PointcloudObject of current PointcloudFigure.

Returns

PointcloudObject ot PointcloudEpisodeObject object

Return type

PointcloudObject or PointcloudEpisodeObject

Usage example
pointcloud_obj_car = pointcloud_figure_car.parent_object

print(pointcloud_obj_car.to_json())
# Output: {
#     "key": "d573c6f081544e3da20022d932b259c1",
#     "classTitle": "car",
#     "tags": []
# }
property video_object

Not supported for pointcloud.

Return type

None