Merge branch 'main' of ssh://892887cvmk08.aicp.io:24928/orisys-tech/orisys-app
This commit is contained in:
@@ -280,6 +280,38 @@ def _plate_mode_rgb(pixels: np.ndarray) -> np.ndarray:
|
||||
return values[int(np.argmax(counts))].astype(float)
|
||||
|
||||
|
||||
def test_depth_threshold_only_changes_depth_colours(gl_widget, qt_app):
|
||||
from orisys_studio.scene3d.gl_backend import lut_rgba
|
||||
|
||||
widget, _, _ = gl_widget
|
||||
assets = synthetic.poc_scene()
|
||||
values = np.full(assets.shape_hw, 0.05, dtype=np.float32)
|
||||
depth = FieldDescriptor("depth_response", "1", "approximate", False)
|
||||
flow = FieldDescriptor("flow_magnitude", "px", "approximate", False)
|
||||
|
||||
def settings(descriptor, threshold):
|
||||
return DisplaySettings(
|
||||
housing_visible=False,
|
||||
depth_threshold=threshold,
|
||||
color_scale=ColorScale(
|
||||
descriptor=descriptor, lower=0.0, upper=1.0, lut_id="sequential"
|
||||
),
|
||||
)
|
||||
|
||||
widget.set_settings(settings(depth, 0.0))
|
||||
widget.present(_frame(assets, values, descriptor=depth, frame_id=30))
|
||||
unfiltered = _plate_mean_rgb(_render(widget, qt_app))
|
||||
widget.set_settings(settings(depth, 0.1))
|
||||
filtered = _plate_mean_rgb(_render(widget, qt_app))
|
||||
base = lut_rgba("sequential")[0, 0, :3].astype(float)
|
||||
assert np.abs(filtered - base).max() < 8.0
|
||||
assert np.abs(unfiltered - filtered).max() > 10.0
|
||||
|
||||
widget.set_settings(settings(flow, 0.1))
|
||||
widget.present(_frame(assets, values, descriptor=flow, frame_id=31))
|
||||
assert np.abs(_plate_mean_rgb(_render(widget, qt_app)) - unfiltered).max() < 8.0
|
||||
|
||||
|
||||
def test_a_press_does_not_move_the_surfaces_base_colour(gl_widget, qt_app):
|
||||
"""The base colour follows the field, not the frame's current response.
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ def test_the_pane_holds_a_legend_and_no_settings(panel):
|
||||
panel.deform_check,
|
||||
panel.gain_spin,
|
||||
panel.flow_threshold_spin,
|
||||
panel.depth_threshold_spin,
|
||||
panel.scale_combo,
|
||||
panel.depth_adaptive_check,
|
||||
panel.fps_combo,
|
||||
@@ -107,6 +108,14 @@ def test_adaptive_depth_scale_round_trips_through_the_dialog(panel):
|
||||
assert panel.settings().depth_scale_adaptive is False
|
||||
|
||||
|
||||
def test_depth_threshold_round_trips_through_the_dialog(panel):
|
||||
from orisys_app_shared.scene3d.contracts import DisplaySettings
|
||||
|
||||
panel.apply_settings(DisplaySettings(depth_threshold=0.025))
|
||||
assert panel.depth_threshold_spin.value() == pytest.approx(0.025)
|
||||
assert panel.settings().depth_threshold == pytest.approx(0.025)
|
||||
|
||||
|
||||
def test_arrow_threshold_round_trips_and_feeds_the_shared_policy(panel):
|
||||
"""The threshold the dialog writes is the one both views sample with."""
|
||||
from orisys_app_shared.scene3d.contracts import DisplaySettings
|
||||
|
||||
@@ -261,6 +261,7 @@ def test_shader_sources_are_two_dialects_of_one_body():
|
||||
len(shader_header("gles30")):
|
||||
]
|
||||
assert "texture(u_lut" in desktop_fragment and "texture(u_lut" in es_fragment
|
||||
assert "value < u_depth_threshold" in desktop_fragment
|
||||
# The surface reads *two textures* and decides validity from one of them. There is
|
||||
# no per-vertex scalar or validity attribute, and no ``isnan`` rule: the NaN that
|
||||
# rule used to catch was produced by the CPU gather this path replaced.
|
||||
|
||||
@@ -474,6 +474,7 @@ def test_the_display_settings_round_trip():
|
||||
flow_grid_spacing=12,
|
||||
max_arrows=250,
|
||||
depth_scale_adaptive=True,
|
||||
depth_threshold=0.025,
|
||||
color_scale=ColorScale(
|
||||
descriptor=FieldDescriptor("flow_magnitude", "px", "approximate", False),
|
||||
lower=0.25,
|
||||
@@ -497,7 +498,9 @@ def test_the_display_settings_round_trip():
|
||||
assert (restored.color_scale.lower, restored.color_scale.upper) == (0.25, 4.5)
|
||||
assert restored.color_scale.mode == "fixed"
|
||||
assert restored.depth_scale_adaptive is True
|
||||
assert restored.depth_threshold == 0.025
|
||||
assert scene3d_prefs.settings_from_prefs({}).depth_scale_adaptive is False
|
||||
assert scene3d_prefs.settings_from_prefs({"depth_threshold": -1}).depth_threshold == 0.0
|
||||
|
||||
|
||||
def test_a_saved_descriptor_is_never_restored_as_a_measurement():
|
||||
|
||||
Reference in New Issue
Block a user