Skip to content

Commit 4fa3b4a

Browse files
authored
Merge pull request #718 from mapillary/fix-duplicate-check-without-compass-angles
fix: check distance for duplications when compass angles are not found
2 parents 39dbb72 + c994e19 commit 4fa3b4a

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

mapillary_tools/process_sequence_properties.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ def cut_sequence_by_time_distance(
4646

4747
def duplication_check(
4848
sequence: PointSequence,
49-
duplicate_distance: float,
50-
duplicate_angle: float,
49+
max_duplicate_distance: float,
50+
max_duplicate_angle: float,
5151
) -> T.Tuple[PointSequence, T.List[types.ErrorMetadata]]:
5252
dedups: PointSequence = []
5353
dups: T.List[types.ErrorMetadata] = []
@@ -70,13 +70,14 @@ def duplication_check(
7070
else:
7171
angle_diff = None
7272

73-
if distance <= duplicate_distance and (
74-
angle_diff is not None and angle_diff <= duplicate_angle
73+
if distance <= max_duplicate_distance and (
74+
angle_diff is None or angle_diff <= max_duplicate_angle
7575
):
76+
msg = f"Duplicate of its previous image in terms of distance <= {max_duplicate_distance} and angle <= {max_duplicate_angle}"
7677
dups.append(
7778
types.describe_error_metadata(
7879
MapillaryDuplicationError(
79-
f"Duplicate of its previous image in terms of distance <= {duplicate_distance} and angle <= {duplicate_angle}",
80+
msg,
8081
types.as_desc(cur),
8182
distance=distance,
8283
angle_diff=angle_diff,
@@ -305,8 +306,8 @@ def process_sequence_properties(
305306
# duplication check
306307
dedups, dups = duplication_check(
307308
sequence,
308-
duplicate_distance=duplicate_distance,
309-
duplicate_angle=duplicate_angle,
309+
max_duplicate_distance=duplicate_distance,
310+
max_duplicate_angle=duplicate_angle,
310311
)
311312
assert len(sequence) == len(dedups) + len(dups)
312313
error_metadatas.extend(dups)

tests/unit/test_sequence_processing.py

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,30 @@ def test_find_sequences_by_folder(tmpdir: py.path.local):
5252
error=Exception("an error"),
5353
),
5454
# s1
55-
_make_image_metadata(Path(curdir) / Path("hello/foo.jpg"), 1.00001, 1.00001, 2),
55+
_make_image_metadata(
56+
Path(curdir) / Path("hello/foo.jpg"), 1.00001, 1.00001, 2, 11
57+
),
5658
_make_image_metadata(
5759
Path(curdir) / Path("./hello/bar.jpg"),
5860
1.00002,
5961
1.00002,
6062
8,
63+
22,
64+
),
65+
_make_image_metadata(
66+
Path(curdir) / Path("hello/a.jpg"), 1.00002, 1.00002, 9, 33
6167
),
62-
_make_image_metadata(Path(curdir) / Path("hello/a.jpg"), 1.00002, 1.00002, 9),
6368
# s2
64-
_make_image_metadata(Path(curdir) / Path("hello.jpg"), 1.00002, 1.00002, 2),
65-
_make_image_metadata(Path(curdir) / Path("./foo.jpg"), 1.00001, 1.00001, 3),
66-
_make_image_metadata(Path(curdir) / Path("a.jpg"), 1.00001, 1.00001, 1),
69+
_make_image_metadata(Path(curdir) / Path("hello.jpg"), 1.00002, 1.00002, 2, 11),
70+
_make_image_metadata(Path(curdir) / Path("./foo.jpg"), 1.00001, 1.00001, 3, 22),
71+
_make_image_metadata(Path(curdir) / Path("a.jpg"), 1.00001, 1.00001, 1, 33),
6772
# s3
68-
_make_image_metadata(Path(curdir) / Path("./../foo.jpg"), 1.00001, 1.00001, 19),
69-
_make_image_metadata(Path(curdir) / Path("../bar.jpg"), 1.00002, 1.00002, 28),
73+
_make_image_metadata(
74+
Path(curdir) / Path("./../foo.jpg"), 1.00001, 1.00001, 19, 11
75+
),
76+
_make_image_metadata(
77+
Path(curdir) / Path("../bar.jpg"), 1.00002, 1.00002, 28, 22
78+
),
7079
]
7180
metadatas = psp.process_sequence_properties(
7281
sequence,
@@ -277,11 +286,11 @@ def test_subsec_interpolation(tmpdir: py.path.local):
277286
curdir = tmpdir.mkdir("hello222").mkdir("world333")
278287
sequence: T.List[types.Metadata] = [
279288
# s1
280-
_make_image_metadata(Path(curdir) / Path("./a.jpg"), 1, 1, 0.0),
281-
_make_image_metadata(Path(curdir) / Path("./b.jpg"), 0, 1, 1.0),
282-
_make_image_metadata(Path(curdir) / Path("./c.jpg"), 0, 0, 1.0),
283-
_make_image_metadata(Path(curdir) / Path("./d.jpg"), 0, 0, 1.0),
284-
_make_image_metadata(Path(curdir) / Path("./e.jpg"), 1, 0, 2.0),
289+
_make_image_metadata(Path(curdir) / Path("./a.jpg"), 1, 1, 0.0, 1),
290+
_make_image_metadata(Path(curdir) / Path("./b.jpg"), 0, 1, 1.0, 11),
291+
_make_image_metadata(Path(curdir) / Path("./c.jpg"), 0, 0, 1.0, 22),
292+
_make_image_metadata(Path(curdir) / Path("./d.jpg"), 0, 0, 1.0, 33),
293+
_make_image_metadata(Path(curdir) / Path("./e.jpg"), 1, 0, 2.0, 44),
285294
]
286295
metadatas = psp.process_sequence_properties(
287296
sequence,

0 commit comments

Comments
 (0)