三维未激活采样显示灰点,二维增加深度叠箭头。

分析对话框默认使用传感器对话框保存的标定,关闭按钮改为保存。框选曲线时数值卡片仍显示光标读数。相关单测通过。
This commit is contained in:
ykcheungab
2026-10-08 17:04:30 +08:00
parent 3d2fb0c4eb
commit 091d0fda35
18 changed files with 507 additions and 202 deletions
+15 -2
View File
@@ -36,12 +36,22 @@ def test_a_live_frame_offers_the_derived_modes_and_needs_no_note():
plan = backend.plan_image(
backend.ImageFrame(_image(), flow=_flow(), depth=np.ones((12, 16)))
)
assert plan.available_modes == ("arrows_pure", "arrows_stitched", "depth")
assert plan.available_modes == ("arrows_pure", "arrows_stitched", "depth", "depth_arrows")
assert plan.default_mode == "arrows_pure"
assert plan.missing == ()
assert plan.note_key == ""
def test_depth_arrows_draws_the_flow_on_the_depth_picture():
depth = np.linspace(0.0, 1.0, 12 * 16, dtype=np.float32).reshape(12, 16)
frame = backend.ImageFrame(_image(), flow=_flow(), depth=depth)
plain = backend.render_image(frame, mode="depth", draw_style="finger")
over = backend.render_image(frame, mode="depth_arrows", draw_style="finger")
assert plain is not None and over is not None
assert over.shape == plain.shape
assert not np.array_equal(over, plain)
def test_a_recorded_frame_is_raw_and_says_so():
"""No flow and no depth: the frame *is* the picture, and the note explains it."""
plan = backend.plan_image(backend.ImageFrame(_image(), source=backend.SOURCE_REPLAY))
@@ -723,9 +733,12 @@ def test_hiding_the_idle_dots_leaves_the_3d_figure_where_it_was():
f"{int(active.sum())} active of {samples.rows.size} candidates"
)
assert overlay_on is not None and overlay_off is not None
assert overlay_on.origins.shape[0] == int(active.sum()), (
assert int(np.count_nonzero(overlay_on.lengths > 0.0)) == int(active.sum()), (
"the 3D overlay is not drawing the active samples the 2D canvas draws"
)
assert int(np.count_nonzero(overlay_on.lengths < 0.0)) > 0, (
"inactive samples are not drawn as grey points"
)
assert np.array_equal(overlay_on.origins, overlay_off.origins)
assert np.array_equal(overlay_on.directions, overlay_off.directions)
assert not np.array_equal(dots_on, dots_off), "the switch changed nothing to hide"
+26 -1
View File
@@ -3,6 +3,7 @@
from __future__ import annotations
import numpy as np
import pytest
from orisys_app_shared.scene3d.overlays import (
arrow_instances_to_mesh,
build_flow_overlay,
@@ -10,7 +11,7 @@ from orisys_app_shared.scene3d.overlays import (
force_visual_strength,
)
from orisys_app_shared.scene3d.synthetic import poc_scene
from orisys_app_shared.scene3d.visual_policy import VisualPolicy, select_flow_samples
from orisys_app_shared.scene3d.visual_policy import FlowSamples, VisualPolicy, select_flow_samples
def test_force_visual_strength_is_capped() -> None:
@@ -58,6 +59,30 @@ def test_flow_and_normal_overlays_on_poc_mapping() -> None:
assert colors.shape[0] == positions.shape[0]
def test_an_inactive_sample_is_a_grey_point_and_an_active_one_is_an_arrow() -> None:
assets = poc_scene()
mapping = assets.surface_mapping
assert mapping is not None
samples = FlowSamples(
rows=np.asarray([1, 1], dtype=np.int32),
cols=np.asarray([1, 2], dtype=np.int32),
dx=np.asarray([0.8, 0.0]),
dy=np.asarray([0.0, 0.0]),
magnitude=np.asarray([1.6, 0.0]),
active=np.asarray([True, False]),
)
arrows, diags = build_flow_overlay(samples, mapping)
assert not diags
assert int(np.count_nonzero(arrows.lengths > 0.0)) == 1
assert int(np.count_nonzero(arrows.lengths < 0.0)) == 1
idle = arrows.colors[arrows.lengths < 0.0][0]
# Brand idle tint #8A93A6, not a ramp colour.
assert idle[0] == pytest.approx(0x8A / 255.0, abs=0.02)
assert idle[2] == pytest.approx(0xA6 / 255.0, abs=0.02)
positions, _triangles, colors = arrow_instances_to_mesh(arrows)
assert positions.shape[0] == colors.shape[0] > 0
def test_missing_contact_yields_no_arrow() -> None:
assets = poc_scene()
mapping = assets.surface_mapping