Skip to content

Commit

Permalink
fixed darwin v1 annotation loading bug (ignored bboxes when loading p…
Browse files Browse the repository at this point in the history
…olygons)
  • Loading branch information
ChristofferEdlund committed Oct 12, 2023
1 parent cae83ff commit 017b1c0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions darwin/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,8 @@ def _parse_darwin_annotation(annotation: Dict[str, Any]) -> Optional[dt.Annotati
# Darwin JSON 1.0 representation of complex and simple polygons
elif "polygon" in annotation:
bounding_box = annotation.get("bounding_box")
if bounding_box is None:
bounding_box = annotation["polygon"].get("bounding_box")
if "additional_paths" in annotation["polygon"]:
paths = [annotation["polygon"]["path"]] + annotation["polygon"]["additional_paths"]
main_annotation = dt.make_complex_polygon(name, paths, bounding_box, slot_names=slot_names)
Expand All @@ -624,6 +626,8 @@ def _parse_darwin_annotation(annotation: Dict[str, Any]) -> Optional[dt.Annotati
# Darwin JSON 1.0 representation of complex polygons
elif "complex_polygon" in annotation:
bounding_box = annotation.get("bounding_box")
if bounding_box is None:
bounding_box = annotation["polygon"].get("bounding_box")
if isinstance(annotation["complex_polygon"]["path"][0], list):
paths = annotation["complex_polygon"]["path"]
else:
Expand Down

0 comments on commit 017b1c0

Please sign in to comment.