feat(测量): 接口1/6 返回与标注图一致的竖线坐标
前端需要按标注图重绘竖线,坐标与画线共用同一套几何。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+38
-1
@@ -461,7 +461,7 @@ def test_success_structure(client):
|
||||
data = body["data"]
|
||||
# 业务字段对齐文档
|
||||
assert set(["face_total_height_cm", "four_courts", "seven_eyes",
|
||||
"landmarks", "hairline_source", "head_pose",
|
||||
"landmarks", "hairline_source", "head_pose", "vertical_lines",
|
||||
"annotated_image_base64"]).issubset(data.keys())
|
||||
assert set(["top_court_cm", "upper_court_cm", "middle_court_cm",
|
||||
"lower_court_cm", "ratios"]).issubset(data["four_courts"].keys())
|
||||
@@ -478,3 +478,40 @@ def test_success_structure(client):
|
||||
assert "annotated_image_url" not in data
|
||||
png = base64.b64decode(data["annotated_image_base64"])
|
||||
assert png[:8] == b"\x89PNG\r\n\x1a\n"
|
||||
_assert_vertical_lines(data, "v1")
|
||||
|
||||
|
||||
_INNER_VLINES = [
|
||||
"left_cheek", "left_eye_outer", "left_eye_inner",
|
||||
"right_eye_inner", "right_eye_outer", "right_cheek",
|
||||
]
|
||||
|
||||
|
||||
def _assert_vertical_lines(data, variant):
|
||||
vl = data["vertical_lines"]
|
||||
assert isinstance(vl["y_top"], int) and isinstance(vl["y_bottom"], int)
|
||||
assert vl["y_top"] < vl["y_bottom"]
|
||||
names = [line["name"] for line in vl["lines"]]
|
||||
xs = [line["x"] for line in vl["lines"]]
|
||||
assert xs == sorted(xs)
|
||||
assert all(isinstance(x, int) for x in xs)
|
||||
if variant == "v6":
|
||||
assert names == _INNER_VLINES
|
||||
assert vl["y_top"] == data["landmarks"]["hairline"]["y"]
|
||||
assert vl["y_bottom"] == data["landmarks"]["chin_tip"]["y"]
|
||||
assert "eye1" not in data["seven_eyes"]
|
||||
assert "eye7" not in data["seven_eyes"]
|
||||
return
|
||||
assert set(_INNER_VLINES).issubset(names)
|
||||
assert names[0] in ("left_head_edge", "left_cheek")
|
||||
assert names[-1] in ("right_head_edge", "right_cheek")
|
||||
by_name = {line["name"]: line["x"] for line in vl["lines"]}
|
||||
assert ("left_head_edge" in by_name) == (data["seven_eyes"]["eye1"] is not None)
|
||||
assert ("right_head_edge" in by_name) == (data["seven_eyes"]["eye7"] is not None)
|
||||
|
||||
|
||||
def test_measure_v2_vertical_lines_have_no_head_edges(client):
|
||||
files = {"image_file": ("frontal.jpg", open(fixture("frontal.jpg"), "rb"), "application/octet-stream")}
|
||||
body = client.post("/api/v1/face/measure-v2", headers=H, files=files).json()
|
||||
assert body["code"] == 0, body
|
||||
_assert_vertical_lines(body["data"], "v6")
|
||||
|
||||
Reference in New Issue
Block a user