cars 1.0.0rc2__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 +86 -0
- cars/applications/__init__.py +40 -0
- cars/applications/application.py +117 -0
- cars/applications/application_constants.py +29 -0
- cars/applications/application_template.py +146 -0
- cars/applications/auxiliary_filling/__init__.py +29 -0
- cars/applications/auxiliary_filling/abstract_auxiliary_filling_app.py +105 -0
- cars/applications/auxiliary_filling/auxiliary_filling_algo.py +475 -0
- cars/applications/auxiliary_filling/auxiliary_filling_from_sensors_app.py +632 -0
- cars/applications/auxiliary_filling/auxiliary_filling_wrappers.py +90 -0
- cars/applications/dem_generation/__init__.py +30 -0
- cars/applications/dem_generation/abstract_dem_generation_app.py +116 -0
- cars/applications/dem_generation/bulldozer_config/base_config.yaml +42 -0
- cars/applications/dem_generation/bulldozer_dem_app.py +641 -0
- cars/applications/dem_generation/bulldozer_memory.py +55 -0
- cars/applications/dem_generation/dem_generation_algo.py +107 -0
- cars/applications/dem_generation/dem_generation_constants.py +32 -0
- cars/applications/dem_generation/dem_generation_wrappers.py +323 -0
- cars/applications/dense_match_filling/__init__.py +30 -0
- cars/applications/dense_match_filling/abstract_dense_match_filling_app.py +242 -0
- cars/applications/dense_match_filling/fill_disp_algo.py +113 -0
- cars/applications/dense_match_filling/fill_disp_constants.py +39 -0
- cars/applications/dense_match_filling/fill_disp_wrappers.py +83 -0
- cars/applications/dense_match_filling/zero_padding_app.py +302 -0
- cars/applications/dense_matching/__init__.py +30 -0
- cars/applications/dense_matching/abstract_dense_matching_app.py +261 -0
- cars/applications/dense_matching/census_mccnn_sgm_app.py +1461 -0
- cars/applications/dense_matching/cpp/__init__.py +0 -0
- 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/cpp/dense_matching_cpp.py +94 -0
- cars/applications/dense_matching/cpp/includes/dense_matching.hpp +58 -0
- cars/applications/dense_matching/cpp/meson.build +9 -0
- cars/applications/dense_matching/cpp/src/bindings.cpp +13 -0
- cars/applications/dense_matching/cpp/src/dense_matching.cpp +207 -0
- cars/applications/dense_matching/dense_matching_algo.py +401 -0
- cars/applications/dense_matching/dense_matching_constants.py +89 -0
- cars/applications/dense_matching/dense_matching_wrappers.py +951 -0
- cars/applications/dense_matching/disparity_grid_algo.py +597 -0
- cars/applications/dense_matching/loaders/__init__.py +23 -0
- cars/applications/dense_matching/loaders/config_census_sgm_default.json +31 -0
- cars/applications/dense_matching/loaders/config_census_sgm_homogeneous.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_mountain_and_vegetation.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_shadow.json +30 -0
- cars/applications/dense_matching/loaders/config_census_sgm_sparse.json +36 -0
- cars/applications/dense_matching/loaders/config_census_sgm_urban.json +30 -0
- cars/applications/dense_matching/loaders/config_mapping.json +13 -0
- cars/applications/dense_matching/loaders/config_mccnn.json +28 -0
- cars/applications/dense_matching/loaders/global_land_cover_map.tif +0 -0
- cars/applications/dense_matching/loaders/pandora_loader.py +593 -0
- cars/applications/dsm_filling/__init__.py +32 -0
- cars/applications/dsm_filling/abstract_dsm_filling_app.py +101 -0
- cars/applications/dsm_filling/border_interpolation_app.py +278 -0
- cars/applications/dsm_filling/bulldozer_config/base_config.yaml +44 -0
- cars/applications/dsm_filling/bulldozer_filling_app.py +288 -0
- cars/applications/dsm_filling/exogenous_filling_app.py +341 -0
- cars/applications/dsm_merging/__init__.py +28 -0
- cars/applications/dsm_merging/abstract_dsm_merging_app.py +101 -0
- cars/applications/dsm_merging/weighted_fusion_app.py +639 -0
- cars/applications/grid_correction/__init__.py +30 -0
- cars/applications/grid_correction/abstract_grid_correction_app.py +103 -0
- cars/applications/grid_correction/grid_correction_app.py +557 -0
- cars/applications/grid_generation/__init__.py +30 -0
- cars/applications/grid_generation/abstract_grid_generation_app.py +142 -0
- cars/applications/grid_generation/epipolar_grid_generation_app.py +327 -0
- cars/applications/grid_generation/grid_generation_algo.py +388 -0
- cars/applications/grid_generation/grid_generation_constants.py +46 -0
- cars/applications/grid_generation/transform_grid.py +88 -0
- cars/applications/ground_truth_reprojection/__init__.py +30 -0
- cars/applications/ground_truth_reprojection/abstract_ground_truth_reprojection_app.py +137 -0
- cars/applications/ground_truth_reprojection/direct_localization_app.py +629 -0
- cars/applications/ground_truth_reprojection/ground_truth_reprojection_algo.py +275 -0
- cars/applications/point_cloud_outlier_removal/__init__.py +30 -0
- cars/applications/point_cloud_outlier_removal/abstract_outlier_removal_app.py +385 -0
- cars/applications/point_cloud_outlier_removal/outlier_removal_algo.py +392 -0
- cars/applications/point_cloud_outlier_removal/outlier_removal_constants.py +43 -0
- cars/applications/point_cloud_outlier_removal/small_components_app.py +522 -0
- cars/applications/point_cloud_outlier_removal/statistical_app.py +528 -0
- cars/applications/rasterization/__init__.py +30 -0
- cars/applications/rasterization/abstract_pc_rasterization_app.py +183 -0
- cars/applications/rasterization/rasterization_algo.py +534 -0
- cars/applications/rasterization/rasterization_constants.py +38 -0
- cars/applications/rasterization/rasterization_wrappers.py +639 -0
- cars/applications/rasterization/simple_gaussian_app.py +1152 -0
- cars/applications/resampling/__init__.py +28 -0
- cars/applications/resampling/abstract_resampling_app.py +187 -0
- cars/applications/resampling/bicubic_resampling_app.py +760 -0
- cars/applications/resampling/resampling_algo.py +590 -0
- cars/applications/resampling/resampling_constants.py +36 -0
- cars/applications/resampling/resampling_wrappers.py +309 -0
- cars/applications/sensors_subsampling/__init__.py +32 -0
- cars/applications/sensors_subsampling/abstract_subsampling_app.py +109 -0
- cars/applications/sensors_subsampling/rasterio_subsampling_app.py +420 -0
- cars/applications/sensors_subsampling/subsampling_algo.py +108 -0
- cars/applications/sparse_matching/__init__.py +30 -0
- cars/applications/sparse_matching/abstract_sparse_matching_app.py +599 -0
- cars/applications/sparse_matching/sift_app.py +724 -0
- cars/applications/sparse_matching/sparse_matching_algo.py +360 -0
- cars/applications/sparse_matching/sparse_matching_constants.py +66 -0
- cars/applications/sparse_matching/sparse_matching_wrappers.py +282 -0
- cars/applications/triangulation/__init__.py +32 -0
- cars/applications/triangulation/abstract_triangulation_app.py +227 -0
- cars/applications/triangulation/line_of_sight_intersection_app.py +1243 -0
- cars/applications/triangulation/pc_transform.py +552 -0
- cars/applications/triangulation/triangulation_algo.py +371 -0
- cars/applications/triangulation/triangulation_constants.py +38 -0
- cars/applications/triangulation/triangulation_wrappers.py +259 -0
- cars/bundleadjustment.py +750 -0
- cars/cars.py +179 -0
- cars/conf/__init__.py +23 -0
- cars/conf/geoid/egm96.grd +0 -0
- cars/conf/geoid/egm96.grd.hdr +15 -0
- cars/conf/input_parameters.py +156 -0
- cars/conf/mask_cst.py +35 -0
- cars/core/__init__.py +23 -0
- cars/core/cars_logging.py +402 -0
- cars/core/constants.py +191 -0
- cars/core/constants_disparity.py +50 -0
- cars/core/datasets.py +140 -0
- cars/core/geometry/__init__.py +27 -0
- cars/core/geometry/abstract_geometry.py +1119 -0
- cars/core/geometry/shareloc_geometry.py +598 -0
- cars/core/inputs.py +568 -0
- cars/core/outputs.py +176 -0
- cars/core/preprocessing.py +722 -0
- cars/core/projection.py +843 -0
- cars/core/roi_tools.py +215 -0
- cars/core/tiling.py +774 -0
- cars/core/utils.py +164 -0
- cars/data_structures/__init__.py +23 -0
- cars/data_structures/cars_dataset.py +1544 -0
- cars/data_structures/cars_dict.py +74 -0
- cars/data_structures/corresponding_tiles_tools.py +186 -0
- cars/data_structures/dataframe_converter.py +185 -0
- cars/data_structures/format_transformation.py +297 -0
- cars/devibrate.py +689 -0
- cars/extractroi.py +264 -0
- cars/orchestrator/__init__.py +23 -0
- cars/orchestrator/achievement_tracker.py +125 -0
- cars/orchestrator/cluster/__init__.py +37 -0
- cars/orchestrator/cluster/abstract_cluster.py +250 -0
- cars/orchestrator/cluster/abstract_dask_cluster.py +381 -0
- cars/orchestrator/cluster/dask_cluster_tools.py +103 -0
- cars/orchestrator/cluster/dask_config/README.md +94 -0
- cars/orchestrator/cluster/dask_config/dask.yaml +21 -0
- cars/orchestrator/cluster/dask_config/distributed.yaml +70 -0
- cars/orchestrator/cluster/dask_config/jobqueue.yaml +26 -0
- cars/orchestrator/cluster/dask_config/reference_confs/dask-schema.yaml +137 -0
- cars/orchestrator/cluster/dask_config/reference_confs/dask.yaml +26 -0
- cars/orchestrator/cluster/dask_config/reference_confs/distributed-schema.yaml +1009 -0
- cars/orchestrator/cluster/dask_config/reference_confs/distributed.yaml +273 -0
- cars/orchestrator/cluster/dask_config/reference_confs/jobqueue.yaml +212 -0
- cars/orchestrator/cluster/dask_jobqueue_utils.py +204 -0
- cars/orchestrator/cluster/local_dask_cluster.py +116 -0
- cars/orchestrator/cluster/log_wrapper.py +728 -0
- cars/orchestrator/cluster/mp_cluster/__init__.py +27 -0
- cars/orchestrator/cluster/mp_cluster/mp_factorizer.py +212 -0
- cars/orchestrator/cluster/mp_cluster/mp_objects.py +535 -0
- cars/orchestrator/cluster/mp_cluster/mp_tools.py +93 -0
- cars/orchestrator/cluster/mp_cluster/mp_wrapper.py +505 -0
- cars/orchestrator/cluster/mp_cluster/multiprocessing_cluster.py +986 -0
- cars/orchestrator/cluster/mp_cluster/multiprocessing_profiler.py +399 -0
- cars/orchestrator/cluster/pbs_dask_cluster.py +207 -0
- cars/orchestrator/cluster/sequential_cluster.py +139 -0
- cars/orchestrator/cluster/slurm_dask_cluster.py +234 -0
- cars/orchestrator/memory_tools.py +47 -0
- cars/orchestrator/orchestrator.py +755 -0
- cars/orchestrator/orchestrator_constants.py +29 -0
- cars/orchestrator/registry/__init__.py +23 -0
- cars/orchestrator/registry/abstract_registry.py +143 -0
- cars/orchestrator/registry/compute_registry.py +106 -0
- cars/orchestrator/registry/id_generator.py +116 -0
- cars/orchestrator/registry/replacer_registry.py +213 -0
- cars/orchestrator/registry/saver_registry.py +363 -0
- cars/orchestrator/registry/unseen_registry.py +118 -0
- cars/orchestrator/tiles_profiler.py +279 -0
- cars/pipelines/__init__.py +26 -0
- cars/pipelines/conf_resolution/conf_final_resolution.yaml +5 -0
- cars/pipelines/conf_resolution/conf_first_resolution.yaml +4 -0
- cars/pipelines/conf_resolution/conf_intermediate_resolution.yaml +2 -0
- cars/pipelines/default/__init__.py +26 -0
- cars/pipelines/default/default_pipeline.py +1088 -0
- cars/pipelines/filling/__init__.py +26 -0
- cars/pipelines/filling/filling.py +981 -0
- cars/pipelines/formatting/__init__.py +26 -0
- cars/pipelines/formatting/formatting.py +186 -0
- cars/pipelines/merging/__init__.py +26 -0
- cars/pipelines/merging/merging.py +439 -0
- cars/pipelines/parameters/__init__.py +0 -0
- cars/pipelines/parameters/advanced_parameters.py +256 -0
- cars/pipelines/parameters/advanced_parameters_constants.py +68 -0
- cars/pipelines/parameters/application_parameters.py +72 -0
- cars/pipelines/parameters/depth_map_inputs.py +0 -0
- cars/pipelines/parameters/dsm_inputs.py +349 -0
- cars/pipelines/parameters/dsm_inputs_constants.py +25 -0
- cars/pipelines/parameters/output_constants.py +52 -0
- cars/pipelines/parameters/output_parameters.py +438 -0
- cars/pipelines/parameters/sensor_inputs.py +859 -0
- cars/pipelines/parameters/sensor_inputs_constants.py +51 -0
- cars/pipelines/parameters/sensor_loaders/__init__.py +29 -0
- cars/pipelines/parameters/sensor_loaders/basic_classif_loader.py +86 -0
- cars/pipelines/parameters/sensor_loaders/basic_image_loader.py +98 -0
- cars/pipelines/parameters/sensor_loaders/pivot_classif_loader.py +90 -0
- cars/pipelines/parameters/sensor_loaders/pivot_image_loader.py +105 -0
- cars/pipelines/parameters/sensor_loaders/sensor_loader.py +93 -0
- cars/pipelines/parameters/sensor_loaders/sensor_loader_template.py +71 -0
- cars/pipelines/parameters/sensor_loaders/slurp_classif_loader.py +86 -0
- cars/pipelines/pipeline.py +119 -0
- cars/pipelines/pipeline_constants.py +38 -0
- cars/pipelines/pipeline_template.py +135 -0
- cars/pipelines/subsampling/__init__.py +26 -0
- cars/pipelines/subsampling/subsampling.py +358 -0
- cars/pipelines/surface_modeling/__init__.py +26 -0
- cars/pipelines/surface_modeling/surface_modeling.py +2098 -0
- cars/pipelines/tie_points/__init__.py +26 -0
- cars/pipelines/tie_points/tie_points.py +536 -0
- cars/starter.py +167 -0
- cars-1.0.0rc2.dist-info/DELVEWHEEL +2 -0
- cars-1.0.0rc2.dist-info/METADATA +289 -0
- cars-1.0.0rc2.dist-info/RECORD +225 -0
- cars-1.0.0rc2.dist-info/WHEEL +4 -0
- cars-1.0.0rc2.dist-info/entry_points.txt +8 -0
- 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
|
@@ -0,0 +1,302 @@
|
|
|
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
|
+
# Standard imports
|
|
27
|
+
import copy
|
|
28
|
+
import logging
|
|
29
|
+
|
|
30
|
+
# Third party imports
|
|
31
|
+
from json_checker import Checker, Or
|
|
32
|
+
|
|
33
|
+
# CARS imports
|
|
34
|
+
import cars.orchestrator.orchestrator as ocht
|
|
35
|
+
from cars.applications import application_constants
|
|
36
|
+
from cars.applications.dense_match_filling import (
|
|
37
|
+
abstract_dense_match_filling_app as abstract_dense_match_fill,
|
|
38
|
+
)
|
|
39
|
+
from cars.applications.dense_match_filling import fill_disp_algo as fd_algo
|
|
40
|
+
from cars.applications.dense_match_filling import fill_disp_constants as fd_cst
|
|
41
|
+
from cars.applications.dense_match_filling import (
|
|
42
|
+
fill_disp_wrappers as fd_wrappers,
|
|
43
|
+
)
|
|
44
|
+
from cars.core import constants as cst
|
|
45
|
+
from cars.data_structures import cars_dataset
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
class ZerosPadding(
|
|
49
|
+
abstract_dense_match_fill.DenseMatchFilling, short_name=["zero_padding"]
|
|
50
|
+
): # pylint: disable=R0903
|
|
51
|
+
"""
|
|
52
|
+
Fill invalid area in disparity map with zeros values
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
# pylint: disable=too-many-instance-attributes
|
|
56
|
+
|
|
57
|
+
def __init__(self, conf=None):
|
|
58
|
+
"""
|
|
59
|
+
Init function of FillDisp
|
|
60
|
+
|
|
61
|
+
:param conf: configuration for filling
|
|
62
|
+
:return: a application_to_use object
|
|
63
|
+
"""
|
|
64
|
+
|
|
65
|
+
super().__init__(conf=conf)
|
|
66
|
+
|
|
67
|
+
# get conf
|
|
68
|
+
self.used_method = self.used_config["method"]
|
|
69
|
+
self.classification = self.used_config["classification"]
|
|
70
|
+
self.fill_valid_pixels = self.used_config["fill_valid_pixels"]
|
|
71
|
+
|
|
72
|
+
# Saving files
|
|
73
|
+
self.save_intermediate_data = self.used_config["save_intermediate_data"]
|
|
74
|
+
|
|
75
|
+
def check_conf(self, conf):
|
|
76
|
+
"""
|
|
77
|
+
Check configuration
|
|
78
|
+
|
|
79
|
+
:param conf: configuration to check
|
|
80
|
+
:type conf: dict
|
|
81
|
+
:return: overloaded configuration
|
|
82
|
+
:rtype: dict
|
|
83
|
+
|
|
84
|
+
"""
|
|
85
|
+
|
|
86
|
+
# init conf
|
|
87
|
+
if conf is not None:
|
|
88
|
+
overloaded_conf = conf.copy()
|
|
89
|
+
else:
|
|
90
|
+
conf = {}
|
|
91
|
+
overloaded_conf = {}
|
|
92
|
+
|
|
93
|
+
# Overload conf
|
|
94
|
+
overloaded_conf["method"] = conf.get("method", "zero_padding")
|
|
95
|
+
|
|
96
|
+
overloaded_conf["classification"] = conf.get("classification", None)
|
|
97
|
+
if isinstance(overloaded_conf["classification"], str):
|
|
98
|
+
overloaded_conf["classification"] = [
|
|
99
|
+
overloaded_conf["classification"]
|
|
100
|
+
]
|
|
101
|
+
overloaded_conf["fill_valid_pixels"] = conf.get(
|
|
102
|
+
"fill_valid_pixels", True
|
|
103
|
+
)
|
|
104
|
+
# Saving files
|
|
105
|
+
overloaded_conf["save_intermediate_data"] = conf.get(
|
|
106
|
+
"save_intermediate_data", False
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
application_schema = {
|
|
110
|
+
"method": str,
|
|
111
|
+
"save_intermediate_data": bool,
|
|
112
|
+
"classification": Or(None, [str]),
|
|
113
|
+
"fill_valid_pixels": bool,
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Check conf
|
|
117
|
+
checker = Checker(application_schema)
|
|
118
|
+
checker.validate(overloaded_conf)
|
|
119
|
+
|
|
120
|
+
return overloaded_conf
|
|
121
|
+
|
|
122
|
+
def get_poly_margin(self):
|
|
123
|
+
"""
|
|
124
|
+
Get the margin used for polygon
|
|
125
|
+
|
|
126
|
+
:return: self.nb_pix
|
|
127
|
+
:rtype: int
|
|
128
|
+
"""
|
|
129
|
+
|
|
130
|
+
return 0
|
|
131
|
+
|
|
132
|
+
def run(
|
|
133
|
+
self,
|
|
134
|
+
epipolar_disparity_map,
|
|
135
|
+
orchestrator=None,
|
|
136
|
+
pair_folder=None,
|
|
137
|
+
pair_key="PAIR_0",
|
|
138
|
+
):
|
|
139
|
+
"""
|
|
140
|
+
Run Refill application using zero_padding method.
|
|
141
|
+
|
|
142
|
+
:param epipolar_disparity_map: left to right disparity
|
|
143
|
+
:type epipolar_disparity_map: CarsDataset
|
|
144
|
+
:param orchestrator: orchestrator used
|
|
145
|
+
:param pair_folder: folder used for current pair
|
|
146
|
+
:type pair_folder: str
|
|
147
|
+
:param pair_key: pair id
|
|
148
|
+
:type pair_key: str
|
|
149
|
+
|
|
150
|
+
:return: filled disparity map: \
|
|
151
|
+
The CarsDataset contains:
|
|
152
|
+
|
|
153
|
+
- N x M Delayed tiles.\
|
|
154
|
+
Each tile will be a future xarray Dataset containing:
|
|
155
|
+
- data with keys : "disp", "disp_msk"
|
|
156
|
+
- attrs with keys: profile, window, overlaps
|
|
157
|
+
- attributes containing:
|
|
158
|
+
"largest_epipolar_region","opt_epipolar_tile_size",
|
|
159
|
+
"epipolar_regions_grid"
|
|
160
|
+
|
|
161
|
+
:rtype: CarsDataset
|
|
162
|
+
|
|
163
|
+
"""
|
|
164
|
+
res = None
|
|
165
|
+
|
|
166
|
+
if not self.classification:
|
|
167
|
+
logging.info("Disparity holes filling was not activated")
|
|
168
|
+
res = epipolar_disparity_map
|
|
169
|
+
|
|
170
|
+
else:
|
|
171
|
+
# Default orchestrator
|
|
172
|
+
if orchestrator is None:
|
|
173
|
+
# Create defaut sequential orchestrator for current application
|
|
174
|
+
# be awere, no out_json will be shared between orchestrators
|
|
175
|
+
# No files saved
|
|
176
|
+
self.orchestrator = ocht.Orchestrator(
|
|
177
|
+
orchestrator_conf={"mode": "sequential"}
|
|
178
|
+
)
|
|
179
|
+
else:
|
|
180
|
+
self.orchestrator = orchestrator
|
|
181
|
+
|
|
182
|
+
if epipolar_disparity_map.dataset_type == "arrays":
|
|
183
|
+
# Create CarsDataset Epipolar_disparity
|
|
184
|
+
# Save Disparity map
|
|
185
|
+
(new_epipolar_disparity_map) = self.__register_dataset__(
|
|
186
|
+
epipolar_disparity_map,
|
|
187
|
+
self.save_intermediate_data,
|
|
188
|
+
pair_folder,
|
|
189
|
+
pair_key,
|
|
190
|
+
app_name="zero_padding",
|
|
191
|
+
nodata_epi_disp=-9999,
|
|
192
|
+
)
|
|
193
|
+
|
|
194
|
+
# Get saving infos in order to save tiles when they are computed
|
|
195
|
+
[
|
|
196
|
+
saving_info,
|
|
197
|
+
] = self.orchestrator.get_saving_infos(
|
|
198
|
+
[new_epipolar_disparity_map]
|
|
199
|
+
)
|
|
200
|
+
# Add infos to orchestrator.out_json
|
|
201
|
+
updating_dict = {
|
|
202
|
+
application_constants.APPLICATION_TAG: {
|
|
203
|
+
fd_cst.FILL_DISP_WITH_ZEROS_RUN_TAG: {
|
|
204
|
+
pair_key: {},
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
self.orchestrator.update_out_info(updating_dict)
|
|
209
|
+
logging.info(
|
|
210
|
+
"Fill missing disparities with zeros values"
|
|
211
|
+
": number tiles: {}".format(
|
|
212
|
+
epipolar_disparity_map.shape[1]
|
|
213
|
+
* epipolar_disparity_map.shape[0]
|
|
214
|
+
)
|
|
215
|
+
)
|
|
216
|
+
# Generate disparity maps
|
|
217
|
+
for col in range(epipolar_disparity_map.shape[1]):
|
|
218
|
+
for row in range(epipolar_disparity_map.shape[0]):
|
|
219
|
+
if epipolar_disparity_map[row, col] is not None:
|
|
220
|
+
# get tile window and overlap
|
|
221
|
+
window = new_epipolar_disparity_map.tiling_grid[
|
|
222
|
+
row, col
|
|
223
|
+
]
|
|
224
|
+
overlap = new_epipolar_disparity_map.overlaps[
|
|
225
|
+
row, col
|
|
226
|
+
]
|
|
227
|
+
# update saving infos for potential replacement
|
|
228
|
+
full_saving_info = ocht.update_saving_infos(
|
|
229
|
+
saving_info, row=row, col=col
|
|
230
|
+
)
|
|
231
|
+
|
|
232
|
+
# copy dataset
|
|
233
|
+
(
|
|
234
|
+
new_epipolar_disparity_map[row, col]
|
|
235
|
+
) = self.orchestrator.cluster.create_task(
|
|
236
|
+
fill_disparity_zeros_wrapper
|
|
237
|
+
)(
|
|
238
|
+
epipolar_disparity_map[row, col],
|
|
239
|
+
window,
|
|
240
|
+
overlap,
|
|
241
|
+
classif=self.classification,
|
|
242
|
+
fill_valid_pixels=self.fill_valid_pixels,
|
|
243
|
+
saving_info=full_saving_info,
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
res = new_epipolar_disparity_map
|
|
247
|
+
|
|
248
|
+
else:
|
|
249
|
+
logging.error(
|
|
250
|
+
"FillDisp application doesn't support "
|
|
251
|
+
"this input data format"
|
|
252
|
+
)
|
|
253
|
+
return res
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
# pylint: disable=too-many-positional-arguments
|
|
257
|
+
def fill_disparity_zeros_wrapper(
|
|
258
|
+
disp,
|
|
259
|
+
window,
|
|
260
|
+
overlap,
|
|
261
|
+
classif,
|
|
262
|
+
fill_valid_pixels,
|
|
263
|
+
saving_info=None,
|
|
264
|
+
):
|
|
265
|
+
"""
|
|
266
|
+
Wrapper to copy previous disparity
|
|
267
|
+
|
|
268
|
+
:param disp: left to right disparity map
|
|
269
|
+
:type disp: xr.Dataset
|
|
270
|
+
:param window: window of base tile [row min, row max, col min col max]
|
|
271
|
+
:type window: list
|
|
272
|
+
:param overlap: overlap [row min, row max, col min col max]
|
|
273
|
+
:type overlap: list
|
|
274
|
+
:param classif: classification tags
|
|
275
|
+
:type classif: list
|
|
276
|
+
:param fill_valid_pixels: option to fill valid pixels
|
|
277
|
+
:type fill_valid_pixels: bool
|
|
278
|
+
:param saving_info: saving infos
|
|
279
|
+
:type saving_info: dict
|
|
280
|
+
|
|
281
|
+
:return: disp map
|
|
282
|
+
:rtype: xr.Dataset, xr.Dataset
|
|
283
|
+
"""
|
|
284
|
+
# Add a band to disparity dataset to memorize which pixels are filled
|
|
285
|
+
disp = fd_wrappers.add_empty_filling_band(disp, ["zeros_padding"])
|
|
286
|
+
fd_algo.fill_disp_using_zero_padding(disp, classif, fill_valid_pixels)
|
|
287
|
+
result = copy.copy(disp)
|
|
288
|
+
|
|
289
|
+
# Fill with attributes
|
|
290
|
+
attributes = {
|
|
291
|
+
cst.CROPPED_DISPARITY_RANGE: (ocht.get_disparity_range_cropped(disp))
|
|
292
|
+
}
|
|
293
|
+
cars_dataset.fill_dataset(
|
|
294
|
+
result,
|
|
295
|
+
saving_info=saving_info,
|
|
296
|
+
window=cars_dataset.window_array_to_dict(window),
|
|
297
|
+
profile=None,
|
|
298
|
+
attributes=attributes,
|
|
299
|
+
overlaps=cars_dataset.overlap_array_to_dict(overlap),
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
return result
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
CARS core dense matching module init file
|
|
23
|
+
"""
|
|
24
|
+
# flake8: noqa: F401
|
|
25
|
+
|
|
26
|
+
from cars.applications.dense_matching.abstract_dense_matching_app import (
|
|
27
|
+
DenseMatching,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from . import census_mccnn_sgm_app
|
|
@@ -0,0 +1,261 @@
|
|
|
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 abstract matching application class.
|
|
23
|
+
"""
|
|
24
|
+
import logging
|
|
25
|
+
from abc import ABCMeta, abstractmethod
|
|
26
|
+
from typing import Dict
|
|
27
|
+
|
|
28
|
+
from cars.applications.application import Application
|
|
29
|
+
from cars.applications.application_template import ApplicationTemplate
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
@Application.register("dense_matching")
|
|
33
|
+
class DenseMatching(ApplicationTemplate, metaclass=ABCMeta):
|
|
34
|
+
"""
|
|
35
|
+
AbstractDenseMatching
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
available_applications: Dict = {}
|
|
39
|
+
default_application = "census_sgm_default"
|
|
40
|
+
|
|
41
|
+
def __new__(cls, conf=None): # pylint: disable=W0613
|
|
42
|
+
"""
|
|
43
|
+
Return the required application
|
|
44
|
+
:raises:
|
|
45
|
+
- KeyError when the required application is not registered
|
|
46
|
+
|
|
47
|
+
:param conf: configuration for matching
|
|
48
|
+
:return: a application_to_use object
|
|
49
|
+
"""
|
|
50
|
+
|
|
51
|
+
matching_method = cls.default_application
|
|
52
|
+
if bool(conf) is False or "method" not in conf:
|
|
53
|
+
logging.info(
|
|
54
|
+
"Dense Matching method not specified, "
|
|
55
|
+
"default {} is used".format(matching_method)
|
|
56
|
+
)
|
|
57
|
+
else:
|
|
58
|
+
matching_method = conf.get("method", cls.default_application)
|
|
59
|
+
|
|
60
|
+
if matching_method not in cls.available_applications:
|
|
61
|
+
logging.error(
|
|
62
|
+
"No matching application named {} registered".format(
|
|
63
|
+
matching_method
|
|
64
|
+
)
|
|
65
|
+
)
|
|
66
|
+
raise KeyError(
|
|
67
|
+
"No matching application named {} registered".format(
|
|
68
|
+
matching_method
|
|
69
|
+
)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
logging.info(
|
|
73
|
+
"The AbstractDenseMatching({}) application will be used".format(
|
|
74
|
+
matching_method
|
|
75
|
+
)
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
return super(DenseMatching, cls).__new__(
|
|
79
|
+
cls.available_applications[matching_method]
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
def __init_subclass__(cls, short_name, **kwargs): # pylint: disable=E0302
|
|
83
|
+
super().__init_subclass__(**kwargs)
|
|
84
|
+
for name in short_name:
|
|
85
|
+
cls.available_applications[name] = cls
|
|
86
|
+
|
|
87
|
+
def __init__(self, conf=None):
|
|
88
|
+
"""
|
|
89
|
+
Init function of DenseMatching
|
|
90
|
+
|
|
91
|
+
:param conf: configuration
|
|
92
|
+
:return: an application_to_use object
|
|
93
|
+
"""
|
|
94
|
+
|
|
95
|
+
super().__init__(conf=conf)
|
|
96
|
+
|
|
97
|
+
@abstractmethod
|
|
98
|
+
def get_optimal_tile_size(self, disp_range_grid, max_ram_per_worker):
|
|
99
|
+
"""
|
|
100
|
+
Get the optimal tile size to use during dense matching.
|
|
101
|
+
|
|
102
|
+
:param disp_range_grid: minimum and maximum disparity grid
|
|
103
|
+
:param max_ram_per_worker: maximum ram per worker
|
|
104
|
+
:return: optimal tile size
|
|
105
|
+
|
|
106
|
+
"""
|
|
107
|
+
|
|
108
|
+
@abstractmethod
|
|
109
|
+
def get_performance_map_parameters(self):
|
|
110
|
+
"""
|
|
111
|
+
Get parameter linked to performance, that will be used in triangulation
|
|
112
|
+
|
|
113
|
+
:return: parameters to use
|
|
114
|
+
:type: dict
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
@abstractmethod
|
|
118
|
+
def get_margins_fun(self, grid_left, disp_range_grid):
|
|
119
|
+
"""
|
|
120
|
+
Get Margins function that generates margins needed by
|
|
121
|
+
matching method, to use during resampling
|
|
122
|
+
|
|
123
|
+
:param grid_left: left epipolar grid
|
|
124
|
+
:param disp_range_grid: minimum and maximum disparity grid
|
|
125
|
+
:return: function that generates margin for given roi
|
|
126
|
+
|
|
127
|
+
"""
|
|
128
|
+
|
|
129
|
+
# pylint: disable=too-many-positional-arguments
|
|
130
|
+
@abstractmethod
|
|
131
|
+
def generate_disparity_grids(
|
|
132
|
+
self,
|
|
133
|
+
epipolar_images_left,
|
|
134
|
+
epipolar_images_right,
|
|
135
|
+
local_tile_optimal_size_fun,
|
|
136
|
+
orchestrator=None,
|
|
137
|
+
pair_folder=None,
|
|
138
|
+
pair_key="PAIR_0",
|
|
139
|
+
disp_range_grid=None,
|
|
140
|
+
compute_disparity_masks=False,
|
|
141
|
+
margins_to_keep=0,
|
|
142
|
+
texture_bands=None,
|
|
143
|
+
classif_bands_to_mask=None,
|
|
144
|
+
):
|
|
145
|
+
"""
|
|
146
|
+
Generate disparity grids min and max, with given step
|
|
147
|
+
|
|
148
|
+
global mode: uses dmin and dmax
|
|
149
|
+
local mode: uses dems
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
:param sensor_image_right: sensor image
|
|
153
|
+
:type sensor_image_right: dict
|
|
154
|
+
:param grid_right: right epipolar grid
|
|
155
|
+
:type grid_right: CarsDataset
|
|
156
|
+
:param geometry_plugin_with_dem_min: geometry plugin with dem min
|
|
157
|
+
:type geometry_plugin_with_dem_min: GeometryPlugin
|
|
158
|
+
:param geometry_plugin_with_dem_max: geometry plugin with dem max
|
|
159
|
+
:type geometry_plugin_with_dem_max: GeometryPlugin
|
|
160
|
+
:param geom_plugin_with_dem_and_geoid: geometry plugin with dem mean
|
|
161
|
+
used to generate epipolar grids
|
|
162
|
+
:type geom_plugin_with_dem_and_geoid: GeometryPlugin
|
|
163
|
+
:param dmin: minimum disparity
|
|
164
|
+
:type dmin: float
|
|
165
|
+
:param dmax: maximum disparity
|
|
166
|
+
:type dmax: float
|
|
167
|
+
:param altitude_delta_max: Delta max of altitude
|
|
168
|
+
:type altitude_delta_max: int
|
|
169
|
+
:param altitude_delta_min: Delta min of altitude
|
|
170
|
+
:type altitude_delta_min: int
|
|
171
|
+
:param dem_min: path to minimum dem
|
|
172
|
+
:type dem_min: str
|
|
173
|
+
:param dem_max: path to maximum dem
|
|
174
|
+
:type dem_max: str
|
|
175
|
+
:param pair_folder: folder used for current pair
|
|
176
|
+
:type pair_folder: str
|
|
177
|
+
:param loc_inverse_orchestrator: orchestrator to perform inverse locs
|
|
178
|
+
:type loc_inverse_orchestrator: Orchestrator
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
:return disparity grid range, containing grid min and max
|
|
182
|
+
:rtype: CarsDataset
|
|
183
|
+
"""
|
|
184
|
+
|
|
185
|
+
@abstractmethod
|
|
186
|
+
def run( # pylint: disable=too-many-positional-arguments
|
|
187
|
+
self,
|
|
188
|
+
epipolar_images_left,
|
|
189
|
+
epipolar_images_right,
|
|
190
|
+
local_tile_optimal_size_fun,
|
|
191
|
+
orchestrator=None,
|
|
192
|
+
pair_folder=None,
|
|
193
|
+
pair_key="PAIR_0",
|
|
194
|
+
disp_range_grid=None,
|
|
195
|
+
compute_disparity_masks=False,
|
|
196
|
+
margins_to_keep=0,
|
|
197
|
+
texture_bands=None,
|
|
198
|
+
classif_bands_to_mask=None,
|
|
199
|
+
):
|
|
200
|
+
"""
|
|
201
|
+
Run Matching application.
|
|
202
|
+
|
|
203
|
+
Create CarsDataset filled with xarray.Dataset, corresponding
|
|
204
|
+
to epipolar disparities, on the same geometry than
|
|
205
|
+
epipolar_images_left.
|
|
206
|
+
|
|
207
|
+
:param epipolar_images_left: tiled left epipolar CarsDataset contains:
|
|
208
|
+
|
|
209
|
+
- N x M Delayed tiles. \
|
|
210
|
+
Each tile will be a future xarray Dataset containing:
|
|
211
|
+
|
|
212
|
+
- data with keys : "im", "msk", "texture"
|
|
213
|
+
- attrs with keys: "margins" with "disp_min" and "disp_max"\
|
|
214
|
+
"transform", "crs", "valid_pixels", "no_data_mask",\
|
|
215
|
+
"no_data_img"
|
|
216
|
+
- attributes containing:
|
|
217
|
+
"largest_epipolar_region","opt_epipolar_tile_size"
|
|
218
|
+
:type epipolar_images_left: CarsDataset
|
|
219
|
+
:param epipolar_images_right: tiled right epipolar CarsDataset contains:
|
|
220
|
+
|
|
221
|
+
- N x M Delayed tiles. \
|
|
222
|
+
Each tile will be a future xarray Dataset containing:
|
|
223
|
+
|
|
224
|
+
- data with keys : "im", "msk", "texture"
|
|
225
|
+
- attrs with keys: "margins" with "disp_min" and "disp_max"
|
|
226
|
+
"transform", "crs", "valid_pixels", "no_data_mask",
|
|
227
|
+
"no_data_img"
|
|
228
|
+
- attributes containing:
|
|
229
|
+
"largest_epipolar_region","opt_epipolar_tile_size"
|
|
230
|
+
:type epipolar_images_right: CarsDataset
|
|
231
|
+
:param local_tile_optimal_size_fun: function to compute local
|
|
232
|
+
optimal tile size
|
|
233
|
+
:type local_tile_optimal_size_fun: func
|
|
234
|
+
:param orchestrator: orchestrator used
|
|
235
|
+
:param pair_folder: folder used for current pair
|
|
236
|
+
:type pair_folder: str
|
|
237
|
+
:param pair_key: pair id
|
|
238
|
+
:type pair_key: str
|
|
239
|
+
:param disp_range_grid: minimum and maximum disparity grid
|
|
240
|
+
:type disp_range_grid: CarsDataset
|
|
241
|
+
:param disp_to_alt_ratio: disp to alti ratio used for performance map
|
|
242
|
+
:type disp_to_alt_ratio: float
|
|
243
|
+
:param margins_to_keep: margin to keep after dense matching
|
|
244
|
+
:type margins_to_keep: int
|
|
245
|
+
:param texture_bands: indices of bands from epipolar_images_left
|
|
246
|
+
used for output texture
|
|
247
|
+
:type texture_bands: list
|
|
248
|
+
|
|
249
|
+
:return: disparity map: \
|
|
250
|
+
The CarsDataset contains:
|
|
251
|
+
|
|
252
|
+
- N x M Delayed tiles.\
|
|
253
|
+
Each tile will be a future xarray Dataset containing:
|
|
254
|
+
- data with keys : "disp", "disp_msk"
|
|
255
|
+
- attrs with keys: profile, window, overlaps
|
|
256
|
+
- attributes containing:
|
|
257
|
+
"largest_epipolar_region","opt_epipolar_tile_size",
|
|
258
|
+
"disp_min_tiling", "disp_max_tiling"
|
|
259
|
+
|
|
260
|
+
:rtype: CarsDataset
|
|
261
|
+
"""
|