改为按帧自适应显示 Autocal 深度色阶
从有效 UV 区域计算当前帧范围,排除无效值和区域外像素。57 项定向测试及代码、文档检查通过。
This commit is contained in:
@@ -83,3 +83,33 @@ def test_display_toggles_redraw_same_frame_without_mutating_measurements(qt_app,
|
||||
assert panel.display_note.text()
|
||||
np.testing.assert_array_equal(frames[-1], solid)
|
||||
panel.shutdown()
|
||||
|
||||
|
||||
def test_depth_range_adapts_per_frame_and_excludes_invalid_uv_pixels(qt_app, monkeypatch):
|
||||
from orisys_autocal.ui import finger_source_panel
|
||||
|
||||
panel = finger_source_panel.FingerSourcePanel()
|
||||
panel.background_check.setChecked(False)
|
||||
panel.depth_check.setChecked(True)
|
||||
mask = np.zeros((64, 80), dtype=bool)
|
||||
mask[10:30, 20:40] = True
|
||||
depth = np.full((64, 80), 1e6)
|
||||
depth[mask] = np.linspace(2, 4, mask.sum())
|
||||
depth[10, 20] = np.nan
|
||||
frames = []
|
||||
monkeypatch.setattr(panel, "_show_frame", lambda frame: frames.append(frame.copy()))
|
||||
panel._last_packet = packet(depth=depth, valid_mask=mask,
|
||||
depth_valid=True, depth_frame_id=1)
|
||||
panel._redraw()
|
||||
first = frames[-1]
|
||||
assert "4" in panel.display_note.text()
|
||||
panel._last_packet = replace(panel._last_packet, depth=depth * 10 + 5)
|
||||
panel._redraw()
|
||||
# A different numerical range spans the same colour ramp in the next frame.
|
||||
np.testing.assert_array_equal(frames[-1], first)
|
||||
assert "45" in panel.display_note.text()
|
||||
panel._last_packet = replace(panel._last_packet, depth=np.full_like(depth, np.nan))
|
||||
panel._redraw()
|
||||
assert panel.display_note.text()
|
||||
assert not np.array_equal(frames[-1], first)
|
||||
panel.shutdown()
|
||||
|
||||
Reference in New Issue
Block a user