import cv2
import mediapipe as mp

# def is_thigh_visible(image_path):
#     # 初始化MediaPipe Pose模型
#     mp_pose = mp.solutions.pose
#     pose = mp_pose.Pose(static_image_mode=True, min_detection_confidence=0.5)
    
#     # 读取图像
#     image = cv2.imread(image_path)
#     image_rgb = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
    
#     # 进行姿态估计
#     results = pose.process(image_rgb)
    
#     if not results.pose_landmarks:
#         return False  # 未检测到人体
    
#     # 获取关键点
#     landmarks = results.pose_landmarks.landmark
    
#     # 检查髋部和膝盖之间的关键点（大腿部分）
#     # MediaPipe关键点索引：
#     # 23: 左髋, 24: 右髋
#     # 25: 左膝, 26: 右膝
    
#     # 检查左大腿是否可见（髋部和膝盖之间）
#     left_hip_visible = landmarks[mp_pose.PoseLandmark.LEFT_HIP.value].visibility > 0.6
#     left_knee_visible = landmarks[mp_pose.PoseLandmark.LEFT_KNEE.value].visibility > 0.6
#     left_thigh_visible = left_hip_visible and left_knee_visible
    
#     # 检查右大腿是否可见
#     right_hip_visible = landmarks[mp_pose.PoseLandmark.RIGHT_HIP.value].visibility > 0.6
#     right_knee_visible = landmarks[mp_pose.PoseLandmark.RIGHT_KNEE.value].visibility > 0.6
#     right_thigh_visible = right_hip_visible and right_knee_visible
    
#     return left_thigh_visible and right_thigh_visible

# print(is_thigh_visible("/home/xsl/code/ComfyUI/change_cloth/static/imgs/fc74eded_00001_.jpg"))