Skip to content

Commit

Permalink
[DAR-991][Internal] Add support of hidden_areas to darwin py importer (
Browse files Browse the repository at this point in the history
  • Loading branch information
AndriiKlymchuk committed Mar 4, 2024
1 parent 50e1c4c commit 82bfdba
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 0 deletions.
7 changes: 7 additions & 0 deletions darwin/datatypes.py
Expand Up @@ -53,6 +53,7 @@ class Success(Enum):
EllipseData = Dict[str, Union[float, Point]]
CuboidData = Dict[str, Dict[str, float]]
Segment = List[int]
HiddenArea = List[int]

DarwinVersionNumber = Tuple[int, int, int]

Expand Down Expand Up @@ -276,6 +277,9 @@ class VideoAnnotation:
# Properties of this annotation.
properties: Optional[list[SelectedProperty]] = None

#: A list of ``HiddenArea``\'s.
hidden_areas: List[HiddenArea] = field(default_factory=list)

def get_data(
self,
only_keyframes: bool = True,
Expand Down Expand Up @@ -334,6 +338,7 @@ def post_processing(
},
"segments": self.segments,
"interpolated": self.interpolated,
"hidden_areas": self.hidden_areas,
}

return output
Expand Down Expand Up @@ -1283,6 +1288,7 @@ def make_video_annotation(
interpolated: bool,
slot_names: List[str],
properties: Optional[list[SelectedProperty]] = None,
hidden_areas: Optional[List[HiddenArea]] = None,
) -> VideoAnnotation:
"""
Creates and returns a ``VideoAnnotation``.
Expand Down Expand Up @@ -1320,6 +1326,7 @@ def make_video_annotation(
interpolated,
slot_names=slot_names or [],
properties=properties,
hidden_areas=hidden_areas or [],
)


Expand Down
1 change: 1 addition & 0 deletions darwin/utils/utils.py
Expand Up @@ -909,6 +909,7 @@ def _parse_darwin_video_annotation(annotation: dict) -> Optional[dt.VideoAnnotat
annotation.get("interpolated", False),
slot_names=parse_slot_names(annotation),
properties=_parse_properties(annotation.get("properties", [])),
hidden_areas=annotation.get("hidden_areas", []),
)

if "id" in annotation:
Expand Down
1 change: 1 addition & 0 deletions tests/darwin/dataset/remote_dataset_test.py
Expand Up @@ -105,6 +105,7 @@ def annotation_content() -> Dict[str, Any]:
"name": "test_class",
"slot_names": ["0"],
"ranges": [[0, 3]],
"hidden_areas": [[1, 2]],
"id": "test_id",
"frames": {
"0": {
Expand Down
7 changes: 7 additions & 0 deletions tests/darwin/utils_test.py
Expand Up @@ -221,6 +221,12 @@ def test_parses_darwin_videos_correctly(self, tmp_path):
3,
46
]
],
"hidden_areas": [
[
5,
8
]
]
}
]
Expand Down Expand Up @@ -294,6 +300,7 @@ def test_parses_darwin_videos_correctly(self, tmp_path):
},
keyframes={3: True},
segments=[[3, 46]],
hidden_areas=[[5, 8]],
interpolated=True,
)
]
Expand Down

0 comments on commit 82bfdba

Please sign in to comment.