PointcloudEpisodeFrame¶
- class PointcloudEpisodeFrame[source]¶
Bases:
supervisely.video_annotation.frame.Frame
PointcloudEpisodeFrame object for
PointcloudEpisodeAnnotation
.PointcloudEpisodeFrame
object is immutable.- Parameters
- index : int
Index of the PointcloudEpisodeFrame.
- figures : list, optional
List of
PointcloudFigure
.
- Usage example
import supervisely as sly from supervisely.geometry.cuboid_3d import Cuboid3d, Vector3d from supervisely.pointcloud_annotation.pointcloud_object_collection import PointcloudObjectCollection # Create pointcloud object obj_class_car = sly.ObjClass('car', Cuboid3d) pointcloud_obj_car = sly.PointcloudObject(obj_class_car) objects = PointcloudObjectCollection([pointcloud_obj_car]) # Create figure frame_index = 7 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) figure = sly.PointcloudFigure(pointcloud_obj_car, cuboid, frame_index=frame_index) frame = sly.PointcloudEpisodeFrame(frame_index, figures=[figure]) print(frame.to_json()) # Output: { # "figures": [ # { # "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": "cd61788d6faa401b9723f066f92a8a30", # "objectKey": "c081cb9f34e54ff2bd85e04e7713ed76" # } # ], # "index": 7 # }
Methods
clone
- rtype
Convert a json dict to PointcloudEpisodeFrame.
Get Frame key (index) value.
Convert the Frame to a json dict.
Checks if image with given size contains a figure.
Attributes
Frame figures.
Frame index.
- figure_type¶
alias of
supervisely.pointcloud_annotation.pointcloud_figure.PointcloudFigure
-
classmethod from_json(data, objects, frames_count=
None
, key_id_map=None
)[source]¶ Convert a json dict to PointcloudEpisodeFrame. Read more about Supervisely format.
- Parameters
- data : dict
Dict in json format.
- objects : PointcloudObjectCollection
PointcloudObjectCollection object.
- frames_count : int, optional
Number of frames in point cloud.
- key_id_map : KeyIdMap, optional
KeyIdMap object.
- Raises
ValueError
if frame index < 0 and if frame index > number of frames in point cloud- Returns
PointcloudEpisodeFrame object
- Return type
- Usage example
import supervisely as sly from supervisely.geometry.cuboid_3d import Cuboid3d, Vector3d from supervisely.pointcloud_annotation.pointcloud_object_collection import PointcloudObjectCollection obj_class_car = sly.ObjClass('car', Cuboid3d) pointcloud_obj_car = sly.PointcloudObject(obj_class_car) objects = PointcloudObjectCollection([pointcloud_obj_car]) frame_index = 7 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) figure = sly.PointcloudFigure(pointcloud_obj_car, cuboid, frame_index=frame_index) frame = sly.PointcloudEpisodeFrame(frame_index, figures=[figure]) frame_json = frame.to_json() frame_from_json = sly.PointcloudEpisodeFrame.from_json(frame_json, objects)
- key()¶
Get Frame key (index) value.
- Returns
Frame key (index) value
- Return type
- Usage example
import supervisely as sly frame_index = 7 geometry = sly.Rectangle(0, 0, 100, 100) class_car = sly.ObjClass('car', sly.Rectangle) object_car = sly.VideoObject(class_car) figure_car = sly.VideoFigure(object_car, geometry, frame_index) frame = sly.Frame(frame_index, figures=[figure_car]) print(frame.key()) # Output: 7
-
to_json(key_id_map=
None
)¶ Convert the Frame 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
- Usage example
import supervisely as sly frame_index = 7 geometry = sly.Rectangle(0, 0, 100, 100) class_car = sly.ObjClass('car', sly.Rectangle) object_car = sly.VideoObject(class_car) figure_car = sly.VideoFigure(object_car, geometry, frame_index) frame = sly.Frame(frame_index, figures=[figure_car]) frame_json = frame.to_json() print(frame_json) # Output: { # "index": 7, # "figures": [ # { # "key": "39f3eb15791f4c72b7cdb98c17b3f0f1", # "objectKey": "319814af474941a98ca208c3fad5ed81", # "geometryType": "rectangle", # "geometry": { # "points": { # "exterior": [ # [ # 0, # 0 # ], # [ # 100, # 100 # ] # ], # "interior": [] # } # } # } # ] # }
-
validate_figures_bounds(img_size=
None
)¶ Checks if image with given size contains a figure.
- Parameters
- Raises
OutOfImageBoundsException
, if figure is out of image bounds- Returns
None
- Return type
NoneType
- Usage Example
import supervisely as sly frame_index = 7 geometry = sly.Rectangle(0, 0, 100, 100) class_car = sly.ObjClass('car', sly.Rectangle) object_car = sly.VideoObject(class_car) figure_car = sly.VideoFigure(object_car, geometry, frame_index) frame = sly.Frame(frame_index, figures=[figure_car]) image_size = (20, 200) frame.validate_figures_bounds(image_size) # raise OutOfImageBoundsException("Figure is out of image bounds")
- property figures¶
Frame figures.
- Returns
List of figures on Frame.
- Return type
- Usage example
frame_figures = frame.figures