Skip to content

Commit

Permalink
Merge branch '169-suppression-de-la-condition-sur-la-disparite-avec-l…
Browse files Browse the repository at this point in the history
…-etape-d-interpolation' into 'release'

Resolve "Suppression de la condition sur la disparité avec l'étape d'interpolation"

See merge request 3d/PandoraBox/pandora2d!146
  • Loading branch information
lecontm committed Aug 20, 2024
2 parents c68d099 + 24ae1ad commit 21b03e0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 129 deletions.
3 changes: 0 additions & 3 deletions docs/source/userguide/input.rst
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ Input section is composed of the following keys:
-
- If the estimation step is not present

.. warning::
If interpolation is used as refinement method, row_disparity and col_disparity ranges must have a size greater than or equal to 2.


Image (left and right) and disparity (col_disparity and row_disparity) properties are composed of the following keys:

Expand Down
29 changes: 0 additions & 29 deletions pandora2d/check_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,6 @@ def check_conf(user_cfg: Dict, pandora2d_machine: Pandora2DMachine) -> dict:
if "matching_cost" in cfg_pipeline["pipeline"]:
check_right_nodata_condition(cfg_input, cfg_pipeline)

# The refinement step with interpolation method is not allowed with disparity ranges of size lower than 5
if (
"refinement" in cfg_pipeline["pipeline"]
and cfg_pipeline["pipeline"]["refinement"]["refinement_method"] == "interpolation"
):
check_disparity_range_size(cfg_input["input"]["col_disparity"], "Column")
check_disparity_range_size(cfg_input["input"]["row_disparity"], "Row")

cfg = concat_conf([cfg_input, cfg_roi, cfg_pipeline])

return cfg
Expand All @@ -249,27 +241,6 @@ def check_right_nodata_condition(cfg_input: Dict, cfg_pipeline: Dict) -> None:
)


def check_disparity_range_size(disparity: Dict | str, title: str) -> None:
"""
Check that disparity ranges (dmax - dmin) with a size < 5 are not allowed for interpolation refinement method.
:param disparity: disparity range
:type disparity: Dict | str
:param cfg_pipeline: pipeline section of configuration
:type cfg_pipeline: Dict
"""

if isinstance(disparity, Dict):
if disparity["range"] < 2:
raise ValueError(
title + " disparity range (dmax - dmin) with a size < 5 are not allowed "
"with interpolation refinement method"
)

if isinstance(disparity, str):
raise TypeError("Grid disparities are not yet handled by Pandora2D")


def check_roi_coherence(roi_cfg: dict) -> None:
"""
Check that the first ROI coords are lower than the last.
Expand Down
98 changes: 1 addition & 97 deletions tests/unit_tests/test_check_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import random
import string
import re
import pytest
import transitions
import numpy as np
Expand Down Expand Up @@ -280,7 +279,7 @@ def test_multiband_pipeline(self, pandora2d_machine, left_rgb_path, right_rgb_pa
check_configuration.check_conf(cfg, pandora2d_machine)


class TestCheckConf:
class TestCheckConf: # pylint: disable=too-few-public-methods
"""Test check_conf method."""

def test_passes_with_good_disparity_range_and_interpolation_step(
Expand All @@ -296,36 +295,6 @@ def test_passes_with_good_disparity_range_and_interpolation_step(
user_cfg = {**correct_input_cfg, **correct_pipeline}
check_configuration.check_conf(user_cfg, pandora2d_machine)

@pytest.mark.parametrize(
["col_disparity", "row_disparity"],
[
pytest.param({"init": 1, "range": 1}, {"init": 1, "range": 2}, id="col_disparity range too small"),
pytest.param({"init": 1, "range": 2}, {"init": 2, "range": 1}, id="row_disparity range too small"),
pytest.param(
{"init": 1, "range": 1}, {"init": 3, "range": 1}, id="col_disparity & row_disparity range too small"
),
],
)
def test_fails_with_wrong_disparity_range_and_interpolation_step(
self, correct_input_cfg, correct_pipeline, pandora2d_machine, col_disparity, row_disparity
):
"""
Description : Test wrong col_disparity & row_disparity range with interpolation step in user configuration
Data :
- Left image : cones/monoband/left.png
- Right image : cones/monoband/right.png
Requirement : EX_CONF_08
"""
correct_input_cfg["input"]["col_disparity"] = col_disparity
correct_input_cfg["input"]["row_disparity"] = row_disparity
user_cfg = {**correct_input_cfg, **correct_pipeline}
with pytest.raises(ValueError) as err:
check_configuration.check_conf(user_cfg, pandora2d_machine)
assert (
" disparity range (dmax - dmin) with a size < 5 are not allowed "
"with interpolation refinement method" in err.value.args[0]
)


class TestCheckRoiSection:
"""
Expand Down Expand Up @@ -530,71 +499,6 @@ def test_zncc_fails_with(self, pandora2d_machine, configuration):
check_configuration.check_conf(configuration, pandora2d_machine)


class TestCheckDisparityRangeSize:
"""Test check_disparity_range_size method."""

@pytest.mark.parametrize(
["disparity", "title", "string_match"],
[
pytest.param(
{"init": 1, "range": 1},
"Column",
"Column disparity range (dmax - dmin) with a size < 5 are not allowed "
"with interpolation refinement method",
id="Column disparity range < 5",
),
pytest.param(
{"init": -1, "range": 1},
"Row",
"Row disparity range (dmax - dmin) with a size < 5 are not allowed "
"with interpolation refinement method",
id="Row disparity range < 5",
),
],
)
def test_fails_with_disparity_ranges_lower_5(self, disparity, title, string_match):
"""
Description : Disparity range size must be greater than or equal to 5 when interpolation
is used as refinement method
Data :
Requirement : EX_CONF_08
"""
with pytest.raises(ValueError, match=re.escape(string_match)):
check_configuration.check_disparity_range_size(disparity, title)

@pytest.mark.parametrize(
["disparity", "title", "string_match"],
[
pytest.param(
"disparity_grid_test",
"Column",
"Grid disparities are not yet handled by Pandora2D",
id="Grid disparity",
),
],
)
def test_fails_with_grid_disparity(self, disparity, title, string_match):
"""
Description : Disparity grid is not handled yet by Pandora2D
Data :
Requirement : EX_CONF_08
"""
with pytest.raises(TypeError, match=string_match):
check_configuration.check_disparity_range_size(disparity, title)

@pytest.mark.parametrize(
["disparity", "title"],
[
pytest.param({"init": 1, "range": 2}, "Col", id="Column disparity range greater than or equal to 5"),
pytest.param({"init": 3, "range": 2}, "Row", id="Row disparity range greater than or equal to 5"),
],
)
def test_passes_with_disparity_ranges_equal_5(self, disparity, title):
"""Disparity range size is correct"""

check_configuration.check_disparity_range_size(disparity, title)


class TestDisparityRangeAgainstImageSize:
"""Test that out of image disparity ranges are not allowed."""

Expand Down

0 comments on commit 21b03e0

Please sign in to comment.