PointcloudAnnotation¶
- class PointcloudAnnotation[source]¶
Bases:
supervisely.video_annotation.video_annotation.VideoAnnotation
Class for creating and using PointcloudAnnotation
- Parameters
- objects : PointcloudObjectCollection, optional
PointcloudObjectCollection object
- figures : List[PointcloudFigure], optional
List[PointcloudFigure] object
- tags : PointcloudTagCollection, optional
PointcloudTagCollection object
- description : str, optional
Description text
- key : uuid.UUID, optional
uuid class object
- Usage example
import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap # PointcloudAnnotation example 1 pointcloud_ann = sly.PointcloudAnnotation() print(pointcloud_ann.to_json()) # Output: { # "description": "", # "key": "ad97e8a4a8524b8a992d1f083c5e6b00", # "tags": [], # "objects": [], # "figures": [] # } # PointcloudAnnotation example 2 key_id_map = KeyIdMap() project_meta_json = api.project.get_meta(pcd_info.project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) ann_json = api.pointcloud.annotation.download(pointcloud_id) ann = sly.PointcloudAnnotation.from_json( data=ann_json, project_meta=project_meta, key_id_map=key_id_map )
Methods
Makes a copy of PointcloudAnnotation with new fields, if fields are given, otherwise it will use fields of the original PointcloudAnnotation.
Convert pointcloud annotation from json format in PointcloudAnnotation object.
Get PointcloudObjectCollection object from annotation figures.
Check whether video annotation contains objects or tags, or not.
Annotation key value.
Loads json file and converts it to PointcloudAnnotation.
Convert PointcloudAnnotation to json format.
Not supported for pointcloud
Attributes
Video description.
PointcloudFigure objects.
Not supported for pointcloud
Not supported for pointcloud
Not supported for pointcloud
PointcloudObject objects collection.
PointcloudTag objects collection.
-
clone(objects=
None
, figures=None
, tags=None
, description=None
)[source]¶ Makes a copy of PointcloudAnnotation with new fields, if fields are given, otherwise it will use fields of the original PointcloudAnnotation.
- Parameters
- objects : PointcloudObjectCollection
PointcloudObjectCollection object
- figures : list of figures
list of pointcloud figures
- tags : PointcloudTagCollection
PointcloudTagCollection object
- description : str
Description text
- Return type
- Returns
PointcloudAnnotation class object
- Usage example
import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) key_id_map = KeyIdMap() pointcloud_id = 19481098 project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) ann_json = api.pointcloud.annotation.download(pointcloud_id) ann = sly.PointcloudAnnotation.from_json( data=ann_json, project_meta=project_meta, key_id_map=key_id_map ) obj_class_car = sly.ObjClass('car', sly.Cuboid) pointcloud_obj_car = sly.PointcloudObject(obj_class_car) new_objects = sly.PointcloudObjectCollection([pointcloud_obj_car]) new_ann = ann.clone(objects=new_objects) print(new_ann.to_json()) # Output: { # "description": "", # "figures": [], # "key": "2cc443272aca4cfa9c4f404614938aa7", # "objects": [ # { # "classTitle": "Pole", # "createdAt": "2023-03-16T06:38:44.934Z", # "key": "eff2ec5e3cda47968f45bc51b36a0dc1", # "labelerLogin": "almaz", # "tags": [], # "updatedAt": "2023-03-16T06:38:44.934Z" # }, # { # "classTitle": "Tram", # "createdAt": "2023-03-16T06:38:44.934Z", # "key": "6baa92e09ceb413ba8fbfcfae74be1c7", # "labelerLogin": "almaz", # "tags": [], # "updatedAt": "2023-03-16T06:38:44.934Z" # }, # { # "classTitle": "car", # "key": "6b1bced23061437b8ddbcdd267548c96", # "tags": [] # } # ], # "tags": [] # }
-
classmethod from_json(data, project_meta, key_id_map=
None
)[source]¶ Convert pointcloud annotation from json format in PointcloudAnnotation object.
- Parameters
- data : Dict
Pointcloud annotation in json format.
- project_meta : ProjectMeta
Project metadata.
- Returns
PointcloudAnnotation object.
- Return type
- Usage example
import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) key_id_map = KeyIdMap() pointcloud_id = pointcloud_id project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) ann_json = api.pointcloud.annotation.download(pointcloud_id) ann = sly.PointcloudAnnotation.from_json( data=ann_json, project_meta=project_meta, key_id_map=key_id_map )
- get_objects_from_figures()[source]¶
Get PointcloudObjectCollection object from annotation figures.
- Returns
PointcloudObjectCollection object from annotation figures.
- Return type
- Usage example
import supervisely as sly key_id_map = KeyIdMap() project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) ann_json = api.pointcloud.annotation.download(pointcloud_id) ann = sly.PointcloudAnnotation.from_json( data=ann_json, project_meta=project_meta, key_id_map=key_id_map ) objects = ann.get_objects_from_figures()
- is_empty()¶
Check whether video annotation contains objects or tags, or not.
- Returns
True if video annotation is empty, False otherwise.
- Return type
- Usage example
import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) project_id = 17208 video_id = 19371139 key_id_map = KeyIdMap() meta_json = api.project.get_meta(project_id) meta = sly.ProjectMeta.from_json(meta_json) ann_json = api.video.annotation.download(video_id) ann = sly.VideoAnnotation.from_json(ann_json, meta, key_id_map) print(ann.is_empty()) # False
- key()¶
Annotation key value.
- Returns
Key value of annotation object.
- Return type
- Usage example
import supervisely as sly height, width = 500, 700 frames_count = 1 # VideoObjectCollection obj_class_car = sly.ObjClass('car', sly.Rectangle) video_obj_car = sly.VideoObject(obj_class_car) objects = sly.VideoObjectCollection([video_obj_car]) video_ann = sly.VideoAnnotation((height, width), frames_count, objects) print(video_ann.key()) # Output: 6e5bd622-4d7b-45ee-8bc5-807d5a5e2134
-
classmethod load_json_file(path, project_meta, key_id_map=
None
)[source]¶ Loads json file and converts it to PointcloudAnnotation.
- Parameters
- path : str
Path to the json file.
- project_meta : ProjectMeta
Input
ProjectMeta
.- key_id_map : KeyIdMap, optional
KeyIdMap object.
- Returns
PointcloudAnnotation object
- Return type
- Usage example
import supervisely as sly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) team_name = 'Vehicle Detection' workspace_name = 'Cities' project_name = 'London' team = api.team.get_info_by_name(team_name) workspace = api.workspace.get_info_by_name(team.id, workspace_name) project = api.project.get_info_by_name(workspace.id, project_name) project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) # Load json file path = "/home/admin/work/docs/my_dataset/ann/annotation.json" ann = sly.PointcloudAnnotation.load_json_file(path, project_meta)
-
to_json(key_id_map=
None
)[source]¶ Convert PointcloudAnnotation to json format.
- Returns
PointcloudAnnotation in json format
- Return type
Dict
- Usage example
import supervisely as sly pointcloud_ann = sly.PointcloudAnnotation() print(pointcloud_ann.to_json()) # Output: { # "description": "", # "key": "ad97e8a4a8524b8a992d1f083c5e6b00", # "tags": [], # "objects": [], # "figures": [] # }
- property description¶
Video description.
- Returns
Video description
- Return type
- Usage example
import supervisely as sly height, width = 500, 700 frames_count = 1 descr = 'example' video_ann = sly.VideoAnnotation((height, width), frames_count, description=descr) print(video_ann.description) # example
- property figures¶
PointcloudFigure objects.
- Returns
List of PointcloudFigure objects from PointcloudAnnotation object.
- Return type
- Usage example
import supervisely as sly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) # Load json file path = "/home/admin/work/docs/my_dataset/ann/annotation.json" ann = sly.PointcloudAnnotation.load_json_file(path, project_meta) figures = ann.figures
- property frames¶
Not supported for pointcloud
- property frames_count¶
Not supported for pointcloud
- property img_size¶
Not supported for pointcloud
- property objects¶
PointcloudObject objects collection.
- Returns
PointcloudObjectCollection object.
- Return type
- Usage example
import supervisely as sly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) # Load json file path = "/home/admin/work/docs/my_dataset/ann/annotation.json" ann = sly.PointcloudAnnotation.load_json_file(path, project_meta) objects = ann.objects
- property tags¶
PointcloudTag objects collection.
- Returns
PointcloudTagCollection object.
- Return type
- Usage example
import supervisely as sly address = 'https://app.supervise.ly/' token = 'Your Supervisely API Token' api = sly.Api(address, token) project_id = 19441 project_meta_json = api.project.get_meta(project_id) project_meta = sly.ProjectMeta.from_json(project_meta_json) # Load json file path = "/home/admin/work/docs/my_dataset/ann/annotation.json" ann = sly.PointcloudAnnotation.load_json_file(path, project_meta) tags = ann.tags