KeyIdMap¶
- class KeyIdMap[source]¶
Bases:
object
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
VideoFigure
in KeyIdMap.Add
VideoFigure
type of instance with given key and id to KeyIdMap object.Add
VideoFigure
type of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoObject
in KeyIdMap.Add
VideoObject
type of instance with given key and id to KeyIdMap object.Add
VideoObject
type of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoTag
in KeyIdMap.Add
VideoTag
type of instance with given key and id to KeyIdMap object.Add
VideoTag
type of instances with given values(keys, ids) to KeyIdMap object.Add UUID and ID of
VideoAnnotation
in KeyIdMap.Add
VideoAnnotation
type of instance with given key and id to KeyIdMap object.Add
VideoAnnotation
type 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
VideoFigure
ID.Get
VideoFigure
UUID key.Get
VideoObject
ID.Get
VideoObject
UUID key.Get
VideoTag
ID.Get
VideoTag
UUID key.Get
VideoAnnotation
ID.Get
VideoAnnotation
UUID key.Decoding data from json file with given filename to KeyIdMap.
Convert the KeyIdMap to a dict(bidict values to dictionary with dict values).
- add_figure(key, id)[source]¶
Add UUID and ID of
VideoFigure
in KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoFigure
ID.
- 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
VideoFigure
type of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoFigure
ID.
- 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
VideoFigure
type 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
VideoFigure
IDs.
- 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
VideoObject
in KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoObject
ID.
- 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
VideoObject
type of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoObject
ID.
- 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
VideoObject
type 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
VideoObject
IDs.
- 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
VideoTag
in 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
VideoTag
type of instance with given key and id to KeyIdMap object.
- classmethod add_tags_to(key_id_map, keys, ids)[source]¶
Add
VideoTag
type 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
VideoAnnotation
in KeyIdMap.- Parameters
- key : UUID
UUID object.
- id : int
VideoAnnotation
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) print(key_id_map.to_dict()) # Output: { # "tags": {}, # "objects": {}, # "figures": {}, # "videos": { # "775f2c581cec44ca8c10419c20c52fcc": 77 # } # }
- classmethod add_video_to(key_id_map, key, id)[source]¶
Add
VideoAnnotation
type of instance with given key and id to KeyIdMap object.- Parameters
- key_id_map : KeyIdMap
KeyIdMap object.
- key : UUID
UUID object.
- id : int
VideoAnnotation
ID.
- 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
VideoAnnotation
type 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
VideoAnnotation
IDs.
- 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
VideoFigure
ID.- Parameters
- key : UUID
UUID object.
- Returns
VideoFigure
ID- Return type
- Usage example
figure_uuid = 'ac1018e6673d405590086063af8184ca' figure_id = key_id_map.get_figure_id(figure_uuid) # 55
- get_figure_key(id)[source]¶
Get
VideoFigure
UUID 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
VideoObject
ID.- Parameters
- key : UUID
UUID object.
- Returns
VideoObject
ID- Return type
- Usage example
obj_uuid = '0c0033c5b4834d4cbabece4317295f07' obj_id = key_id_map.get_object_id(obj_uuid) # 1
- get_object_key(id)[source]¶
Get
VideoObject
UUID 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_video_id(key)[source]¶
Get
VideoAnnotation
ID.- 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
VideoAnnotation
UUID 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'