PointcloudAnnotation¶
-
class PointcloudAnnotation(objects=
None, figures=None, tags=None, description='', key=None)[source]¶ Bases:
VideoAnnotationAnnotation for a single point cloud item in Supervisely format.
Stores point cloud-level tags, objects and figures (e.g. cuboids) and supports JSON (de)serialization via
to_json()/from_json().Class for creating and using PointcloudAnnotation
- Parameters:
- 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.
-
classmethod from_json(data, project_meta, key_id_map=
None)[source]¶ Convert pointcloud annotation from json format in PointcloudAnnotation object.
- Parameters:
- Returns:
Pointcloud annotation object.
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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 )
-
classmethod load_json_file(path, project_meta, key_id_map=
None)[source]¶ Loads json file and converts it to PointcloudAnnotation.
- Parameters:
- Returns:
Pointcloud annotation object.
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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)
-
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:
- Returns:
PointcloudAnnotationclass object- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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": [] # }
- get_objects_from_figures()[source]¶
Get PointcloudObjectCollection object from annotation figures.
- Returns:
Pointcloud objects collection 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 os from dotenv import load_dotenv import supervisely as sly from supervisely.video_annotation.key_id_map import KeyIdMap # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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:
UUID
- 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
-
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 : str¶
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 : list[supervisely.pointcloud_annotation.pointcloud_figure.PointcloudFigure]¶
PointcloudFigure objects.
- Returns:
List of pointcloud figures from
PointcloudAnnotationobject.- Return type:
List[
PointcloudFigure]- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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 : supervisely.pointcloud_annotation.pointcloud_object_collection.PointcloudObjectCollection¶
PointcloudObject objects collection.
- Returns:
Pointcloud objects collection.
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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 : supervisely.pointcloud_annotation.pointcloud_tag_collection.PointcloudTagCollection¶
PointcloudTag objects collection.
- Returns:
Pointcloud tags collection.
- Return type:
- Usage Example:
import os from dotenv import load_dotenv import supervisely as sly # Load secrets and create API object from .env file (recommended) # Learn more here: https://developer.supervisely.com/getting-started/basics-of-authentication if sly.is_development(): load_dotenv(os.path.expanduser("~/supervisely.env")) api = sly.Api.from_env() 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