Skip to content

Commit

Permalink
Merge branch '928-integration-parametrage-sift-dem' into 'master'
Browse files Browse the repository at this point in the history
Resolve "intégration paramétrage sift/ dem"

Closes #928

See merge request 3d/cars-park/cars!765
  • Loading branch information
dyoussef committed Nov 25, 2024
2 parents 9854570 + d350e32 commit 8f74306
Show file tree
Hide file tree
Showing 103 changed files with 412 additions and 377 deletions.
19 changes: 18 additions & 1 deletion cars/applications/dem_generation/dichotomic_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ def __init__(self, conf=None):
self.fillnodata_max_search_distance = self.used_config[
"fillnodata_max_search_distance"
]
self.min_dem = self.used_config["min_dem"]
self.max_dem = self.used_config["max_dem"]

# Init orchestrator
self.orchestrator = None
Expand Down Expand Up @@ -117,9 +119,11 @@ def check_conf(self, conf):
overloaded_conf["min_number_matches"] = conf.get(
"min_number_matches", 100
)
overloaded_conf["min_dem"] = conf.get("min_dem", -500)
overloaded_conf["max_dem"] = conf.get("max_dem", 1000)

overloaded_conf["fillnodata_max_search_distance"] = conf.get(
"fillnodata_max_search_distance", 3
"fillnodata_max_search_distance", 5
)

rectification_schema = {
Expand All @@ -129,6 +133,8 @@ def check_conf(self, conf):
"height_margin": Or(list, int),
"percentile": And(Or(int, float), lambda x: x >= 0),
"min_number_matches": And(int, lambda x: x > 0),
"min_dem": And(Or(int, float), lambda x: x < 0),
"max_dem": And(Or(int, float), lambda x: x > 0),
"fillnodata_max_search_distance": And(int, lambda x: x > 0),
OptionalKey(application_constants.SAVE_INTERMEDIATE_DATA): bool,
}
Expand Down Expand Up @@ -311,6 +317,17 @@ def run(
dem_min = np.floor(dem_min).astype(int)
dem_max = np.ceil(dem_max).astype(int)

dem_min = np.where(
dem_median - dem_min < self.min_dem,
dem_median + self.min_dem,
dem_min,
)
dem_max = np.where(
dem_max - dem_median > self.max_dem,
dem_median + self.max_dem,
dem_max,
)

# Generate CarsDataset

dem = cars_dataset.CarsDataset("arrays", name="dem_generation")
Expand Down
14 changes: 10 additions & 4 deletions cars/applications/sparse_matching/sift.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ def __init__(self, conf=None):
self.sift_peak_threshold = self.used_config["sift_peak_threshold"]
self.sift_edge_threshold = self.used_config["sift_edge_threshold"]
self.sift_magnification = self.used_config["sift_magnification"]
self.sift_window_size = self.used_config["sift_window_size"]
self.sift_back_matching = self.used_config["sift_back_matching"]

# sifts filter
Expand Down Expand Up @@ -163,21 +164,22 @@ def check_conf(self, conf):

# sifts params
overloaded_conf["sift_matching_threshold"] = conf.get(
"sift_matching_threshold", 0.6
"sift_matching_threshold", 0.7
)
overloaded_conf["sift_n_octave"] = conf.get("sift_n_octave", 8)
overloaded_conf["sift_n_scale_per_octave"] = conf.get(
"sift_n_scale_per_octave", 3
)
overloaded_conf["sift_peak_threshold"] = conf.get(
"sift_peak_threshold", None
"sift_peak_threshold", 4.0
)
overloaded_conf["sift_edge_threshold"] = conf.get(
"sift_edge_threshold", 5.0
"sift_edge_threshold", 10.0
)
overloaded_conf["sift_magnification"] = conf.get(
"sift_magnification", 2.0
"sift_magnification", 7.0
)
overloaded_conf["sift_window_size"] = conf.get("sift_window_size", 2)
overloaded_conf["sift_back_matching"] = conf.get(
"sift_back_matching", True
)
Expand Down Expand Up @@ -214,6 +216,7 @@ def check_conf(self, conf):
"sift_peak_threshold": Or(float, None),
"sift_edge_threshold": float,
"sift_magnification": And(float, lambda x: x > 0),
"sift_window_size": And(int, lambda x: x > 0),
"sift_back_matching": bool,
"matches_filter_knn": int,
"matches_filter_dev_factor": Or(int, float),
Expand Down Expand Up @@ -547,6 +550,7 @@ def run(
peak_threshold=tmp_sift_peak_threshold,
edge_threshold=self.sift_edge_threshold,
magnification=self.sift_magnification,
window_size=self.sift_window_size,
backmatching=self.sift_back_matching,
disp_lower_bound=disp_lower_bound,
disp_upper_bound=disp_upper_bound,
Expand Down Expand Up @@ -763,6 +767,7 @@ def compute_matches_wrapper(
peak_threshold=None,
edge_threshold=None,
magnification=None,
window_size=None,
backmatching=None,
disp_lower_bound=None,
disp_upper_bound=None,
Expand Down Expand Up @@ -811,6 +816,7 @@ def compute_matches_wrapper(
peak_threshold=peak_threshold,
edge_threshold=edge_threshold,
magnification=magnification,
window_size=window_size,
backmatching=backmatching,
disp_lower_bound=disp_lower_bound,
disp_upper_bound=disp_upper_bound,
Expand Down
25 changes: 17 additions & 8 deletions cars/applications/sparse_matching/sparse_matching_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,13 @@ def compute_matches(
right_mask: np.ndarray = None,
left_origin: [float, float] = None,
right_origin: [float, float] = None,
matching_threshold: float = 0.6,
matching_threshold: float = 0.7,
n_octave: int = 8,
n_scale_per_octave: int = 3,
peak_threshold: float = 20.0,
edge_threshold: float = 5.0,
magnification: float = 2.0,
peak_threshold: float = 4.0,
edge_threshold: float = 10.0,
magnification: float = 7.0,
window_size: int = 2,
backmatching: bool = True,
disp_lower_bound=None,
disp_upper_bound=None,
Expand Down Expand Up @@ -98,6 +99,8 @@ def compute_matches(
:type edge_threshold: float
:param magnification: set the descriptor magnification factor
:type magnification: float
:param window_size: size of the window
:type window_size: int
:param backmatching: also check that right vs. left gives same match
:type backmatching: bool
:return: matches
Expand All @@ -115,6 +118,7 @@ def compute_matches(
peak_thresh=peak_threshold,
edge_thresh=edge_threshold,
magnification=magnification,
window_size=window_size,
float_descriptors=True,
compute_descriptor=True,
verbose=False,
Expand All @@ -128,6 +132,7 @@ def compute_matches(
peak_thresh=peak_threshold,
edge_thresh=edge_threshold,
magnification=magnification,
window_size=window_size,
float_descriptors=True,
compute_descriptor=True,
verbose=False,
Expand Down Expand Up @@ -265,12 +270,13 @@ def compute_matches(
def dataset_matching(
ds1,
ds2,
matching_threshold=0.6,
matching_threshold=0.7,
n_octave=8,
n_scale_per_octave=3,
peak_threshold=20.0,
edge_threshold=5.0,
magnification=2.0,
peak_threshold=4.0,
edge_threshold=10.0,
magnification=7.0,
window_size=2,
backmatching=True,
disp_lower_bound=None,
disp_upper_bound=None,
Expand All @@ -294,6 +300,8 @@ def dataset_matching(
:param edge_threshold: the edge selection threshold.
:param magnification: set the descriptor magnification factor
:type magnification: float
:param window_size: size of the window
:type window_size: int
:param backmatching: also check that right vs. left gives same match
:type backmatching: bool
:return: matches
Expand All @@ -320,6 +328,7 @@ def dataset_matching(
peak_threshold=peak_threshold,
edge_threshold=edge_threshold,
magnification=magnification,
window_size=window_size,
backmatching=backmatching,
disp_lower_bound=disp_lower_bound,
disp_upper_bound=disp_upper_bound,
Expand Down
8 changes: 6 additions & 2 deletions cars/pipelines/default/default_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,11 @@ def check_applications(
]

if self.merging: # we have to merge point clouds, add merging apps
needed_applications += ["point_cloud_fusion"]
needed_applications += [
"point_cloud_fusion",
"point_cloud_outliers_removing.1",
"point_cloud_outliers_removing.2",
]

for app_key in conf.keys():
if app_key not in needed_applications:
Expand Down Expand Up @@ -668,7 +672,7 @@ def check_applications_with_inputs(self, inputs_conf, application_conf):
)
if self.sparse_mtch_app.elevation_delta_lower_bound is None:
self.sparse_mtch_app.used_config["elevation_delta_lower_bound"] = (
-100 if initial_elevation else -1000
-500 if initial_elevation else -1000
)
self.sparse_mtch_app.elevation_delta_lower_bound = (
self.sparse_mtch_app.used_config["elevation_delta_lower_bound"]
Expand Down
23 changes: 10 additions & 13 deletions docs/source/usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -843,18 +843,20 @@ The structure follows this organisation:
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| minimum_nb_matches | Minimum number of matches that must be computed to continue pipeline | int | should be > 0 | 100 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_matching_threshold | Threshold for the ratio to nearest second match | float | should be > 0 | 0.6 | No |
| sift_matching_threshold | Threshold for the ratio to nearest second match | float | should be > 0 | 0.7 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_n_octave | The number of octaves of the Difference of Gaussians scale space | int | should be > 0 | 8 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_n_scale_per_octave | The numbers of levels per octave of the Difference of Gaussians scale space | int | should be > 0 | 3 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_peak_threshold | Constrast threshold to discard a match (at None it will be set according to image type) | float | should be > 0, or None | None | No |
| sift_peak_threshold | Constrast threshold to discard a match (at None it will be set according to image type) | float | should be > 0 | 4.0 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_edge_threshold | Distance to image edge threshold to discard a match | float | | -5.0 | No |
| sift_edge_threshold | Distance to image edge threshold to discard a match | float | | 10.0 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_magnification | The descriptor magnification factor | float | should be > 0 | 2.0 | No |
| sift_magnification | The descriptor magnification factor | float | should be > 0 | 7.0 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_window_size | smaller values let the center of the descriptor count more | int | should be > 0 | 2 | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| sift_back_matching | Also check that right vs. left gives same match | boolean | | true | No |
+--------------------------------------+------------------------------------------------------------------------------------------------+-------------+------------------------+---------------+----------+
| matches_filter_knn | Number of neighbors used to measure isolation of matches and detect isolated matches | int | should be > 0 | 25 | No |
Expand All @@ -868,15 +870,6 @@ The structure follows this organisation:


For more information about these parameters, please refer to the `VLFEAT SIFT documentation <https://www.vlfeat.org/api/sift.html>`_.

.. note::

By default, the sift_peak_threshold is set to None (auto-mode). In this mode, the sift_peak_threshold is determined at runtime based on the sensor image type:

* uint8 image type : sift_peak_threshold = 1
* other image type sift_peak_threshold = 20

It is also possible to set the value to a fixed value.

**Example**

Expand Down Expand Up @@ -923,6 +916,10 @@ The structure follows this organisation:
+---------------------------------+------------------------------------------------------------+------------+-----------------+---------------+----------+
| fillnodata_max_search_distance | Max search distance for rasterio fill nodata | int | should be > 0 | 3 | No |
+---------------------------------+------------------------------------------------------------+------------+-----------------+---------------+----------+
| min_dem | Min value that has to be reached by dem_min | int | should be < 0 | -500 | No |
+---------------------------------+------------------------------------------------------------+------------+-----------------+---------------+----------+
| max_dem | Max value that has to be reached by dem_max | int | should be > 0 | 1000 | No |
+---------------------------------+------------------------------------------------------------+------------+-----------------+---------------+----------+

**Example**

Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/classification_end2end_ventoux_split.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/cloud1_ref_pandora
Binary file not shown.
Binary file modified tests/data/ref_output/clr_end2end_ventoux_split_no_merging.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_gizeh_crop.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_gizeh_crop_no_merging.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_gizeh_fill.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_gizeh_fill_with_zero.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_paca_bulldozer.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_paca_matches_filling.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_egm96.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_no_srtm.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_split.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_split_4326.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_with_color.tif
Binary file not shown.
Binary file modified tests/data/ref_output/color_end2end_ventoux_with_roi.tif
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.
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.
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/dem_max_end2end_ventoux.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_max_end2end_ventoux_8bit.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_max_end2end_ventoux_no_srtm.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_max_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_median_end2end_ventoux.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_median_end2end_ventoux_8bit.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_median_end2end_ventoux_no_srtm.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/dem_min_end2end_ventoux.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_min_end2end_ventoux_8bit.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_min_end2end_ventoux_no_srtm.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dem_min_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_gizeh_crop.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_gizeh_crop_no_merging.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_gizeh_fill.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_gizeh_fill_with_zero.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_paca_bulldozer.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_paca_matches_filling.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_egm96.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_egm96_custom_geoid.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_no_srtm.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_split.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_split_4326.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_split_no_merging.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_with_classif.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_with_color.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_with_roi.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_end2end_ventoux_with_snap_to_img1.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_filling_dsm_filled_gizeh_crop_roi.tif
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_mean_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/dsm_std_end2end_ventoux_quality_stats.tif
Binary file not shown.
Binary file modified tests/data/ref_output/epi_pc_X_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/epi_pc_Y_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/epi_pc_Z_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/filling_end2end_gizeh_fill.tif
Binary file not shown.
Binary file modified tests/data/ref_output/filling_end2end_gizeh_fill_with_zero.tif
Binary file not shown.
Binary file modified tests/data/ref_output/filling_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/filling_end2end_ventoux_split.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_gizeh_crop.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_gizeh_crop_no_merging.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_gizeh_fill.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_gizeh_fill_with_zero.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_paca_bulldozer.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_paca_matches_filling.tif
Binary file not shown.
Binary file modified tests/data/ref_output/mask_end2end_ventoux_no_elevation.tif
Binary file not shown.
Binary file modified tests/data/ref_output/matches.npy
Binary file not shown.
Binary file modified tests/data/ref_output/performance_map_end2end_gizeh_crop.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/performance_map_end2end_ventoux_split.tif
Binary file not shown.
Binary file not shown.
Binary file modified tests/data/ref_output/rasterization_res_ref_1_intervals.nc
Binary file not shown.
Binary file modified tests/data/ref_output/source_pc_end2end_ventoux_split_4326.tif
Binary file not shown.
Loading

0 comments on commit 8f74306

Please sign in to comment.