get_all_comments
函数源码
comments: {str} = get_all_comments(data: Annotations | [AnnoItem])
获得一组标记数据中的全部文字标注集合。返回的文字标注未排序。
别名
该函数可以按以下方式之一获取
import dash_picture_annotation as dpa
dpa.get_all_comments
dpa.utilities.get_all_comments
参数
输入
| 参数 | 类型 | 必选 | |
|---|---|---|---|
data | Annotations | [AnnoItem] | 要检索的标记数据。 | 
输出
| 参数 | 类型 | |
|---|---|---|
comments | {str} | 在所检查的标记数据中,由所有出现过的文字标注构成的未排序集合。若数据不包含任何文字标注,返回空集。 | 
范例
获得数据中的所有文字标注
- 代码
 - 结果
 
get_comments_from_anno.py
import pprint
import dash_picture_annotation as dpa
mark = lambda pos: {"x": pos, "y": pos, "width": 0, "height": 0, "type": "RECT"}
data = [
    {"id": "a", "mark": mark(0)},
    {"id": "b", "mark": mark(1)},
    {"id": "c", "mark": mark(2), "comment": "type-1"},
    {"id": "d", "mark": mark(3), "comment": "type-2"},
    {"id": "d", "mark": mark(4), "comment": "type-2"},
]
data_wrapped = {"timestamp": 0, "data": data}
pprint.pprint(dpa.get_all_comments(data))
pprint.pprint(dpa.get_all_comments(data_wrapped))
frozenset({'type-1', 'type-2'})
frozenset({'type-1', 'type-2'})