Source code for iaa_od.utils.find_contained

from copy import deepcopy

[docs] def find_all_contained_bboxes(annotation, all_annotations: list, iom_thr: float) -> list: """ Returns a list of all annotations which are considered "contained" within the provided annotation, based on an IoM threshold. Parameters: annotation (AnnotationProtocol): The annotation to check containment against. all_annotations (list[AnnotationProtocol]): A list of all annotations to check for containment. iom_thr (float): The IoM threshold to consider an annotation as "contained" within the provided annotation. Returns: list[AnnotationProtocol]: A list of annotations that are considered "contained" within the provided annotation. """ from iaa_od.metrics.iou import iom contained_bboxes: list = [] for other_ann in all_annotations: if annotation.gt_name == other_ann.gt_name: continue if iom(annotation, other_ann) >= iom_thr: other_ann_copy = deepcopy(other_ann) contained_bboxes.append(other_ann_copy) return contained_bboxes