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_figure

Add UUID and ID of VideoFigure in KeyIdMap.

add_figure_to

Add VideoFigure type of instance with given key and id to KeyIdMap object.

add_figures_to

Add VideoFigure type of instances with given values(keys, ids) to KeyIdMap object.

add_object

Add UUID and ID of VideoObject in KeyIdMap.

add_object_to

Add VideoObject type of instance with given key and id to KeyIdMap object.

add_objects_to

Add VideoObject type of instances with given values(keys, ids) to KeyIdMap object.

add_tag

Add UUID and ID of VideoTag in KeyIdMap.

add_tag_to

Add VideoTag type of instance with given key and id to KeyIdMap object.

add_tags_to

Add VideoTag type of instances with given values(keys, ids) to KeyIdMap object.

add_video

Add UUID and ID of VideoAnnotation in KeyIdMap.

add_video_to

Add VideoAnnotation type of instance with given key and id to KeyIdMap object.

add_videos_to

Add VideoAnnotation type of instances with given values(keys, ids) to KeyIdMap object.

dump_json

Write KeyIdMap to file with given path.

from_dict

Convert dict(bidict values to dictionary with dict values) into KeyIdMap.

get_figure_id

Get VideoFigure ID.

get_figure_key

Get VideoFigure UUID key.

get_object_id

Get VideoObject ID.

get_object_key

Get VideoObject UUID key.

get_tag_id

Get VideoTag ID.

get_tag_key

Get VideoTag UUID key.

get_video_id

Get VideoAnnotation ID.

get_video_key

Get VideoAnnotation UUID key.

load_json

Decoding data from json file with given filename to KeyIdMap.

remove_figure

Remove VideoFigure with given UUID from KeyIdMap.

remove_figure_from

Remove VideoFigure type of instance with given key from KeyIdMap object.

remove_figures_from

Remove VideoFigure type of instances with given keys or ids from KeyIdMap object.

remove_object

Remove VideoObject with given UUID from KeyIdMap.

remove_object_from

Remove VideoObject type of instance with given key from KeyIdMap object.

remove_objects_from

Remove VideoObject type of instances with given keys or ids from KeyIdMap object.

remove_tag

Remove VideoTag with given UUID from KeyIdMap.

remove_tag_from

Remove VideoTag type of instance with given key from KeyIdMap object.

remove_tags_from

Remove VideoTag type of instances with given keys or ids from KeyIdMap object.

remove_video

Remove Video with given UUID from KeyIdMap.

remove_video_from

Remove Video type of instance with given key from KeyIdMap object.

remove_videos_from

Remove Video type of instances with given keys or ids from KeyIdMap object.

to_dict

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
key : UUID

UUID object.

id : int

VideoTag ID.

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.

Parameters
key_id_map : KeyIdMap

KeyIdMap object.

key : UUID

UUID object.

id : int

VideoTag ID.

Returns

None

Return type

NoneType

Usage example
key_id_map = KeyIdMap()
new_uuid = uuid.uuid4()
new_tag_id = 1213
KeyIdMap.add_tag_to(key_id_map, new_uuid, new_tag_id)
classmethod add_tags_to(key_id_map, keys, ids)[source]

Add VideoTag 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 VideoTag IDs.

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

KeyIdMap

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

int

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

int

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_tag_id(key)[source]

Get VideoTag ID.

Parameters
key : UUID

UUID object.

Returns

VideoTag ID

Return type

int

Usage example
tag_uuid = '697d005df2a94bb386188c78a61b0a86'
tag_id = key_id_map.get_tag_id(tag_uuid) # 34
get_tag_key(id)[source]

Get VideoTag UUID 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 VideoAnnotation ID.

Parameters
key : UUID

UUID object.

Returns

VideoAnnotation ID

Return type

int

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'
classmethod load_json(path)[source]

Decoding data from json file with given filename to KeyIdMap.

Parameters
path : str

Target file path.

Returns

KeyIdMap object

Return type

KeyIdMap

Usage example
new_key_id = KeyIdMap.load_json('/home/admin/work/projects/key_id.json')
remove_figure(key=None, id=None)[source]

Remove VideoFigure with given UUID from 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)
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 VideoFigure type of instance with given key from 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()
KeyIdMap.remove_figure_from(key_id_map, new_uuid)
classmethod remove_figures_from(key_id_map, keys=None, ids=None)[source]

Remove VideoFigure type 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 VideoFigure IDs.

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 VideoObject with given UUID from 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)
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 VideoObject type of instance with given key from 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()
KeyIdMap.remove_object_from(key_id_map, new_uuid)
classmethod remove_objects_from(key_id_map, keys=None, ids=None)[source]

Remove VideoObject type 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 VideoObject IDs.

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 VideoTag with given UUID from KeyIdMap.

Parameters
key : UUID

UUID object.

id : int

VideoTag ID.

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 VideoTag type of instance with given key from KeyIdMap object.

Parameters
key_id_map : KeyIdMap

KeyIdMap object.

key : UUID

UUID object.

id : int

VideoTag ID.

Returns

None

Return type

NoneType

Usage example
key_id_map = KeyIdMap()
new_uuid = uuid.uuid4()
KeyIdMap.remove_tag_from(key_id_map, new_uuid)
classmethod remove_tags_from(key_id_map, keys=None, ids=None)[source]

Remove VideoTag type 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 VideoTag IDs.

Returns

None

Return type

NoneType

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])
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.

Parameters
key_id_map : KeyIdMap

KeyIdMap object.

key : UUID

UUID object.

id : int

Video ID.

Returns

None

Return type

NoneType

Usage example
key_id_map = KeyIdMap()
new_uuid = uuid.uuid4()
KeyIdMap.remove_video_from(key_id_map, new_uuid)
classmethod remove_videos_from(key_id_map, keys=None, ids=None)[source]

Remove Video type 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 Video IDs.

Returns

None

Return type

NoneType

Usage example
key_id_map = KeyIdMap()
uuid_1 = uuid.uuid4()
uuid_2 = uuid.uuid4()
KeyIdMap.remove_videos_from(key_id_map, [uuid_1, uuid_2])
to_dict()[source]

Convert the KeyIdMap to a dict(bidict values to dictionary with dict values).

Returns

Json format as a dict

Return type

dict

Usage example
key_id_map = KeyIdMap()
print(key_id_map.to_dict())
# Output: {
#     "tags": {},
#     "objects": {},
#     "figures": {},
#     "videos": {}
# }