Skip to content

Commit

Permalink
added remove statistical outlier test
Browse files Browse the repository at this point in the history
  • Loading branch information
SVivdich02 committed Jan 3, 2024
1 parent 331304f commit 2c1702c
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 9 deletions.
4 changes: 2 additions & 2 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
"start_image_index_offset": 2,
"cam_name": "cam2",
"R": 12,
"nb_neighbors": 30,
"std_ratio": 5.0,
"nb_neighbors": 5,
"std_ratio": 2.0,
"voxel_size": 0.25,
}
)
6 changes: 3 additions & 3 deletions tests/test_in_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ def test_select_points_in_cube(
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(src_points)

pcd_in_cube, points2instances_in_cube = SelectionInCubeProcessor().process(
actual_pcd, actual_points2instances = SelectionInCubeProcessor().process(
config, pcd, src_points2instances
)

assert (np.asarray(pcd_in_cube.points) == expected_points).all()
assert (points2instances_in_cube == expected_points2instances).all()
assert (np.asarray(actual_pcd.points) == expected_points).all()
assert (actual_points2instances == expected_points2instances).all()
4 changes: 2 additions & 2 deletions tests/test_init_instances_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
def test_init_map(init_pcd: o3d.geometry.PointCloud):
points2instances = InitInstancesMatrixProcessor().process(config, init_pcd)

real_image_count = config.end_index - (
expected_image_count = config.end_index - (
config.start_index - config.start_image_index_offset
)

assert points2instances.shape == (len(init_pcd.points), real_image_count)
assert points2instances.shape == (len(init_pcd.points), expected_image_count)
4 changes: 2 additions & 2 deletions tests/test_init_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
def test_init_map():
init_pcd = InitMapProcessor().process(config)

real_init_map_size = sum(
expected_init_map_size = sum(
len(config.dataset.get_point_cloud(i).points)
for i in range(config.start_index, config.end_index)
)

assert len(init_pcd.points) == real_init_map_size
assert len(init_pcd.points) == expected_init_map_size
95 changes: 95 additions & 0 deletions tests/test_statistical_outlier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Copyright (c) 2023, Sofia Vivdich and Anastasiia Kornilova
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np
import open3d as o3d
import pytest

from services.preprocessing.statistical_outlier import StatisticalOutlierProcessor

from tests.test_data import config


@pytest.mark.parametrize(
"src_points, "
"src_points2instances, "
"expected_points, "
"expected_points2instances",
[
(
np.array(
[
[0.1, 0.1, 2],
[0.2, 0.2, 3],
[0.3, 0.3, 4],
[0.4, 0.4, 2],
[0.5, 0.5, 6],
[-100000, -300000, -999999],
[0.7, 0.7, 5],
[0.8, 0.8, 3],
[0.9, 0.9, 1],
]
),
np.array(
[
[1, 2, 3, 4, 5, 6],
[0, 2, 3, 4, 5, 6],
[1, 0, 3, 4, 5, 6],
[1, 2, 0, 4, 5, 6],
[1, 2, 3, 0, 5, 6],
[1, 2, 3, 4, 0, 6],
[1, 2, 3, 4, 5, 0],
[0, 0, 3, 4, 5, 6],
[1, 0, 0, 4, 5, 6],
]
),
np.array(
[
[0.1, 0.1, 2],
[0.2, 0.2, 3],
[0.3, 0.3, 4],
[0.4, 0.4, 2],
[0.5, 0.5, 6],
[0.7, 0.7, 5],
[0.8, 0.8, 3],
[0.9, 0.9, 1],
]
),
np.array(
[
[1, 2, 3, 4, 5, 6],
[0, 2, 3, 4, 5, 6],
[1, 0, 3, 4, 5, 6],
[1, 2, 0, 4, 5, 6],
[1, 2, 3, 0, 5, 6],
[1, 2, 3, 4, 5, 0],
[0, 0, 3, 4, 5, 6],
[1, 0, 0, 4, 5, 6],
]
),
)
],
)
def test_select_points_in_cube(
src_points, src_points2instances, expected_points, expected_points2instances
):
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(src_points)

actual_pcd, actual_points2instances = StatisticalOutlierProcessor().process(
config, pcd, src_points2instances
)

assert (np.asarray(actual_pcd.points) == expected_points).all()
assert (actual_points2instances == expected_points2instances).all()

0 comments on commit 2c1702c

Please sign in to comment.