fix(annotation): 标注图重排,8 个量全标注且不重叠
- 修复七眼三个横向量(单眼宽度/两眼间距/脸宽)叠在同一条眼睛线上的重叠问题, 改为上下错开三个高度,各自虚线带箭头 + 紧贴标签 - 新增「全脸总高」标注:右侧竖向标尺(虚线双箭头,头顶→下巴)+ 标签 - 四庭(顶/上/中/下庭)仍在左侧各段中点 - 标签用全名:单眼宽度/两眼间距/脸宽/全脸总高 - 新增 tests/test_annotation.py 防回归 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
"""标注图生成测试:RGBA 透明底 + 尺寸 + 有内容(不重叠由人工目视核验)。"""
|
||||
import cv2
|
||||
import numpy as np
|
||||
from conftest import fixture
|
||||
|
||||
from face_analysis.detector import detector
|
||||
from face_analysis.measure import measure_face
|
||||
from face_analysis.annotation import create_annotated_image
|
||||
|
||||
|
||||
def test_annotation_rgba_transparent():
|
||||
img = cv2.imread(fixture("frontal.jpg"))
|
||||
h, w = img.shape[:2]
|
||||
lms = detector.detect(img)
|
||||
r = measure_face(lms, None, w, h) # 方案A,确定性
|
||||
canvas = create_annotated_image(img, r)
|
||||
assert canvas.mode == "RGBA"
|
||||
assert canvas.size == (w, h)
|
||||
arr = np.asarray(canvas)
|
||||
assert (arr[:, :, 3] == 0).any() # 存在透明像素
|
||||
assert (arr[:, :, 3] > 0).any() # 存在不透明像素(线/字)
|
||||
|
||||
|
||||
def test_annotation_runs_on_hard_sample():
|
||||
img = cv2.imread(fixture("hard_longhair.jpg"))
|
||||
h, w = img.shape[:2]
|
||||
lms = detector.detect(img)
|
||||
r = measure_face(lms, None, w, h)
|
||||
canvas = create_annotated_image(img, r)
|
||||
assert canvas.size == (w, h)
|
||||
Reference in New Issue
Block a user