22 lines
951 B
Python
22 lines
951 B
Python
from __future__ import annotations
|
|
|
|
import cv2
|
|
import numpy as np
|
|
|
|
from app.exercises.dead_bug.types import DeadBugResult
|
|
|
|
|
|
def draw_status_overlay(image: np.ndarray, result: DeadBugResult) -> None:
|
|
"""在图像上叠加动作状态信息(次数、阶段、反馈)"""
|
|
color = (60, 220, 90) if result.is_standard else (50, 180, 255)
|
|
cv2.rectangle(image, (12, 12), (520, 142), (20, 20, 20), -1)
|
|
cv2.putText(image, f"Dead bug reps: {result.rep_count}", (28, 48), cv2.FONT_HERSHEY_SIMPLEX, 0.9, color, 2)
|
|
cv2.putText(image, f"phase: {result.phase.value}", (28, 82), cv2.FONT_HERSHEY_SIMPLEX, 0.68, (230, 230, 230), 2)
|
|
status = "standard" if result.is_standard else "adjust"
|
|
cv2.putText(image, f"status: {status}", (28, 116), cv2.FONT_HERSHEY_SIMPLEX, 0.68, color, 2)
|
|
|
|
y = 170
|
|
for text in result.feedback:
|
|
cv2.putText(image, text, (28, y), cv2.FONT_HERSHEY_SIMPLEX, 0.68, (255, 255, 255), 2)
|
|
y += 30
|