VolumeObject¶
- class VolumeObject[source]¶
Bases:
supervisely.video_annotation.video_object.VideoObject
VolumeObject object for
VolumeAnnotation
.VolumeObject
object is immutable.- Parameters
- obj_class : ObjClass
VolumeObject
class
.- tags : VolumeTagCollection, optional
VolumeObject
tags
.- key : UUID, optional
The UUID key associated with the VolumeFigure.
- class_id : int, optional
ID of
ObjClass
to which VolumeObject belongs.- labeler_login : str, optional
Login of the user who created VolumeObject.
- updated_at : str, optional
Date and Time when VolumeObject 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 VolumeObject was created. Date Format is the same as in “updated_at” parameter.
- mask_3d : Union[str, ndarray, Mask3D], optional
Path for local geometry file, array with geometry data or Mask3D geometry object
- Usage example
import supervisely as sly obj_class_heart = sly.ObjClass('heart', sly.Rectangle) volume_obj_heart = sly.VolumeObject(obj_class_heart) volume_obj_heart_json = volume_obj_heart.to_json() print(volume_obj_heart_json) # Output: { # "key": "6b819f1840f84d669b32cdec225385f0", # "classTitle": "heart", # "tags": [] # }
Methods
Adds VideoTag to the current VideoObject.
Adds VideoTags to the current VideoObject.
Makes a copy of VideoObject with new fields, if fields are given, otherwise it will use fields of the original VideoObject.
Convert a json dict to VideoObject.
Object key.
Convert the VideoObject to a json dict.
Attributes
Object class ID.
ObjClass of the current VideoObject.
VideoTagCollection of the current VideoObject.
- 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
)¶ Convert a json dict to VideoObject. Read more about Supervisely format.
- Parameters
- data : dict
Dict in json format.
- project_meta : ProjectMeta
Input
ProjectMeta
.- key_id_map : KeyIdMap, optional
KeyIdMap object.
- Raises
RuntimeError
, if object class name is not found in the given project meta- Returns
VideoObject object
- Return type
VideoObject
- Usage example
import supervisely as sly obj_car_json = { "classTitle": "vehicle", "tags": [] } obj_class_car = sly.ObjClass('vehicle', sly.Rectangle) obj_collection = sly.ObjClassCollection([obj_class_car]) meta = sly.ProjectMeta(obj_classes=obj_collection) video_obj_from_json = sly.VideoObject.from_json(obj_car_json, meta)
- key()¶
Object key.
- Returns
Object key
- Return type
- 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
- 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
- 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
- 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
- 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" # } # ]