get_all_ids
函数源码
ids: [str] = get_all_ids(data: Annotations | [AnnoItem])
获得一组标记数据 中、由所有标记数据ID构成的列表。所返回的ID按照原标记数据data
中各项的顺序排序。
别名
该函数可以按以下方式之一获取
import dash_picture_annotation as dpa
dpa.get_all_ids
dpa.utilities.get_all_ids
参数
输入
参数 | 类型 | 必选 | |
---|---|---|---|
data | Annotations | [AnnoItem] | 要检索的标记数据。 |
输出
参数 | 类型 | |
---|---|---|
ids | [str] | 已排序的、标记数据的、各项ID。 |
范例
获取数据中的所有ID
- 代码
- 结果
get_all_ids.py
import pprint
import dash_picture_annotation as dpa
data = [
{"id": "a", "mark": {"x": 0, "y": 0, "width": 0, "height": 0, "type": "RECT"}},
{"id": "b", "mark": {"x": 0, "y": 0, "width": 0, "height": 0, "type": "RECT"}},
{"mark": {"x": 0, "y": 0, "width": 0, "height": 0, "type": "RECT"}},
{"id": "c", "mark": {"x": 0, "y": 0, "width": 0, "height": 0, "type": "RECT"}},
{"id": "c", "mark": {"x": 1, "y": 1, "width": 0, "height": 0, "type": "RECT"}},
]
data_wrapped = {"timestamp": 0, "data": data}
pprint.pprint(dpa.get_all_ids(data))
pprint.pprint(dpa.get_all_ids(data_wrapped))
('a', 'b', 'c', 'c')
('a', 'b', 'c', 'c')