KeyIdMap¶
- class KeyIdMap[source]¶
Bases:
objectBidirectional mapping between UUID keys and integer IDs for video annotations.
Used to keep stable references between objects/figures/tags (UUID keys) and server-side IDs during JSON (de)serialization and API interactions.
KeyIdMap object for
VideoAnnotation. It consist from dict with bidict values.- Usage Example:
key_id_map = KeyIdMap() print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": {} # }
Methods
Add UUID and ID of
VideoFigurein KeyIdMap.Add
VideoFiguretype of instance with given key and id to KeyIdMap object.Add
VideoFiguretype of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoObjectin KeyIdMap.Add
VideoObjecttype of instance with given key and id to KeyIdMap object.Add
VideoObjecttype of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoTagin KeyIdMap.Add
VideoTagtype of instance with given key and id to KeyIdMap object.Add
VideoTagtype of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoAnnotationin KeyIdMap.Add
VideoAnnotationtype of instance with given key and id to KeyIdMap object.Add
VideoAnnotationtype of instances with given values(keys, ids) to KeyIdMap object.Write KeyIdMap to file with given path.
Convert dict(bidict values to dictionary with dict values) into KeyIdMap.
Get
VideoFigureID.Get
VideoFigureUUID key.Get
VideoObjectID.Get
VideoObjectUUID key.Get
VideoTagID.Get
VideoTagUUID key.Get
VideoAnnotationID.Get
VideoAnnotationUUID key.Decoding data from json file with given filename to KeyIdMap.
Remove
VideoFigurewith given UUID from KeyIdMap.Remove
VideoFiguretype of instance with given key from KeyIdMap object.Remove
VideoFiguretype of instances with given keys or ids from KeyIdMap object.Remove
VideoObjectwith given UUID from KeyIdMap.Remove
VideoObjecttype of instance with given key from KeyIdMap object.Remove
VideoObjecttype of instances with given keys or ids from KeyIdMap object.Remove
VideoTagwith given UUID from KeyIdMap.Remove
VideoTagtype of instance with given key from KeyIdMap object.Remove
VideoTagtype of instances with given keys or ids from KeyIdMap object.Remove
VideoAnnotationby given UUID from KeyIdMap.Remove
VideoAnnotationtype of instance with given key from KeyIdMap object.Remove
VideoAnnotationtype of instances with given keys or ids from KeyIdMap object.Convert the KeyIdMap to a dict(bidict values to dictionary with dict values).
- classmethod add_figure_to(key_id_map, key, id)[source]¶
Add
VideoFiguretype of instance with given key and id to KeyIdMap object.
- classmethod add_figures_to(key_id_map, keys, ids)[source]¶
Add
VideoFiguretype of instances with given values(keys, ids) to KeyIdMap object.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() figure_id_1 = 23 uuid_2 = uuid.uuid4() figure_id_2 = 57 KeyIdMap.add_figures_to(key_id_map, [uuid_1, uuid_2], [figure_id_1, figure_id_2])
- classmethod add_object_to(key_id_map, key, id)[source]¶
Add
VideoObjecttype of instance with given key and id to KeyIdMap object.
- classmethod add_objects_to(key_id_map, keys, ids)[source]¶
Add
VideoObjecttype of instances with given values(keys, ids) to KeyIdMap object.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() object_id_1 = 23 uuid_2 = uuid.uuid4() object_id_2 = 57 KeyIdMap.add_objects_to(key_id_map, [uuid_1, uuid_2], [object_id_1, object_id_2])
- classmethod add_tag_to(key_id_map, key, id)[source]¶
Add
VideoTagtype of instance with given key and id to KeyIdMap object.
- classmethod add_tags_to(key_id_map, keys, ids)[source]¶
Add
VideoTagtype of instances with given values(keys, ids) to KeyIdMap object.- Parameters:
KeyIdMapobject.List of UUID objects.
List of VideoTag IDs.
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() tag_id_1 = 1213 uuid_2 = uuid.uuid4() tag_id_2 = 3686 KeyIdMap.add_tags_to(key_id_map, [uuid_1, uuid_2], [tag_id_1, tag_id_2])
- classmethod add_video_to(key_id_map, key, id)[source]¶
Add
VideoAnnotationtype of instance with given key and id to KeyIdMap object.
- classmethod add_videos_to(key_id_map, keys, ids)[source]¶
Add
VideoAnnotationtype of instances with given values(keys, ids) to KeyIdMap object.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() video_id_1 = 567 uuid_2 = uuid.uuid4() video_id_2 = 5200 KeyIdMap.add_videos_to(key_id_map, [uuid_1, uuid_2], [video_id_1, video_id_2])
- classmethod from_dict(dict)[source]¶
Convert dict(bidict values to dictionary with dict values) into KeyIdMap.
- Returns:
KeyIdMap object
- Return type:
- Usage Example:
dict = { "tags": {}, "objects": {}, "figures": {}, "videos": {} } key_id_map = KeyIdMap.from_dict(dict)
-
classmethod remove_figure_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoFiguretype of instance with given key from KeyIdMap object.
-
classmethod remove_figures_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoFiguretype of instances with given keys or ids from KeyIdMap object.
-
classmethod remove_object_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoObjecttype of instance with given key from KeyIdMap object.
-
classmethod remove_objects_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoObjecttype of instances with given keys or ids from KeyIdMap object.
-
classmethod remove_tag_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoTagtype of instance with given key from KeyIdMap object.
-
classmethod remove_tags_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoTagtype of instances with given keys or ids from KeyIdMap object.- Parameters:
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of VideoTag IDs.
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() uuid_2 = uuid.uuid4() KeyIdMap.remove_tags_from(key_id_map, [uuid_1, uuid_2])
-
classmethod remove_video_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoAnnotationtype of instance with given key from KeyIdMap object.
-
classmethod remove_videos_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoAnnotationtype of instances with given keys or ids from KeyIdMap object.
- add_figure(key, id)[source]¶
Add UUID and ID of
VideoFigurein KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "ac1018e6673d405590086063af8184ca" key_id_map.add_figure(new_uuid, 55) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": { # "ac1018e6673d405590086063af8184ca": 55 # }, # "videos": {} # }
- add_object(key, id)[source]¶
Add UUID and ID of
VideoObjectin KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "0c0033c5b4834d4cbabece4317295f07" key_id_map.add_object(new_uuid, 1) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": { # "0c0033c5b4834d4cbabece4317295f07": 1 # }, # "figures": {}, # "videos": {} # }
- add_tag(key, id)[source]¶
Add UUID and ID of
VideoTagin KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "697d005df2a94bb386188c78a61b0a86" key_id_map.add_tag(new_uuid, 34) print(key_id_map.to_dict()) # Output: { # "tags": { # "697d005df2a94bb386188c78a61b0a86": 34 # }, # "objects": {}, # "figures": {}, # "videos": {} # }
- add_video(key, id)[source]¶
Add UUID and ID of
VideoAnnotationin KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "775f2c581cec44ca8c10419c20c52fcc" key_id_map.add_video(new_uuid, 77) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": { # "775f2c581cec44ca8c10419c20c52fcc": 77 # } # }
- get_figure_id(key)[source]¶
Get
VideoFigureID.
- get_figure_key(id)[source]¶
Get
VideoFigureUUID key.- Parameters:
- key : int
VideoFigure ID.
- Returns:
UUID object
- Return type:
UUID
- Usage Example:
figure_id = 55 figure_uuid = key_id_map.get_figure_key(figure_id) # 'ac1018e6673d405590086063af8184ca'
- get_object_id(key)[source]¶
Get
VideoObjectID.
- get_object_key(id)[source]¶
Get
VideoObjectUUID key.- Parameters:
- key : int
VideoObject ID.
- Returns:
UUID object
- Return type:
UUID
- Usage Example:
obj_id = 1 obj_uuid = key_id_map.get_object_id(obj_id) # '0c0033c5b4834d4cbabece4317295f07'
- get_tag_key(id)[source]¶
Get
VideoTagUUID key.- Parameters:
- key : int
VideoTag ID.
- Returns:
UUID object
- Return type:
UUID
- Usage Example:
tag_id = 34 tag_uuid = key_id_map.get_tag_key(tag_id) # '697d005df2a94bb386188c78a61b0a86'
- get_video_id(key)[source]¶
Get
VideoAnnotationID.
- get_video_key(id)[source]¶
Get
VideoAnnotationUUID key.- Parameters:
- key : int
VideoAnnotation ID.
- Returns:
UUID object
- Return type:
UUID
- Usage Example:
video_id = 77 video_uuid = key_id_map.get_video_key(video_id) # '775f2c581cec44ca8c10419c20c52fcc'
-
remove_figure(key=
None, id=None)[source]¶ Remove
VideoFigurewith given UUID from KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "ac1018e6673d405590086063af8184ca" key_id_map.add_figure(new_uuid, 55) key_id_map.remove_figure(new_uuid) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": {} # }
-
remove_object(key=
None, id=None)[source]¶ Remove
VideoObjectwith given UUID from KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "0c0033c5b4834d4cbabece4317295f07" key_id_map.add_object(new_uuid, 1) key_id_map.remove_object(new_uuid) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": {} # }
-
remove_tag(key=
None, id=None)[source]¶ Remove
VideoTagwith given UUID from KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "697d005df2a94bb386188c78a61b0a86" key_id_map.add_tag(new_uuid, 34) key_id_map.remove_tag(new_uuid) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": {} # }
-
remove_video(key=
None, id=None)[source]¶ Remove
VideoAnnotationby given UUID from KeyIdMap.- Parameters:
- Returns:
None
- Return type:
None
- Usage Example:
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() # "775f2c581cec44ca8c10419c20c52fcc" key_id_map.add_video(new_uuid, 77) key_id_map.remove_video(new_uuid) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": {} # }