cars 1.0.0a3__cp312-cp312-win_amd64.whl → 1.0.0a4__cp312-cp312-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cars might be problematic. Click here for more details.
- cars/__init__.py +3 -3
- cars/applications/__init__.py +0 -3
- cars/applications/application_template.py +20 -0
- cars/applications/auxiliary_filling/abstract_auxiliary_filling_app.py +12 -2
- cars/applications/auxiliary_filling/auxiliary_filling_algo.py +2 -2
- cars/applications/auxiliary_filling/auxiliary_filling_from_sensors_app.py +80 -36
- cars/applications/dem_generation/dem_generation_algo.py +1 -1
- cars/applications/dem_generation/dem_generation_wrappers.py +23 -57
- cars/applications/dem_generation/dichotomic_generation_app.py +3 -3
- cars/applications/dem_generation/rasterization_app.py +100 -41
- cars/applications/dense_match_filling/__init__.py +1 -1
- cars/applications/dense_match_filling/abstract_dense_match_filling_app.py +2 -15
- cars/applications/dense_match_filling/fill_disp_algo.py +32 -373
- cars/applications/dense_match_filling/fill_disp_wrappers.py +0 -343
- cars/applications/dense_match_filling/zero_padding_app.py +10 -5
- cars/applications/dense_matching/abstract_dense_matching_app.py +2 -1
- cars/applications/dense_matching/census_mccnn_sgm_app.py +38 -39
- cars/applications/dense_matching/cpp/dense_matching_cpp.cp312-win_amd64.dll.a +0 -0
- cars/applications/dense_matching/cpp/dense_matching_cpp.cp312-win_amd64.pyd +0 -0
- cars/applications/dense_matching/dense_matching_algo.py +48 -14
- cars/applications/dense_matching/dense_matching_wrappers.py +11 -3
- cars/applications/dense_matching/disparity_grid_algo.py +84 -62
- cars/applications/dense_matching/loaders/pandora_loader.py +91 -33
- cars/applications/dsm_filling/border_interpolation_app.py +1 -7
- cars/applications/dsm_filling/bulldozer_filling_app.py +2 -8
- cars/applications/dsm_filling/exogenous_filling_app.py +4 -9
- cars/applications/grid_generation/abstract_grid_generation_app.py +1 -1
- cars/applications/grid_generation/epipolar_grid_generation_app.py +4 -2
- cars/applications/grid_generation/grid_correction_app.py +4 -1
- cars/applications/grid_generation/grid_generation_algo.py +7 -2
- cars/applications/ground_truth_reprojection/abstract_ground_truth_reprojection_app.py +1 -1
- cars/applications/ground_truth_reprojection/direct_localization_app.py +2 -2
- cars/applications/ground_truth_reprojection/ground_truth_reprojection_algo.py +2 -1
- cars/applications/point_cloud_fusion/abstract_pc_fusion_app.py +0 -155
- cars/applications/point_cloud_fusion/mapping_to_terrain_tiles_app.py +0 -658
- cars/applications/point_cloud_fusion/pc_fusion_algo.py +0 -1339
- cars/applications/point_cloud_fusion/pc_fusion_wrappers.py +0 -869
- cars/applications/point_cloud_outlier_removal/abstract_outlier_removal_app.py +2 -1
- cars/applications/point_cloud_outlier_removal/outlier_removal_algo.py +9 -8
- cars/applications/point_cloud_outlier_removal/small_components_app.py +96 -267
- cars/applications/point_cloud_outlier_removal/statistical_app.py +116 -275
- cars/applications/rasterization/abstract_pc_rasterization_app.py +1 -1
- cars/applications/rasterization/rasterization_algo.py +18 -6
- cars/applications/rasterization/rasterization_wrappers.py +2 -1
- cars/applications/rasterization/simple_gaussian_app.py +60 -113
- cars/applications/resampling/abstract_resampling_app.py +1 -1
- cars/applications/resampling/bicubic_resampling_app.py +3 -1
- cars/applications/resampling/resampling_algo.py +16 -4
- cars/applications/resampling/resampling_wrappers.py +3 -1
- cars/applications/sparse_matching/abstract_sparse_matching_app.py +1 -1
- cars/applications/sparse_matching/sift_app.py +3 -3
- cars/applications/sparse_matching/sparse_matching_algo.py +3 -2
- cars/applications/sparse_matching/sparse_matching_wrappers.py +1 -1
- cars/applications/triangulation/abstract_triangulation_app.py +1 -1
- cars/applications/triangulation/line_of_sight_intersection_app.py +13 -11
- cars/applications/triangulation/pc_transform.py +552 -0
- cars/applications/triangulation/triangulation_algo.py +6 -4
- cars/applications/triangulation/triangulation_wrappers.py +1 -0
- cars/bundleadjustment.py +6 -6
- cars/cars.py +11 -9
- cars/core/cars_logging.py +80 -49
- cars/core/constants.py +0 -1
- cars/core/datasets.py +5 -2
- cars/core/geometry/abstract_geometry.py +256 -25
- cars/core/geometry/shareloc_geometry.py +110 -82
- cars/core/inputs.py +57 -19
- cars/core/outputs.py +1 -1
- cars/core/preprocessing.py +17 -3
- cars/core/projection.py +9 -6
- cars/core/tiling.py +10 -3
- cars/data_structures/cars_dataset.py +5 -5
- cars/data_structures/corresponding_tiles_tools.py +0 -103
- cars/data_structures/format_transformation.py +4 -1
- cars/devibrate.py +6 -3
- cars/extractroi.py +20 -21
- cars/orchestrator/cluster/abstract_cluster.py +15 -5
- cars/orchestrator/cluster/abstract_dask_cluster.py +6 -2
- cars/orchestrator/cluster/dask_jobqueue_utils.py +1 -1
- cars/orchestrator/cluster/log_wrapper.py +148 -21
- cars/orchestrator/cluster/mp_cluster/multiprocessing_cluster.py +11 -3
- cars/orchestrator/cluster/mp_cluster/multiprocessing_profiler.py +2 -2
- cars/orchestrator/cluster/pbs_dask_cluster.py +1 -1
- cars/orchestrator/cluster/sequential_cluster.py +5 -4
- cars/orchestrator/cluster/slurm_dask_cluster.py +1 -1
- cars/orchestrator/orchestrator.py +14 -3
- cars/orchestrator/registry/id_generator.py +1 -0
- cars/orchestrator/registry/saver_registry.py +2 -2
- cars/pipelines/conf_resolution/conf_final_resolution.json +5 -3
- cars/pipelines/default/default_pipeline.py +462 -1073
- cars/pipelines/parameters/advanced_parameters.py +74 -64
- cars/pipelines/parameters/advanced_parameters_constants.py +2 -5
- cars/pipelines/parameters/application_parameters.py +71 -0
- cars/pipelines/parameters/depth_map_inputs.py +0 -314
- cars/pipelines/parameters/dsm_inputs.py +40 -4
- cars/pipelines/parameters/output_parameters.py +2 -2
- cars/pipelines/parameters/sensor_inputs.py +30 -75
- cars/pipelines/parameters/sensor_inputs_constants.py +0 -2
- cars/pipelines/parameters/sensor_loaders/__init__.py +4 -3
- cars/pipelines/parameters/sensor_loaders/basic_classif_loader.py +106 -0
- cars/pipelines/parameters/sensor_loaders/{basic_sensor_loader.py → basic_image_loader.py} +16 -22
- cars/pipelines/parameters/sensor_loaders/pivot_classif_loader.py +121 -0
- cars/pipelines/parameters/sensor_loaders/{pivot_sensor_loader.py → pivot_image_loader.py} +10 -21
- cars/pipelines/parameters/sensor_loaders/sensor_loader.py +4 -6
- cars/pipelines/parameters/sensor_loaders/sensor_loader_template.py +1 -3
- cars/pipelines/pipeline_template.py +1 -3
- cars/pipelines/unit/unit_pipeline.py +527 -1016
- cars/starter.py +4 -3
- cars-1.0.0a4.dist-info/DELVEWHEEL +2 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/METADATA +135 -53
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/RECORD +115 -131
- cars.libs/libgcc_s_seh-1-b2494fcbd4d80cf2c98fdd5261f6d850.dll +0 -0
- cars.libs/libstdc++-6-e9b0d12ae0e9555bbae55e8dfd08c3f7.dll +0 -0
- cars.libs/libwinpthread-1-7882d1b093714ccdfaf4e0789a817792.dll +0 -0
- cars/applications/dense_match_filling/cpp/__init__.py +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp312-win_amd64.dll.a +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.cp312-win_amd64.pyd +0 -0
- cars/applications/dense_match_filling/cpp/dense_match_filling_cpp.py +0 -72
- cars/applications/dense_match_filling/cpp/includes/dense_match_filling.hpp +0 -46
- cars/applications/dense_match_filling/cpp/meson.build +0 -9
- cars/applications/dense_match_filling/cpp/src/bindings.cpp +0 -11
- cars/applications/dense_match_filling/cpp/src/dense_match_filling.cpp +0 -142
- cars/applications/dense_match_filling/plane_app.py +0 -556
- cars/applications/hole_detection/__init__.py +0 -30
- cars/applications/hole_detection/abstract_hole_detection_app.py +0 -125
- cars/applications/hole_detection/cloud_to_bbox_app.py +0 -346
- cars/applications/hole_detection/hole_detection_algo.py +0 -144
- cars/applications/hole_detection/hole_detection_wrappers.py +0 -53
- cars/applications/point_cloud_denoising/__init__.py +0 -29
- cars/applications/point_cloud_denoising/abstract_pc_denoising_app.py +0 -273
- cars/applications/point_cloud_fusion/__init__.py +0 -30
- cars/applications/point_cloud_fusion/cloud_fusion_constants.py +0 -39
- cars/applications/sparse_matching/pandora_sparse_matching_app.py +0 -0
- cars/pipelines/parameters/depth_map_inputs_constants.py +0 -25
- cars-1.0.0a3.dist-info/DELVEWHEEL +0 -2
- cars.libs/libgcc_s_seh-1-ca70890bbc5723b6d0ea31e9c9cded2b.dll +0 -0
- cars.libs/libstdc++-6-00ee19f73d5122a1277c137b1c218401.dll +0 -0
- cars.libs/libwinpthread-1-f5042e8e3d21edce20c1bc99445f551b.dll +0 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/WHEEL +0 -0
- {cars-1.0.0a3.dist-info → cars-1.0.0a4.dist-info}/entry_points.txt +0 -0
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
#include "dense_match_filling.hpp"
|
|
2
|
-
#include <pybind11/numpy.h>
|
|
3
|
-
#include <pybind11/stl.h>
|
|
4
|
-
#include <pybind11/pybind11.h>
|
|
5
|
-
#include <cmath>
|
|
6
|
-
#include <optional>
|
|
7
|
-
#include <iostream>
|
|
8
|
-
#include <algorithm>
|
|
9
|
-
|
|
10
|
-
namespace py = pybind11;
|
|
11
|
-
|
|
12
|
-
std::pair<py::array_t<float>, py::array_t<bool>> fill_disp_pandora(
|
|
13
|
-
py::array_t<float> disp,
|
|
14
|
-
py::array_t<bool> msk_fill_disp,
|
|
15
|
-
int nb_directions
|
|
16
|
-
) {
|
|
17
|
-
auto r_disp = disp.unchecked<2>();
|
|
18
|
-
auto r_msk_fill_disp = msk_fill_disp.unchecked<2>();
|
|
19
|
-
|
|
20
|
-
size_t nrow = r_disp.shape(0);
|
|
21
|
-
size_t ncol = r_disp.shape(1);
|
|
22
|
-
|
|
23
|
-
py::array_t<float> out_disp({nrow, ncol});
|
|
24
|
-
py::array_t<bool> out_msk({nrow, ncol});
|
|
25
|
-
|
|
26
|
-
auto rw_out_disp = out_disp.mutable_unchecked<2>();
|
|
27
|
-
auto rw_out_msk = out_msk.mutable_unchecked<2>();
|
|
28
|
-
|
|
29
|
-
py::array_t<float> dirs;
|
|
30
|
-
if (nb_directions == 8) {
|
|
31
|
-
std::vector<float> data = {
|
|
32
|
-
0.0f, 1.0f,
|
|
33
|
-
-1.0f, 1.0f,
|
|
34
|
-
-1.0f, 0.0f,
|
|
35
|
-
-1.0f, -1.0f,
|
|
36
|
-
0.0f, -1.0f,
|
|
37
|
-
1.0f, -1.0f,
|
|
38
|
-
1.0f, 0.0f,
|
|
39
|
-
1.0f, 1.0f
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
dirs = py::array({8, 2}, data.data());
|
|
43
|
-
} else if (nb_directions == 16) {
|
|
44
|
-
std::vector<float> data = {
|
|
45
|
-
0.0f, 1.0f, -0.5f, 1.0f,
|
|
46
|
-
-1.0f, 1.0f, -1.0f, 0.5f,
|
|
47
|
-
-1.0f, 0.0f, -1.0f, -0.5f,
|
|
48
|
-
-1.0f, -1.0f, -0.5f, -1.0f,
|
|
49
|
-
0.0f, -1.0f, 0.5f, -1.0f,
|
|
50
|
-
1.0f, -1.0f, 1.0f, -0.5f,
|
|
51
|
-
1.0f, 0.0f, 1.0f, 0.5f,
|
|
52
|
-
1.0f, 1.0f, 0.5f, 1.0f
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
dirs = py::array({16, 2}, data.data());
|
|
56
|
-
} else {
|
|
57
|
-
throw std::invalid_argument("nb_directions must be 8 or 16");
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
for (size_t row = 0; row < nrow; ++row) {
|
|
61
|
-
for (size_t col = 0; col < ncol; ++col) {
|
|
62
|
-
if (r_msk_fill_disp(row, col)) {
|
|
63
|
-
auto valid_neighbors = find_valid_neighbors(
|
|
64
|
-
dirs, disp, msk_fill_disp,
|
|
65
|
-
static_cast<int>(row), static_cast<int>(col),
|
|
66
|
-
nb_directions
|
|
67
|
-
).unchecked<1>();
|
|
68
|
-
|
|
69
|
-
std::vector<float> valid_values;
|
|
70
|
-
for (size_t i = 0; i < valid_neighbors.shape(0); ++i) {
|
|
71
|
-
if (!std::isnan(valid_neighbors(i))) {
|
|
72
|
-
valid_values.push_back(valid_neighbors(i));
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (valid_values.empty()) {
|
|
78
|
-
rw_out_disp(row, col) = std::nanf("");
|
|
79
|
-
}
|
|
80
|
-
else {
|
|
81
|
-
std::sort(valid_values.begin(), valid_values.end());
|
|
82
|
-
if (valid_values.size()%2==1) {
|
|
83
|
-
rw_out_disp(row, col) = valid_values[valid_values.size()/2];
|
|
84
|
-
} else {
|
|
85
|
-
rw_out_disp(row, col) = valid_values[valid_values.size()/2-1]
|
|
86
|
-
+ valid_values[valid_values.size()/2];
|
|
87
|
-
rw_out_disp(row, col) /= 2.f;
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
rw_out_msk(row, col) = false;
|
|
91
|
-
} else {
|
|
92
|
-
rw_out_disp(row, col) = r_disp(row, col);
|
|
93
|
-
rw_out_msk(row, col) = r_msk_fill_disp(row, col);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
return {out_disp, out_msk};
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
py::array_t<float> find_valid_neighbors(
|
|
102
|
-
py::array_t<float> dirs,
|
|
103
|
-
py::array_t<float> disp,
|
|
104
|
-
py::array_t<bool> valid,
|
|
105
|
-
int row,
|
|
106
|
-
int col,
|
|
107
|
-
int nb_directions
|
|
108
|
-
) {
|
|
109
|
-
auto r_dirs = dirs.unchecked<2>();
|
|
110
|
-
auto r_disp = disp.unchecked<2>();
|
|
111
|
-
auto r_valid = valid.unchecked<2>();
|
|
112
|
-
|
|
113
|
-
size_t nrow = r_disp.shape(0);
|
|
114
|
-
size_t ncol = r_disp.shape(1);
|
|
115
|
-
size_t max_path_length = std::max(nrow, ncol);
|
|
116
|
-
|
|
117
|
-
py::array_t<float> valid_neighbors(nb_directions);
|
|
118
|
-
auto rw_valid_neighbors = valid_neighbors.mutable_unchecked<1>();
|
|
119
|
-
|
|
120
|
-
for (int direction = 0; direction < nb_directions; ++direction) {
|
|
121
|
-
|
|
122
|
-
rw_valid_neighbors(direction) = 0.f;
|
|
123
|
-
|
|
124
|
-
for (size_t i = 1; i < max_path_length; ++i) {
|
|
125
|
-
int tmp_row = row + static_cast<int>(r_dirs(direction, 0) * static_cast<float>(i));
|
|
126
|
-
int tmp_col = col + static_cast<int>(r_dirs(direction, 1) * static_cast<float>(i));
|
|
127
|
-
|
|
128
|
-
if (tmp_row < 0 || tmp_row >= static_cast<int>(nrow) ||
|
|
129
|
-
tmp_col < 0 || tmp_col >= static_cast<int>(ncol)) {
|
|
130
|
-
rw_valid_neighbors(direction) = std::nanf("");
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
if (!r_valid(tmp_row, tmp_col) && r_disp(tmp_row, tmp_col) != 0) {
|
|
135
|
-
rw_valid_neighbors(direction) = r_disp(tmp_row, tmp_col);
|
|
136
|
-
break;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
return valid_neighbors;
|
|
142
|
-
}
|
|
@@ -1,556 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python
|
|
2
|
-
# coding: utf8
|
|
3
|
-
#
|
|
4
|
-
# Copyright (c) 2020 Centre National d'Etudes Spatiales (CNES).
|
|
5
|
-
#
|
|
6
|
-
# This file is part of CARS
|
|
7
|
-
# (see https://github.com/CNES/cars).
|
|
8
|
-
#
|
|
9
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
10
|
-
# you may not use this file except in compliance with the License.
|
|
11
|
-
# You may obtain a copy of the License at
|
|
12
|
-
#
|
|
13
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
|
14
|
-
#
|
|
15
|
-
# Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
# See the License for the specific language governing permissions and
|
|
19
|
-
# limitations under the License.
|
|
20
|
-
#
|
|
21
|
-
"""
|
|
22
|
-
this module contains the fill_disp application class.
|
|
23
|
-
"""
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import copy
|
|
27
|
-
|
|
28
|
-
# Standard imports
|
|
29
|
-
import logging
|
|
30
|
-
|
|
31
|
-
# Third party imports
|
|
32
|
-
from json_checker import Checker, Or
|
|
33
|
-
from shapely.geometry import Polygon
|
|
34
|
-
|
|
35
|
-
# CARS imports
|
|
36
|
-
import cars.orchestrator.orchestrator as ocht
|
|
37
|
-
from cars.applications import application_constants
|
|
38
|
-
from cars.applications.dense_match_filling import (
|
|
39
|
-
abstract_dense_match_filling_app as abstract_dense_match_fill,
|
|
40
|
-
)
|
|
41
|
-
from cars.applications.dense_match_filling import fill_disp_algo as fd_algo
|
|
42
|
-
from cars.applications.dense_match_filling import fill_disp_constants as fd_cst
|
|
43
|
-
from cars.applications.dense_match_filling import (
|
|
44
|
-
fill_disp_wrappers as fd_wrappers,
|
|
45
|
-
)
|
|
46
|
-
from cars.core import constants as cst
|
|
47
|
-
from cars.data_structures import cars_dataset, corresponding_tiles_tools
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
class PlaneFill(
|
|
51
|
-
abstract_dense_match_fill.DenseMatchFilling, short_name=["plane"]
|
|
52
|
-
): # pylint: disable=R0903
|
|
53
|
-
"""
|
|
54
|
-
Fill invalid area in disparity map using plane method
|
|
55
|
-
"""
|
|
56
|
-
|
|
57
|
-
# pylint: disable=too-many-instance-attributes
|
|
58
|
-
|
|
59
|
-
def __init__(self, conf=None):
|
|
60
|
-
"""
|
|
61
|
-
Init function of FillDisp
|
|
62
|
-
|
|
63
|
-
:param conf: configuration for filling
|
|
64
|
-
:return: a application_to_use object
|
|
65
|
-
"""
|
|
66
|
-
|
|
67
|
-
super().__init__(conf=conf)
|
|
68
|
-
|
|
69
|
-
# get conf
|
|
70
|
-
self.used_method = self.used_config["method"]
|
|
71
|
-
self.interpolation_type = self.used_config[fd_cst.INTERP_TYPE]
|
|
72
|
-
self.interpolation_method = self.used_config[fd_cst.INTERP_METHOD]
|
|
73
|
-
self.max_search_distance = self.used_config[fd_cst.MAX_DIST]
|
|
74
|
-
self.smoothing_iterations = self.used_config[fd_cst.SMOOTH_IT]
|
|
75
|
-
self.ignore_nodata_at_disp_mask_borders = self.used_config[
|
|
76
|
-
fd_cst.IGNORE_NODATA
|
|
77
|
-
]
|
|
78
|
-
self.ignore_zero_fill_disp_mask_values = self.used_config[
|
|
79
|
-
fd_cst.IGNORE_ZERO
|
|
80
|
-
]
|
|
81
|
-
self.ignore_extrema_disp_values = self.used_config[
|
|
82
|
-
fd_cst.IGNORE_EXTREMA
|
|
83
|
-
]
|
|
84
|
-
self.nb_pix = self.used_config["nb_pix"]
|
|
85
|
-
self.percent_to_erode = self.used_config["percent_to_erode"]
|
|
86
|
-
self.classification = self.used_config["classification"]
|
|
87
|
-
self.fill_valid_pixels = self.used_config["fill_valid_pixels"]
|
|
88
|
-
# Saving files
|
|
89
|
-
self.save_intermediate_data = self.used_config["save_intermediate_data"]
|
|
90
|
-
|
|
91
|
-
def check_conf(self, conf):
|
|
92
|
-
"""
|
|
93
|
-
Check configuration
|
|
94
|
-
|
|
95
|
-
:param conf: configuration to check
|
|
96
|
-
:type conf: dict
|
|
97
|
-
:return: overloaded configuration
|
|
98
|
-
:rtype: dict
|
|
99
|
-
|
|
100
|
-
"""
|
|
101
|
-
|
|
102
|
-
# init conf
|
|
103
|
-
if conf is not None:
|
|
104
|
-
overloaded_conf = conf.copy()
|
|
105
|
-
else:
|
|
106
|
-
conf = {}
|
|
107
|
-
overloaded_conf = {}
|
|
108
|
-
|
|
109
|
-
# Overload conf
|
|
110
|
-
overloaded_conf["method"] = conf.get("method", "plane")
|
|
111
|
-
|
|
112
|
-
overloaded_conf[fd_cst.INTERP_TYPE] = conf.get(
|
|
113
|
-
fd_cst.INTERP_TYPE, "pandora"
|
|
114
|
-
)
|
|
115
|
-
overloaded_conf[fd_cst.INTERP_METHOD] = conf.get(
|
|
116
|
-
fd_cst.INTERP_METHOD, "mc_cnn"
|
|
117
|
-
)
|
|
118
|
-
overloaded_conf[fd_cst.MAX_DIST] = conf.get(fd_cst.MAX_DIST, 100)
|
|
119
|
-
overloaded_conf[fd_cst.SMOOTH_IT] = conf.get(fd_cst.SMOOTH_IT, 1)
|
|
120
|
-
overloaded_conf[fd_cst.IGNORE_NODATA] = conf.get(
|
|
121
|
-
fd_cst.IGNORE_NODATA, False
|
|
122
|
-
)
|
|
123
|
-
overloaded_conf[fd_cst.IGNORE_ZERO] = conf.get(fd_cst.IGNORE_ZERO, True)
|
|
124
|
-
overloaded_conf[fd_cst.IGNORE_EXTREMA] = conf.get(
|
|
125
|
-
fd_cst.IGNORE_EXTREMA, True
|
|
126
|
-
)
|
|
127
|
-
overloaded_conf["nb_pix"] = conf.get("nb_pix", 20)
|
|
128
|
-
overloaded_conf["percent_to_erode"] = conf.get("percent_to_erode", 0.2)
|
|
129
|
-
overloaded_conf["classification"] = conf.get("classification", None)
|
|
130
|
-
overloaded_conf["fill_valid_pixels"] = conf.get(
|
|
131
|
-
"fill_valid_pixels", True
|
|
132
|
-
)
|
|
133
|
-
# Saving files
|
|
134
|
-
overloaded_conf["save_intermediate_data"] = conf.get(
|
|
135
|
-
"save_intermediate_data", False
|
|
136
|
-
)
|
|
137
|
-
|
|
138
|
-
application_schema = {
|
|
139
|
-
"method": str,
|
|
140
|
-
"save_intermediate_data": bool,
|
|
141
|
-
"interpolation_type": Or(None, str),
|
|
142
|
-
"interpolation_method": Or(None, str),
|
|
143
|
-
"max_search_distance": Or(None, int),
|
|
144
|
-
"smoothing_iterations": Or(None, int),
|
|
145
|
-
"ignore_nodata_at_disp_mask_borders": bool,
|
|
146
|
-
"ignore_zero_fill_disp_mask_values": bool,
|
|
147
|
-
"ignore_extrema_disp_values": bool,
|
|
148
|
-
"nb_pix": Or(None, int),
|
|
149
|
-
"percent_to_erode": Or(None, float),
|
|
150
|
-
"classification": Or(None, [str]),
|
|
151
|
-
"fill_valid_pixels": bool,
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
# Check conf
|
|
155
|
-
checker = Checker(application_schema)
|
|
156
|
-
checker.validate(overloaded_conf)
|
|
157
|
-
|
|
158
|
-
return overloaded_conf
|
|
159
|
-
|
|
160
|
-
def get_poly_margin(self):
|
|
161
|
-
"""
|
|
162
|
-
Get the margin used for polygon
|
|
163
|
-
|
|
164
|
-
:return: self.nb_pix
|
|
165
|
-
:rtype: int
|
|
166
|
-
"""
|
|
167
|
-
|
|
168
|
-
return self.nb_pix
|
|
169
|
-
|
|
170
|
-
def run(
|
|
171
|
-
self,
|
|
172
|
-
epipolar_disparity_map,
|
|
173
|
-
holes_bbox_left=None,
|
|
174
|
-
holes_bbox_right=None,
|
|
175
|
-
disp_min=0,
|
|
176
|
-
disp_max=0,
|
|
177
|
-
orchestrator=None,
|
|
178
|
-
pair_folder=None,
|
|
179
|
-
pair_key="PAIR_0",
|
|
180
|
-
):
|
|
181
|
-
"""
|
|
182
|
-
Run Refill application using plane method.
|
|
183
|
-
|
|
184
|
-
:param epipolar_disparity_map: left to right disparity
|
|
185
|
-
:type epipolar_disparity_map: CarsDataset
|
|
186
|
-
:param holes_bbox_left: left holes
|
|
187
|
-
:type holes_bbox_left: CarsDataset
|
|
188
|
-
:param holes_bbox_right: right holes
|
|
189
|
-
:type holes_bbox_right: CarsDataset
|
|
190
|
-
:param disp_min: minimum disparity
|
|
191
|
-
:type disp_min: int
|
|
192
|
-
:param disp_max: maximum disparity
|
|
193
|
-
:type disp_max: int
|
|
194
|
-
:param orchestrator: orchestrator used
|
|
195
|
-
:param pair_folder: folder used for current pair
|
|
196
|
-
:type pair_folder: str
|
|
197
|
-
:param pair_key: pair id
|
|
198
|
-
:type pair_key: str
|
|
199
|
-
|
|
200
|
-
:return: filled disparity map: \
|
|
201
|
-
Each CarsDataset contains:
|
|
202
|
-
|
|
203
|
-
- N x M Delayed tiles.\
|
|
204
|
-
Each tile will be a future xarray Dataset containing:
|
|
205
|
-
- data with keys : "disp", "disp_msk"
|
|
206
|
-
- attrs with keys: profile, window, overlaps
|
|
207
|
-
- attributes containing:
|
|
208
|
-
"largest_epipolar_region","opt_epipolar_tile_size",
|
|
209
|
-
"epipolar_regions_grid"
|
|
210
|
-
|
|
211
|
-
:rtype: CarsDataset
|
|
212
|
-
|
|
213
|
-
"""
|
|
214
|
-
|
|
215
|
-
if holes_bbox_left is None or holes_bbox_right is None:
|
|
216
|
-
raise RuntimeError("Disparity holes bbox are inconsistent.")
|
|
217
|
-
|
|
218
|
-
res = None
|
|
219
|
-
|
|
220
|
-
if not self.classification:
|
|
221
|
-
logging.info("Disparity holes filling was not activated")
|
|
222
|
-
res = epipolar_disparity_map
|
|
223
|
-
|
|
224
|
-
else:
|
|
225
|
-
# Default orchestrator
|
|
226
|
-
if orchestrator is None:
|
|
227
|
-
# Create defaut sequential orchestrator for current application
|
|
228
|
-
# be awere, no out_json will be shared between orchestrators
|
|
229
|
-
# No files saved
|
|
230
|
-
self.orchestrator = ocht.Orchestrator(
|
|
231
|
-
orchestrator_conf={"mode": "sequential"}
|
|
232
|
-
)
|
|
233
|
-
else:
|
|
234
|
-
self.orchestrator = orchestrator
|
|
235
|
-
|
|
236
|
-
interp_options = {
|
|
237
|
-
"type": self.interpolation_type,
|
|
238
|
-
"method": self.interpolation_method,
|
|
239
|
-
"smoothing_iterations": self.smoothing_iterations,
|
|
240
|
-
"max_search_distance": self.max_search_distance,
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
if epipolar_disparity_map.dataset_type == "arrays":
|
|
244
|
-
new_epipolar_disparity_map = self.__register_dataset__(
|
|
245
|
-
epipolar_disparity_map,
|
|
246
|
-
self.save_intermediate_data,
|
|
247
|
-
pair_folder,
|
|
248
|
-
pair_key,
|
|
249
|
-
app_name="plane",
|
|
250
|
-
nodata_epi_disp=-9999,
|
|
251
|
-
)
|
|
252
|
-
|
|
253
|
-
# Get saving infos in order to save tiles when they are computed
|
|
254
|
-
[saving_info] = self.orchestrator.get_saving_infos(
|
|
255
|
-
[new_epipolar_disparity_map]
|
|
256
|
-
)
|
|
257
|
-
|
|
258
|
-
# Add infos to orchestrator.out_json
|
|
259
|
-
updating_dict = {
|
|
260
|
-
application_constants.APPLICATION_TAG: {
|
|
261
|
-
fd_cst.FILL_DISP_WITH_PLAN_RUN_TAG: {
|
|
262
|
-
pair_key: {},
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
self.orchestrator.update_out_info(updating_dict)
|
|
267
|
-
logging.info(
|
|
268
|
-
"Fill missing disparity with plan model"
|
|
269
|
-
": number tiles: {}".format(
|
|
270
|
-
epipolar_disparity_map.shape[1]
|
|
271
|
-
* epipolar_disparity_map.shape[0]
|
|
272
|
-
)
|
|
273
|
-
)
|
|
274
|
-
|
|
275
|
-
# get all polygones
|
|
276
|
-
poly_list_left = fd_wrappers.get_polygons_from_cars_ds(
|
|
277
|
-
holes_bbox_left
|
|
278
|
-
)
|
|
279
|
-
poly_list_right = fd_wrappers.get_polygons_from_cars_ds(
|
|
280
|
-
holes_bbox_right
|
|
281
|
-
)
|
|
282
|
-
|
|
283
|
-
# Estimate right poly on left
|
|
284
|
-
# using disparity range
|
|
285
|
-
poly_list_right_on_left = [
|
|
286
|
-
fd_wrappers.estimate_poly_with_disp(
|
|
287
|
-
p, dmin=-disp_max, dmax=-disp_min
|
|
288
|
-
)
|
|
289
|
-
for p in poly_list_right
|
|
290
|
-
]
|
|
291
|
-
|
|
292
|
-
# Merge polygones
|
|
293
|
-
merged_poly_list = fd_wrappers.merge_intersecting_polygones(
|
|
294
|
-
poly_list_left + poly_list_right_on_left
|
|
295
|
-
)
|
|
296
|
-
|
|
297
|
-
logging.info(
|
|
298
|
-
"Disparity filling: {} holes on"
|
|
299
|
-
" left to fill".format(len(merged_poly_list))
|
|
300
|
-
)
|
|
301
|
-
|
|
302
|
-
# Generate polygones for tiles
|
|
303
|
-
tiles_polygones = {}
|
|
304
|
-
for col in range(epipolar_disparity_map.shape[1]):
|
|
305
|
-
for row in range(epipolar_disparity_map.shape[0]):
|
|
306
|
-
tile = epipolar_disparity_map.tiling_grid[row, col]
|
|
307
|
-
tiles_polygones[(row, col)] = Polygon(
|
|
308
|
-
[
|
|
309
|
-
[tile[0], tile[2]],
|
|
310
|
-
[tile[0], tile[3]],
|
|
311
|
-
[tile[1], tile[3]],
|
|
312
|
-
[tile[1], tile[2]],
|
|
313
|
-
[tile[0], tile[2]],
|
|
314
|
-
]
|
|
315
|
-
)
|
|
316
|
-
|
|
317
|
-
# Generate disparity maps
|
|
318
|
-
for col in range(epipolar_disparity_map.shape[1]):
|
|
319
|
-
for row in range(epipolar_disparity_map.shape[0]):
|
|
320
|
-
if epipolar_disparity_map[row, col] is not None:
|
|
321
|
-
tile_poly = tiles_polygones[(row, col)]
|
|
322
|
-
# Get intersecting holes poly
|
|
323
|
-
corresponding_holes = (
|
|
324
|
-
fd_wrappers.get_corresponding_holes(
|
|
325
|
-
tile_poly, merged_poly_list
|
|
326
|
-
)
|
|
327
|
-
)
|
|
328
|
-
|
|
329
|
-
# Get corresponding_tiles
|
|
330
|
-
# list of (tile_window, tile overlap, xr.Dataset)
|
|
331
|
-
corresponding_tiles = (
|
|
332
|
-
fd_wrappers.get_corresponding_tiles(
|
|
333
|
-
tiles_polygones,
|
|
334
|
-
corresponding_holes,
|
|
335
|
-
epipolar_disparity_map,
|
|
336
|
-
)
|
|
337
|
-
)
|
|
338
|
-
|
|
339
|
-
# get tile window and overlap
|
|
340
|
-
window = new_epipolar_disparity_map.tiling_grid[
|
|
341
|
-
row, col
|
|
342
|
-
]
|
|
343
|
-
overlap = new_epipolar_disparity_map.overlaps[
|
|
344
|
-
row, col
|
|
345
|
-
]
|
|
346
|
-
|
|
347
|
-
# update saving infos for potential replacement
|
|
348
|
-
full_saving_info = ocht.update_saving_infos(
|
|
349
|
-
saving_info, row=row, col=col
|
|
350
|
-
)
|
|
351
|
-
|
|
352
|
-
if len(corresponding_tiles) == 0:
|
|
353
|
-
# copy dataset
|
|
354
|
-
(
|
|
355
|
-
new_epipolar_disparity_map[row, col]
|
|
356
|
-
) = self.orchestrator.cluster.create_task(
|
|
357
|
-
wrapper_copy_disparity
|
|
358
|
-
)(
|
|
359
|
-
epipolar_disparity_map[row, col],
|
|
360
|
-
window,
|
|
361
|
-
overlap,
|
|
362
|
-
saving_info=full_saving_info,
|
|
363
|
-
)
|
|
364
|
-
|
|
365
|
-
else:
|
|
366
|
-
# Fill holes
|
|
367
|
-
(
|
|
368
|
-
new_epipolar_disparity_map[row, col]
|
|
369
|
-
) = self.orchestrator.cluster.create_task(
|
|
370
|
-
fill_disparity_plane_wrapper
|
|
371
|
-
)(
|
|
372
|
-
corresponding_tiles,
|
|
373
|
-
corresponding_holes,
|
|
374
|
-
window,
|
|
375
|
-
overlap,
|
|
376
|
-
self.classification,
|
|
377
|
-
ignore_nodata_at_disp_mask_borders=(
|
|
378
|
-
self.ignore_nodata_at_disp_mask_borders
|
|
379
|
-
),
|
|
380
|
-
ignore_zero_fill_disp_mask_values=(
|
|
381
|
-
self.ignore_zero_fill_disp_mask_values
|
|
382
|
-
),
|
|
383
|
-
ignore_extrema_disp_values=(
|
|
384
|
-
self.ignore_extrema_disp_values
|
|
385
|
-
),
|
|
386
|
-
nb_pix=self.nb_pix,
|
|
387
|
-
percent_to_erode=self.percent_to_erode,
|
|
388
|
-
interp_options=interp_options,
|
|
389
|
-
fill_valid_pixels=self.fill_valid_pixels,
|
|
390
|
-
saving_info=full_saving_info,
|
|
391
|
-
)
|
|
392
|
-
|
|
393
|
-
res = new_epipolar_disparity_map
|
|
394
|
-
|
|
395
|
-
else:
|
|
396
|
-
logging.error(
|
|
397
|
-
"FillDisp application doesn't support "
|
|
398
|
-
"this input data format"
|
|
399
|
-
)
|
|
400
|
-
return res
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
def fill_disparity_plane_wrapper(
|
|
404
|
-
corresponding_tiles,
|
|
405
|
-
corresponding_poly,
|
|
406
|
-
window,
|
|
407
|
-
overlap,
|
|
408
|
-
classification,
|
|
409
|
-
ignore_nodata_at_disp_mask_borders=True,
|
|
410
|
-
ignore_zero_fill_disp_mask_values=True,
|
|
411
|
-
ignore_extrema_disp_values=True,
|
|
412
|
-
nb_pix=20,
|
|
413
|
-
percent_to_erode=0.3,
|
|
414
|
-
interp_options=None,
|
|
415
|
-
fill_valid_pixels=True,
|
|
416
|
-
saving_info=None,
|
|
417
|
-
):
|
|
418
|
-
"""
|
|
419
|
-
Wrapper to Fill disparity map holes
|
|
420
|
-
|
|
421
|
-
:param corresponding_tiles: disparity map tiles
|
|
422
|
-
:type corresponding_tiles: list(tuple(list, list, xr.Dataset))
|
|
423
|
-
:param corresponding_poly: holes polygons
|
|
424
|
-
:type corresponding_poly: list(Polygon)
|
|
425
|
-
:param window: window of base tile [row min, row max, col min col max]
|
|
426
|
-
:type window: list
|
|
427
|
-
:param overlap: overlap [row min, row max, col min col max]
|
|
428
|
-
:type overlap: list
|
|
429
|
-
:param left_epi_image: left epipolar image
|
|
430
|
-
:type left_epi_image: xr.Dataset
|
|
431
|
-
:param classification: list of tag to use
|
|
432
|
-
:type classification: list(str)
|
|
433
|
-
:param ignore_nodata_at_disp_mask_borders: ingore nodata
|
|
434
|
-
:type ignore_nodata_at_disp_mask_borders: bool
|
|
435
|
-
:param ignore_zero_fill_disp_mask_values: ingnore zero fill
|
|
436
|
-
:type ignore_zero_fill_disp_mask_values: bool
|
|
437
|
-
:param ignore_extrema_disp_values: ignore extrema
|
|
438
|
-
:type ignore_extrema_disp_values: bool
|
|
439
|
-
:param nb_pix: margin to use
|
|
440
|
-
:type nb_pix: int
|
|
441
|
-
:param percent_to_erode: percent to erode
|
|
442
|
-
:type percent_to_erode: float
|
|
443
|
-
:param interp_options: interp_options
|
|
444
|
-
:type interp_options: dict
|
|
445
|
-
:param fill_valid_pixels: option to fill valid pixels
|
|
446
|
-
:type fill_valid_pixels: bool
|
|
447
|
-
:param saving_info: saving infos
|
|
448
|
-
:type saving_info: dict
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
:return: disp map
|
|
452
|
-
:rtype: xr.Dataset
|
|
453
|
-
"""
|
|
454
|
-
|
|
455
|
-
# Create combined xarray Dataset
|
|
456
|
-
(
|
|
457
|
-
combined_dataset,
|
|
458
|
-
row_min,
|
|
459
|
-
col_min,
|
|
460
|
-
) = corresponding_tiles_tools.reconstruct_data(
|
|
461
|
-
corresponding_tiles, window, overlap
|
|
462
|
-
)
|
|
463
|
-
|
|
464
|
-
# Add a band to disparity dataset to memorize which pixels are filled
|
|
465
|
-
combined_dataset = fd_wrappers.add_empty_filling_band(
|
|
466
|
-
combined_dataset, ["plane.hole_center", "plane.hole_border"]
|
|
467
|
-
)
|
|
468
|
-
|
|
469
|
-
# Fill disparity
|
|
470
|
-
fd_algo.fill_disp_using_plane(
|
|
471
|
-
combined_dataset,
|
|
472
|
-
corresponding_poly,
|
|
473
|
-
row_min,
|
|
474
|
-
col_min,
|
|
475
|
-
ignore_nodata_at_disp_mask_borders,
|
|
476
|
-
ignore_zero_fill_disp_mask_values,
|
|
477
|
-
ignore_extrema_disp_values,
|
|
478
|
-
nb_pix,
|
|
479
|
-
percent_to_erode,
|
|
480
|
-
interp_options,
|
|
481
|
-
classification,
|
|
482
|
-
fill_valid_pixels,
|
|
483
|
-
)
|
|
484
|
-
|
|
485
|
-
# Find xarray Dataset corresponding to current tile
|
|
486
|
-
input_disp = copy.deepcopy(
|
|
487
|
-
corresponding_tiles_tools.find_tile_dataset(corresponding_tiles, window)
|
|
488
|
-
)
|
|
489
|
-
|
|
490
|
-
# Add additional attribute "filling" to dataset template
|
|
491
|
-
input_disp[cst.EPI_FILLING] = combined_dataset[cst.EPI_FILLING]
|
|
492
|
-
|
|
493
|
-
# Crop Dataset to get tile disparity
|
|
494
|
-
cropped_disp = corresponding_tiles_tools.crop_dataset(
|
|
495
|
-
combined_dataset,
|
|
496
|
-
input_disp,
|
|
497
|
-
window,
|
|
498
|
-
overlap,
|
|
499
|
-
row_min,
|
|
500
|
-
col_min,
|
|
501
|
-
)
|
|
502
|
-
|
|
503
|
-
# Fill with attributes
|
|
504
|
-
cars_dataset.fill_dataset(
|
|
505
|
-
cropped_disp,
|
|
506
|
-
saving_info=saving_info,
|
|
507
|
-
window=cars_dataset.window_array_to_dict(window),
|
|
508
|
-
profile=None,
|
|
509
|
-
attributes=None,
|
|
510
|
-
overlaps=cars_dataset.overlap_array_to_dict(overlap),
|
|
511
|
-
)
|
|
512
|
-
|
|
513
|
-
return cropped_disp
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
def wrapper_copy_disparity(
|
|
517
|
-
disp,
|
|
518
|
-
window,
|
|
519
|
-
overlap,
|
|
520
|
-
saving_info=None,
|
|
521
|
-
):
|
|
522
|
-
"""
|
|
523
|
-
Wrapper to copy previous disparity with additional filling band with zeros
|
|
524
|
-
|
|
525
|
-
:param disp: disparity map
|
|
526
|
-
:type disp: xr.Dataset
|
|
527
|
-
:param window: window of base tile [row min, row max, col min col max]
|
|
528
|
-
:type window: list
|
|
529
|
-
:param overlap: overlap [row min, row max, col min col max]
|
|
530
|
-
:type overlap: list
|
|
531
|
-
:param saving_info: saving infos
|
|
532
|
-
:type saving_info: dict
|
|
533
|
-
|
|
534
|
-
:return: disp map
|
|
535
|
-
:rtype: xr.Dataset
|
|
536
|
-
"""
|
|
537
|
-
# Fill band named filling with zeros
|
|
538
|
-
res = fd_wrappers.add_empty_filling_band(
|
|
539
|
-
disp, ["plane.hole_center", "plane.hole_border"]
|
|
540
|
-
)
|
|
541
|
-
|
|
542
|
-
attributes = {
|
|
543
|
-
cst.CROPPED_DISPARITY_RANGE: (ocht.get_disparity_range_cropped(disp))
|
|
544
|
-
}
|
|
545
|
-
|
|
546
|
-
# Fill with attributes
|
|
547
|
-
cars_dataset.fill_dataset(
|
|
548
|
-
res,
|
|
549
|
-
saving_info=saving_info,
|
|
550
|
-
window=cars_dataset.window_array_to_dict(window),
|
|
551
|
-
profile=None,
|
|
552
|
-
attributes=attributes,
|
|
553
|
-
overlaps=cars_dataset.overlap_array_to_dict(overlap),
|
|
554
|
-
)
|
|
555
|
-
|
|
556
|
-
return res
|