VideoObject¶
-
class VideoObject(obj_class, tags=
None, key=None, class_id=None, labeler_login=None, updated_at=None, created_at=None)[source]¶ Bases:
KeyObjectTracked object across video frames; obj_class plus optional tags. Immutable.
- Parameters:
- obj_class¶
Object class (e.g. ‘car’ with Rectangle geometry).
Tags for this object.
- key : uuid.UUID, optional¶
UUID key. Auto-generated if not provided.
- class_id : int, optional¶
Server-side class ID.
- labeler_login : str, optional¶
Login of user who created the object.
- updated_at : str, optional¶
Last modification timestamp.
- created_at : str, optional¶
Creation timestamp.
- Usage Example:
import supervisely as sly obj_class_car = sly.ObjClass('car', sly.Rectangle) video_obj_car = sly.VideoObject(obj_class_car) video_obj_car_json = video_obj_car.to_json() print(video_obj_car_json)
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.
-
classmethod from_json(data, project_meta, key_id_map=
None)[source]¶ Convert a json dict to VideoObject. Read more about Supervisely format.
- Parameters:
- Raises:
RuntimeError – if object class name is not found in the given project meta
- Returns:
VideoObject object
- Return type:
- 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)
- add_tag(tag)[source]¶
Adds VideoTag to the current VideoObject.
- Parameters:
- tag¶
VideoTag to be added.
- Returns:
VideoObject object
- Return type:
- 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)[source]¶
Adds VideoTags to the current VideoObject.
- Parameters:
- tag : List[
VideoTag] List of VideoTags to be added.
- tag : List[
- Returns:
VideoObject object
- Return type:
- 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)[source]¶ Makes a copy of VideoObject with new fields, if fields are given, otherwise it will use fields of the original VideoObject.
- Parameters:
- obj_class=
None¶ ObjClass object.
VideoTagCollection object.
- key : uuid.UUID, optional¶
UUID key associated with the 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.
- obj_class=
- Returns:
VideoObject object
- Return type:
- Usage Example:
import supervisely as sly from supervisely.video_annotation.video_tag import VideoTag from supervisely.video_annotation.video_tag_collection import VideoTagCollection 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 meta_car = sly.TagMeta('car_tag', sly.TagValueType.ANY_STRING) car_tag = VideoTag(meta_car, value='acura') 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" # } # ] # }
-
to_json(key_id_map=
None)[source]¶ Convert the VideoObject to a json dict. Read more about Supervisely format.
- Parameters:
- key_id_map=
None¶ KeyIdMap object.
- key_id_map=
- 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 : int¶
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 : supervisely.annotation.obj_class.ObjClass¶
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 : supervisely.video_annotation.video_tag_collection.VideoTagCollection¶
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" # } # ]