Skip to content

Commit

Permalink
Fix KITTI-3D importer and exporter (#1596)
Browse files Browse the repository at this point in the history
<!-- Contributing guide:
https://github.com/openvinotoolkit/datumaro/blob/develop/CONTRIBUTING.md
-->

### Summary

- Fix for #1578

### How to test
<!-- Describe the testing procedure for reviewers, if changes are
not fully covered by unit tests or manual testing can be complicated.
-->

### Checklist
<!-- Put an 'x' in all the boxes that apply -->
- [ ] I have added unit tests to cover my changes.​
- [ ] I have added integration tests to cover my changes.​
- [x] I have added the description of my changes into
[CHANGELOG](https://github.com/openvinotoolkit/datumaro/blob/develop/CHANGELOG.md).​
- [ ] I have updated the
[documentation](https://github.com/openvinotoolkit/datumaro/tree/develop/docs)
accordingly

### License

- [ ] I submit _my code changes_ under the same [MIT
License](https://github.com/openvinotoolkit/datumaro/blob/develop/LICENSE)
that covers the project.
  Feel free to contact the maintainers if that's a concern.
- [ ] I have updated the license header for each file (see an example
below).

```python
# Copyright (C) 2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
```
  • Loading branch information
wonjuleee authored Sep 2, 2024
1 parent 0cbcd58 commit 51c316a
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 20 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Enhancements
- Change _Shape to Shape and add comments for subclasses of Shape
(<https://github.com/openvinotoolkit/datumaro/pull/1568>)
- Fix `kitti_raw` importer and exporter for dimensions (height, width, length) in meters
(<https://github.com/openvinotoolkit/datumaro/pull/1596>)

### Bug fixes

Expand Down
4 changes: 2 additions & 2 deletions src/datumaro/plugins/data_formats/kitti_raw/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021-2023 Intel Corporation
# Copyright (C) 2021-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -182,7 +182,7 @@ def _parse_attr(cls, value):
@classmethod
def _parse_track(cls, track_id, track, categories):
common_attrs = {k: cls._parse_attr(v) for k, v in track["attributes"].items()}
scale = [track["scale"][k] for k in ["w", "h", "l"]]
scale = [track["scale"][k] for k in ["h", "w", "l"]]
label = categories[AnnotationType.label].find(track["label"])[0]

kf_occluded = False
Expand Down
8 changes: 4 additions & 4 deletions src/datumaro/plugins/data_formats/kitti_raw/exporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2021 Intel Corporation
# Copyright (C) 2021-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -339,16 +339,16 @@ def _create_tracklets(self, subset):
if not track:
track = {
"objectType": label,
"h": ann.scale[1],
"w": ann.scale[0],
"h": ann.scale[0],
"w": ann.scale[1],
"l": ann.scale[2],
"first_frame": frame_id,
"poses": [],
"finished": 1, # keep last
}
tracks[track_id] = track
else:
if [track["w"], track["h"], track["l"]] != ann.scale:
if [track["h"], track["w"], track["l"]] != ann.scale:
# Tracks have fixed scale in the format
raise DatasetExportError(
"Item %s: mismatching track shapes, "
Expand Down
8 changes: 4 additions & 4 deletions tests/integration/cli/test_kitti_raw_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def test_can_convert_to_kitti_raw(self):
annotations=[
Cuboid3d(
position=[1, 2, 3],
scale=[7.95, -3.62, -1.03],
scale=[-3.62, 7.95, -1.03],
label=1,
attributes={"occluded": False, "track_id": 1},
),
Cuboid3d(
position=[1, 1, 0],
scale=[8.34, 23.01, -0.76],
scale=[23.01, 8.34, -0.76],
label=0,
attributes={"occluded": False, "track_id": 2},
),
Expand All @@ -65,7 +65,7 @@ def test_can_convert_to_kitti_raw(self):
annotations=[
Cuboid3d(
position=[0, 1, 0],
scale=[8.34, 23.01, -0.76],
scale=[23.01, 8.34, -0.76],
rotation=[1, 1, 3],
label=0,
attributes={"occluded": True, "track_id": 2},
Expand All @@ -92,7 +92,7 @@ def test_can_convert_to_kitti_raw(self):
annotations=[
Cuboid3d(
position=[1, 2, 3],
scale=[-9.41, 13.54, 0.24],
scale=[13.54, -9.41, 0.24],
label=1,
attributes={"occluded": False, "track_id": 3},
)
Expand Down
20 changes: 10 additions & 10 deletions tests/unit/test_kitti_raw_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ def test_can_load(self):
annotations=[
Cuboid3d(
position=[1, 2, 3],
scale=[7.95, -3.62, -1.03],
scale=[-3.62, 7.95, -1.03],
label=1,
attributes={"occluded": False, "track_id": 1},
),
Cuboid3d(
position=[1, 1, 0],
scale=[8.34, 23.01, -0.76],
scale=[23.01, 8.34, -0.76],
label=0,
attributes={"occluded": False, "track_id": 2},
),
Expand All @@ -71,7 +71,7 @@ def test_can_load(self):
annotations=[
Cuboid3d(
position=[0, 1, 0],
scale=[8.34, 23.01, -0.76],
scale=[23.01, 8.34, -0.76],
rotation=[1, 1, 3],
label=0,
attributes={"occluded": True, "track_id": 2},
Expand All @@ -85,7 +85,7 @@ def test_can_load(self):
annotations=[
Cuboid3d(
position=[1, 2, 3],
scale=[-9.41, 13.54, 0.24],
scale=[13.54, -9.41, 0.24],
label=1,
attributes={"occluded": False, "track_id": 3},
)
Expand Down Expand Up @@ -161,7 +161,7 @@ def test_can_save_and_load(self):
Cuboid3d(position=[1.4, 2.1, 1.4], label=1, attributes={"track_id": 2}),
Cuboid3d(
position=[11.4, -0.1, 4.2],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"track_id": 3},
),
Expand All @@ -172,7 +172,7 @@ def test_can_save_and_load(self):
annotations=[
Cuboid3d(
position=[0.4, -1, 2.24],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"track_id": 3},
),
Expand All @@ -185,7 +185,7 @@ def test_can_save_and_load(self):
annotations=[
Cuboid3d(
position=[0.4, -1, 3.24],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"track_id": 3},
),
Expand Down Expand Up @@ -244,7 +244,7 @@ def test_can_save_and_load(self):
),
Cuboid3d(
position=[11.4, -0.1, 4.2],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"occluded": False, "track_id": 3},
),
Expand All @@ -256,7 +256,7 @@ def test_can_save_and_load(self):
annotations=[
Cuboid3d(
position=[0.4, -1, 2.24],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"occluded": False, "track_id": 3},
),
Expand All @@ -271,7 +271,7 @@ def test_can_save_and_load(self):
annotations=[
Cuboid3d(
position=[0.4, -1, 3.24],
scale=[2, 1, 2],
scale=[1, 2, 2],
label=0,
attributes={"occluded": False, "track_id": 3},
),
Expand Down

0 comments on commit 51c316a

Please sign in to comment.