diff --git a/CHANGELOG.md b/CHANGELOG.md index f1b2c03a858d..175ea3083670 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Fixed label editor name field validator () - An error about track shapes outside of the task frames during export () - Fixed project search field updating () +- Fixed export error when invalid polygons are present in overlapping frames () ### Security diff --git a/cvat/apps/dataset_manager/annotation.py b/cvat/apps/dataset_manager/annotation.py index f10c3af587e1..391b26bf588b 100644 --- a/cvat/apps/dataset_manager/annotation.py +++ b/cvat/apps/dataset_manager/annotation.py @@ -315,11 +315,14 @@ def _get_cost_threshold(): @staticmethod def _calc_objects_similarity(obj0, obj1, start_frame, overlap): def _calc_polygons_similarity(p0, p1): - overlap_area = p0.intersection(p1).area - if p0.area == 0 or p1.area == 0: # a line with many points - return 0 + if p0.is_valid and p1.is_valid: # check validity of polygons + overlap_area = p0.intersection(p1).area + if p0.area == 0 or p1.area == 0: # a line with many points + return 0 + else: + return overlap_area / (p0.area + p1.area - overlap_area) else: - return overlap_area / (p0.area + p1.area - overlap_area) + return 0 # if there's invalid polygon, assume similarity is 0 has_same_type = obj0["type"] == obj1["type"] has_same_label = obj0.get("label_id") == obj1.get("label_id")