Skip to content

Commit

Permalink
added init tests
Browse files Browse the repository at this point in the history
  • Loading branch information
SVivdich02 committed Jan 3, 2024
1 parent e372520 commit f14706b
Show file tree
Hide file tree
Showing 32 changed files with 139 additions and 35 deletions.
29 changes: 25 additions & 4 deletions tests/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,31 @@
# See the License for the specific language governing permissions and
# limitations under the License.

import numpy as np
from pcd_dataset.kitti_dataset import KittiDataset
from services.preprocessing.common.config import ConfigDTO

from pathlib import Path
dataset_path = "tests/test_dataset/"
sequence = "00"
image_instances_path = "tests/test_pipeline/vfm-labels/sam/00/"

path_to_dataset = Path("tests/test_dataset")
kitti = KittiDataset(dataset_path, sequence, image_instances_path)

intrinsics = np.loadtxt(path_to_dataset / "intrinsics.txt")
config = ConfigDTO(
**{
"dataset": kitti,
"start_index": 3,
"end_index": 7,
"start_image_index_offset": 2,
"cam_name": "cam2",
"R": 12,
"nb_neighbors": 30,
"std_ratio": 5.0,
"voxel_size": 0.25,
}
)

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

real_image_count = config.end_index - (config.start_index - config.start_image_index_offset)
3 changes: 0 additions & 3 deletions tests/test_dataset/intrinsics.txt

This file was deleted.

25 changes: 0 additions & 25 deletions tests/test_dataset/poses.txt

This file was deleted.

10 changes: 10 additions & 0 deletions tests/test_dataset/poses/00.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 9.31323e-10 -3.27418e-11 0 -9.31323e-10 1 -4.65661e-10 7.45058e-09 1.09139e-11 -9.31323e-10 1 0
0.999991 -0.00316351 -0.00274942 -0.00135393 0.00316045 0.999994 -0.00111659 -0.0248245 0.00275294 0.00110789 0.999996 0.672716
0.999969 -0.00274641 -0.00740973 -0.00497909 0.00272564 0.999992 -0.00281192 -0.0381271 0.0074174 0.00279163 0.999969 1.37469
0.999925 -0.00226129 -0.0120078 -0.0149304 0.0022199 0.999992 -0.00345849 -0.0500735 0.0120155 0.00343158 0.999922 2.08592
0.999855 -0.00103747 -0.0170278 -0.0315576 0.000971246 0.999992 -0.00389727 -0.0597511 0.0170317 0.00388016 0.999847 2.81254
0.999759 -0.00222044 -0.0218404 -0.0495894 0.00213642 0.99999 -0.0038696 -0.0735588 0.0218488 0.003822 0.999754 3.55139
0.99969 -0.000911992 -0.0248676 -0.0810928 0.000785158 0.999987 -0.00510963 -0.0882149 0.024872 0.00508852 0.999678 4.31233
0.999573 0.00254257 -0.0291203 -0.110765 -0.00272044 0.999978 -0.00607018 -0.105792 0.0291042 0.00614681 0.999558 5.08088
0.999438 0.00434114 -0.0332473 -0.142767 -0.00450281 0.999978 -0.00478932 -0.11819 0.0332258 0.00493634 0.999436 5.87572
0.999253 0.00411408 -0.0384275 -0.178263 -0.00420248 0.999989 -0.00221999 -0.130267 0.0384179 0.00237982 0.999259 6.68287
5 changes: 5 additions & 0 deletions tests/test_dataset/sequences/00/calib.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
P0: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 0.000000000000e+00 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P1: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 -3.861448000000e+02 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 0.000000000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 0.000000000000e+00
P2: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 4.538225000000e+01 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 -1.130887000000e-01 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 3.779761000000e-03
P3: 7.188560000000e+02 0.000000000000e+00 6.071928000000e+02 -3.372877000000e+02 0.000000000000e+00 7.188560000000e+02 1.852157000000e+02 2.369057000000e+00 0.000000000000e+00 0.000000000000e+00 1.000000000000e+00 4.915215000000e-03
Tr: 4.276802385584e-04 -9.999672484946e-01 -8.084491683471e-03 -1.198459927713e-02 -7.210626507497e-03 8.081198471645e-03 -9.999413164504e-01 -5.403984729748e-02 9.999738645903e-01 4.859485810390e-04 -7.206933692422e-03 -2.921968648686e-01
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions tests/test_dataset/sequences/00/poses.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
1 9.31323e-10 -3.27418e-11 0 -9.31323e-10 1 -4.65661e-10 7.45058e-09 1.09139e-11 -9.31323e-10 1 0
0.999991 -0.00316351 -0.00274942 -0.00135393 0.00316045 0.999994 -0.00111659 -0.0248245 0.00275294 0.00110789 0.999996 0.672716
0.999969 -0.00274641 -0.00740973 -0.00497909 0.00272564 0.999992 -0.00281192 -0.0381271 0.0074174 0.00279163 0.999969 1.37469
0.999925 -0.00226129 -0.0120078 -0.0149304 0.0022199 0.999992 -0.00345849 -0.0500735 0.0120155 0.00343158 0.999922 2.08592
0.999855 -0.00103747 -0.0170278 -0.0315576 0.000971246 0.999992 -0.00389727 -0.0597511 0.0170317 0.00388016 0.999847 2.81254
0.999759 -0.00222044 -0.0218404 -0.0495894 0.00213642 0.99999 -0.0038696 -0.0735588 0.0218488 0.003822 0.999754 3.55139
0.99969 -0.000911992 -0.0248676 -0.0810928 0.000785158 0.999987 -0.00510963 -0.0882149 0.024872 0.00508852 0.999678 4.31233
0.999573 0.00254257 -0.0291203 -0.110765 -0.00272044 0.999978 -0.00607018 -0.105792 0.0291042 0.00614681 0.999558 5.08088
0.999438 0.00434114 -0.0332473 -0.142767 -0.00450281 0.999978 -0.00478932 -0.11819 0.0332258 0.00493634 0.999436 5.87572
0.999253 0.00411408 -0.0384275 -0.178263 -0.00420248 0.999989 -0.00221999 -0.130267 0.0384179 0.00237982 0.999259 6.68287
10 changes: 10 additions & 0 deletions tests/test_dataset/sequences/00/times.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
0.000000e+00
1.037359e-01
2.073381e-01
3.110752e-01
4.146917e-01
5.184302e-01
6.220448e-01
7.257977e-01
8.294199e-01
9.331467e-01
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
3 changes: 0 additions & 3 deletions tests/test_first.py

This file was deleted.

28 changes: 28 additions & 0 deletions tests/test_init_instances_matrix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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 open3d as o3d
import pytest

from services.preprocessing.init.instances_matrix import InitInstancesMatrixProcessor

from tests.test_data import config
from tests.test_data import real_image_count
from tests.utils import generate_init_pcd

@pytest.mark.parametrize("init_pcd", [generate_init_pcd(config)])
def test_init_map(init_pcd : o3d.geometry.PointCloud):
points2instances = InitInstancesMatrixProcessor().process(config, init_pcd)

assert points2instances.shape == (len(init_pcd.points), real_image_count)
24 changes: 24 additions & 0 deletions tests/test_init_map.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 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.

from services.preprocessing.init.map import InitMapProcessor

from tests.test_data import config
from tests.test_data import real_init_map_size


def test_init_map():
init_pcd = InitMapProcessor().process(config)

assert len(init_pcd.points) == real_init_map_size
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# 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 copy
import open3d as o3d

from services.preprocessing.common.config import ConfigDTO

def generate_init_pcd(config : ConfigDTO):
map_wc = o3d.geometry.PointCloud()

for i in range(config.start_index, config.end_index):
T = config.dataset.get_lidar_pose(i)
map_wc += copy.deepcopy(config.dataset.get_point_cloud(i)).transform(T)

return map_wc

0 comments on commit f14706b

Please sign in to comment.