feat: 新增接口22生发控制与测试页

This commit is contained in:
xsl
2026-11-09 21:19:39 +08:00
parent c800822d54
commit b84a506b9b
21 changed files with 770 additions and 175 deletions
+6 -6
View File
@@ -16,21 +16,21 @@ def _landmarks(width=320, height=400):
return lm
def test_target_uses_mean_courts_without_old_estimation_ratio():
def test_target_is_lowered_by_five_percent_of_brow_to_chin():
rule = height_target(_landmarks(), 320, 400)
assert rule["middle_height_px"] == pytest.approx(80, abs=1e-4)
assert rule["lower_height_px"] == pytest.approx(60, abs=1e-4)
assert rule["target_upper_height_px"] == pytest.approx(70, abs=1e-4)
assert rule["target_center"]["y"] == pytest.approx(110, abs=1e-4)
assert rule["target_upper_height_px"] == pytest.approx(63, abs=1e-4)
assert rule["target_center"]["y"] == pytest.approx(117, abs=1e-4)
def test_reference_uses_unrounded_measurement_and_scale():
ref = {"brow_center": (161.4, 181.3), "nose_bottom": (160.0, 261.9),
"chin_tip": (160.0, 321.5), "px_per_cm": 20}
rule = height_target(_landmarks(), 320, 400, ref)
assert rule["target_upper_height_px"] == pytest.approx(70.1)
assert rule["target_center"]["y"] == pytest.approx(111.2)
assert rule["target_upper_height_cm"] == pytest.approx(3.505)
assert rule["target_upper_height_px"] == pytest.approx(63.09)
assert rule["target_center"]["y"] == pytest.approx(118.21)
assert rule["target_upper_height_cm"] == pytest.approx(3.1545)
assert rule["measurement_source"] == "face_measure"