KeyIdMap¶
- class KeyIdMap[source]¶
Bases:
objectKeyIdMap 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 Video with given UUID from KeyIdMap.
Remove Video type of instance with given key from KeyIdMap object.
Remove Video type of instances with given keys or ids from KeyIdMap object.
Convert the KeyIdMap to a dict(bidict values to dictionary with dict values).
- add_figure(key, id)[source]¶
Add UUID and ID of
VideoFigurein KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoFigureID.
- Returns
None- Return type
NoneType- 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": {} # }
- classmethod add_figure_to(key_id_map, key, id)[source]¶
Add
VideoFiguretype of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoFigureID.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() new_figure_id = 3834 KeyIdMap.add_figure_to(key_id_map, new_uuid, new_figure_id)
- classmethod add_figures_to(key_id_map, keys, ids)[source]¶
Add
VideoFiguretype of instances with given values(keys, ids) to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of
VideoFigureIDs.
- Returns
None- Return type
NoneType- 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])
- add_object(key, id)[source]¶
Add UUID and ID of
VideoObjectin KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoObjectID.
- Returns
None- Return type
NoneType- 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": {} # }
- classmethod add_object_to(key_id_map, key, id)[source]¶
Add
VideoObjecttype of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoObjectID.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() new_object_id = 76 KeyIdMap.add_object_to(key_id_map, new_uuid, new_object_id)
- classmethod add_objects_to(key_id_map, keys, ids)[source]¶
Add
VideoObjecttype of instances with given values(keys, ids) to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of
VideoObjectIDs.
- Returns
None- Return type
NoneType- 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])
- add_tag(key, id)[source]¶
Add UUID and ID of
VideoTagin KeyIdMap.- Parameters
- Returns
None- Return type
NoneType- 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": {} # }
- 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
- Returns
None- Return type
NoneType- 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])
- add_video(key, id)[source]¶
Add UUID and ID of
VideoAnnotationin KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoAnnotationID.
- Returns
None- Return type
NoneType- 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 # } # }
- classmethod add_video_to(key_id_map, key, id)[source]¶
Add
VideoAnnotationtype of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoAnnotationID.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() new_video_id = 3834 KeyIdMap.add_video_to(key_id_map, new_uuid, new_video_id)
- classmethod add_videos_to(key_id_map, keys, ids)[source]¶
Add
VideoAnnotationtype of instances with given values(keys, ids) to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of
VideoAnnotationIDs.
- Returns
None- Return type
NoneType- 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])
- dump_json(path)[source]¶
Write KeyIdMap to file with given path.
- Parameters
- path : str
Target file path.
- Returns
None- Return type
NoneType- Usage example
key_id_map.dump_json('/home/admin/work/projects/key_id.json')
- 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)
- get_figure_id(key)[source]¶
Get
VideoFigureID.- Parameters
- key : UUID
UUID object.
- Returns
VideoFigureID- Return type
- Usage example
figure_uuid = 'ac1018e6673d405590086063af8184ca' figure_id = key_id_map.get_figure_id(figure_uuid) # 55
- get_figure_key(id)[source]¶
Get
VideoFigureUUID key.- Parameters
- key : int
VideoFigureID.
- Returns
UUIDobject- 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.- Parameters
- key : UUID
UUID object.
- Returns
VideoObjectID- Return type
- Usage example
obj_uuid = '0c0033c5b4834d4cbabece4317295f07' obj_id = key_id_map.get_object_id(obj_uuid) # 1
- get_object_key(id)[source]¶
Get
VideoObjectUUID key.- Parameters
- key : int
VideoObjectID.
- Returns
UUIDobject- Return type
UUID- Usage example
obj_id = 1 obj_uuid = key_id_map.get_object_id(obj_id) # '0c0033c5b4834d4cbabece4317295f07'
- get_video_id(key)[source]¶
Get
VideoAnnotationID.- Parameters
- key : UUID
UUID object.
- Returns
- Return type
- Usage example
video_uuid = '775f2c581cec44ca8c10419c20c52fcc' video_id = key_id_map.get_video_id(video_uuid) # 77
- get_video_key(id)[source]¶
Get
VideoAnnotationUUID key.- Parameters
- key : int
VideoAnnotationID.
- Returns
UUIDobject- 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
- key : UUID
UUID object.
- id : int
VideoFigureID.
- Returns
None- Return type
NoneType- 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": {} # }
-
classmethod remove_figure_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoFiguretype of instance with given key from KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoFigureID.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() KeyIdMap.remove_figure_from(key_id_map, new_uuid)
-
classmethod remove_figures_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoFiguretype of instances with given keys or ids from KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of
VideoFigureIDs.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() uuid_2 = uuid.uuid4() KeyIdMap.remove_figures_from(key_id_map, [uuid_1, uuid_2])
-
remove_object(key=
None, id=None)[source]¶ Remove
VideoObjectwith given UUID from KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoObjectID.
- Returns
None- Return type
NoneType- 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": {} # }
-
classmethod remove_object_from(key_id_map, key=
None, id=None)[source]¶ Remove
VideoObjecttype of instance with given key from KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoObjectID.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() new_uuid = uuid.uuid4() KeyIdMap.remove_object_from(key_id_map, new_uuid)
-
classmethod remove_objects_from(key_id_map, keys=
None, ids=None)[source]¶ Remove
VideoObjecttype of instances with given keys or ids from KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : List[UUID]
List of UUID objects.
- id : List[int]
List of
VideoObjectIDs.
- Returns
None- Return type
NoneType- Usage example
key_id_map = KeyIdMap() uuid_1 = uuid.uuid4() uuid_2 = uuid.uuid4() KeyIdMap.remove_objects_from(key_id_map, [uuid_1, uuid_2])
-
remove_tag(key=
None, id=None)[source]¶ Remove
VideoTagwith given UUID from KeyIdMap.- Parameters
- Returns
None- Return type
NoneType- 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": {} # }
-
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.
-
remove_video(key=
None, id=None)[source]¶ Remove Video with given UUID from KeyIdMap.
- Parameters
- key : UUID
UUID object.
- id : int
Video ID
- Returns
None- Return type
NoneType- 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": {} # }
-
classmethod remove_video_from(key_id_map, key=
None, id=None)[source]¶ Remove Video type of instance with given key from KeyIdMap object.