Skip to main content
Version: 0.1.x

compare_anno_marks

FunctionSource

flag: bool = compare_anno_marks(
anno_item_1: AnnoItem | AnnoMark,
anno_item_2: AnnoItem | AnnoMark,
tolearance: float = 0.1,
)

Compare whether two annotation marks are equivalent or not.

The comparison is only performed on the positions. The ID and the comment of the annotation items will not be compared.

Aliases​

This function can be acquired by

import dash_picture_annotation as dpa


dpa.compare_anno_marks
dpa.utilities.compare_anno_marks

Arguments​

Requires​

ArgumentTypeRequired
Description

anno_item_1

anno_item_2

AnnoItem | AnnoMarkThe annotation items to be compared.
tolearancefloatThe tolerance used for checking whether positions are the same or not.

Returns​

ArgumentType
Description
flagbool

A flag. Returns True if the two items are in the same position and share the same size.

Will return False if any of them is not an annotation item or mark.

Examples​

Compare positional information​

compare_anno_item_position.py
import pprint
import dash_picture_annotation as dpa


mark = lambda pos: {"x": pos, "y": 0, "width": 0, "height": pos, "type": "RECT"}
mark_eq = lambda pos: {"x": pos, "y": pos, "width": 0, "height": -pos, "type": "RECT"}

pprint.pprint(dpa.compare_anno_marks(mark(17.7), mark(17.7)))
pprint.pprint(dpa.compare_anno_marks(mark(17.7), mark(17.8)))
pprint.pprint(dpa.compare_anno_marks(mark(17.7), mark_eq(17.7)))
pprint.pprint(dpa.compare_anno_marks({"id": mark(17.7)}, mark(17.7)))