diff --git a/face_analysis/annotation.py b/face_analysis/annotation.py index 09616b9..726725b 100644 --- a/face_analysis/annotation.py +++ b/face_analysis/annotation.py @@ -260,6 +260,18 @@ def create_annotated_image(image_bgr, measure_result, ear_mask=None, hair_mask=N draw = ImageDraw.Draw(canvas) font = _load_font(font_size) + # --- 2b. 每条横线在「中间线段」(两内眼角之间)中点画原点突出 --- + # 注意:原点不在整条线的中点 face_cx,而在被竖线切出的中间段(左内眼角↔右内眼角) + # 的正中,即脸的竖直中轴附近、两内眼角连线中点。 + li_x = pts["left_inner"][0] + ri_x = pts["right_inner"][0] + dot_cx = (li_x + ri_x) / 2 + dot_r = max(2, round(s * 0.0045)) # 原点半径,与 arrow_size 同档自适应 + for cy in ys: + x0, y0 = dot_cx - dot_r, cy - dot_r + x1, y1 = dot_cx + dot_r, cy + dot_r + draw.ellipse((x0, y0, x1, y1), fill=LINE_COLOR) + # --- 3a. 横线右侧:线名(头顶/发际线/眉心/鼻翼下缘/下巴尖),文字在线上方 --- name_x = fx1 + pad name_gap = max(2, round(pad * 1.6)) # 文字底部到线的间距(再上移)