
    Wpf                        d Z ddlZddlmZ ddlZddlmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ ddl m!Z! ddl"m#Z# ddl$m%Z%  G d dej&                  Z'dZ(d Z) G d d e!          Z*dS )!zMediaPipe Pose.    N)
NamedTuple)#constant_side_packet_calculator_pb2)gate_calculator_pb2)split_vector_calculator_pb2)warp_affine_calculator_pb2)image_to_tensor_calculator_pb2)inference_calculator_pb2)(tensors_to_classification_calculator_pb2)$tensors_to_detections_calculator_pb2)#tensors_to_landmarks_calculator_pb2)&tensors_to_segmentation_calculator_pb2)ssd_anchors_calculator_pb2)"detections_to_rects_calculator_pb2)"landmarks_smoothing_calculator_pb2)"local_file_contents_calculator_pb2)logic_calculator_pb2)"non_max_suppression_calculator_pb2)"rect_transformation_calculator_pb2)thresholding_calculator_pb2)#visibility_smoothing_calculator_pb2)switch_container_pb2)SolutionBase)download_utils)POSE_CONNECTIONSc                       e Zd ZdZdZdZdZdZdZdZ	dZ
d	Zd
ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!d Z"d!Z#d"Z$d#S )$PoseLandmarkzThe 33 pose landmarks.r                           	   
                                                                      N)%__name__
__module____qualname____doc__NOSELEFT_EYE_INNERLEFT_EYELEFT_EYE_OUTERRIGHT_EYE_INNER	RIGHT_EYERIGHT_EYE_OUTERLEFT_EAR	RIGHT_EAR
MOUTH_LEFTMOUTH_RIGHTLEFT_SHOULDERRIGHT_SHOULDER
LEFT_ELBOWRIGHT_ELBOW
LEFT_WRISTRIGHT_WRIST
LEFT_PINKYRIGHT_PINKY
LEFT_INDEXRIGHT_INDEX
LEFT_THUMBRIGHT_THUMBLEFT_HIP	RIGHT_HIP	LEFT_KNEE
RIGHT_KNEE
LEFT_ANKLERIGHT_ANKLE	LEFT_HEEL
RIGHT_HEELLEFT_FOOT_INDEXRIGHT_FOOT_INDEX     _/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/mediapipe/python/solutions/pose.pyr   r   5   s        	
$.(./)/()*+-.*+*+*+*+*+())**+)*/rc   r   z:mediapipe/modules/pose_landmark/pose_landmark_cpu.binarypbc                 v    | dk    rt          j        d           dS | dk    rt          j        d           dS dS )zoDownloads the pose landmark lite/heavy model from the MediaPipe Github repo if it doesn't exist in the package.r   z9mediapipe/modules/pose_landmark/pose_landmark_lite.tfliter   z:mediapipe/modules/pose_landmark/pose_landmark_heavy.tfliteN)r   download_oss_model)model_complexitys    rd   !_download_oss_pose_landmark_modelrh   ]   sp     %CE E E E E1%DF F F F F rc   c                   P     e Zd ZdZ	 	 	 	 	 	 	 d
 fd	Zdej        def fd	Z xZ	S )PosezMediaPipe Pose.

  MediaPipe Pose processes an RGB image and returns pose landmarks on the most
  prominent person detected.

  Please refer to https://solutions.mediapipe.dev/pose#python-solution-api for
  usage examples.
  Fr   T      ?c           	          t          |           t                                          t          ||o| ||o| | d||dg d           dS )aj  Initializes a MediaPipe Pose object.

    Args:
      static_image_mode: Whether to treat the input images as a batch of static
        and possibly unrelated images, or a video stream. See details in
        https://solutions.mediapipe.dev/pose#static_image_mode.
      model_complexity: Complexity of the pose landmark model: 0, 1 or 2. See
        details in https://solutions.mediapipe.dev/pose#model_complexity.
      smooth_landmarks: Whether to filter landmarks across different input
        images to reduce jitter. See details in
        https://solutions.mediapipe.dev/pose#smooth_landmarks.
      enable_segmentation: Whether to predict segmentation mask. See details in
        https://solutions.mediapipe.dev/pose#enable_segmentation.
      smooth_segmentation: Whether to filter segmentation across different input
        images to reduce jitter. See details in
        https://solutions.mediapipe.dev/pose#smooth_segmentation.
      min_detection_confidence: Minimum confidence value ([0.0, 1.0]) for person
        detection to be considered successful. See details in
        https://solutions.mediapipe.dev/pose#min_detection_confidence.
      min_tracking_confidence: Minimum confidence value ([0.0, 1.0]) for the
        pose landmarks to be considered tracked successfully. See details in
        https://solutions.mediapipe.dev/pose#min_tracking_confidence.
    )rg   smooth_landmarksenable_segmentationsmooth_segmentationuse_prev_landmarks)z@posedetectioncpu__TensorsToDetectionsCalculator.min_score_threshz]poselandmarkbyroicpu__tensorstoposelandmarksandsegmentation__ThresholdingCalculator.threshold)pose_landmarkspose_world_landmarkssegmentation_mask)binary_graph_pathside_inputscalculator_paramsoutputsN)rh   super__init___BINARYPB_FILE_PATH)	selfstatic_image_moderg   rm   rn   ro   min_detection_confidencemin_tracking_confidence	__class__s	           rd   ry   zPose.__init__r   s    > &&6777	GG- 0 0 J9J5J#6#=,=(=&7"7
 
 )'	
 
 POO!  Q Q Q Q Qrc   imagereturnc                     t                                          d|i          }|j        r$|j        j        D ]}|                    d           |j        r$|j        j        D ]}|                    d           |S )a  Processes an RGB image and returns the pose landmarks on the most prominent person detected.

    Args:
      image: An RGB image represented as a numpy ndarray.

    Raises:
      RuntimeError: If the underlying graph throws any error.
      ValueError: If the input image is not three channel RGB.

    Returns:
      A NamedTuple with fields describing the landmarks on the most prominate
      person detected:
        1) "pose_landmarks" field that contains the pose landmarks.
        2) "pose_world_landmarks" field that contains the pose landmarks in
        real-world 3D coordinates that are in meters with the origin at the
        center between hips.
        3) "segmentation_mask" field that contains the segmentation mask if
           "enable_segmentation" is set to true.
    r   )
input_datapresence)rx   processrq   landmark
ClearFieldrr   )r{   r   resultsr   r   s       rd   r   zPose.process   s    * ggoo'5)9o::G (,5 ( ((J''''# (2; ( ((J''''Nrc   )Fr   TFTrk   rk   )
r=   r>   r?   r@   ry   npndarrayr   r   __classcell__)r   s   @rd   rj   rj   h   s          "' ! $#(#'(+'*0Q 0Q 0Q 0Q 0Q 0Qd2: *          rc   rj   )+r@   enumtypingr   numpyr   mediapipe.calculators.corer   r   r   mediapipe.calculators.imager   mediapipe.calculators.tensorr   r	   r
   r   r   r   mediapipe.calculators.tfliter   mediapipe.calculators.utilr   r   r   r   r   r   r   r   mediapipe.framework.toolr   mediapipe.python.solution_baser   mediapipe.python.solutionsr   +mediapipe.python.solutions.pose_connectionsr   IntEnumr   rz   rh   rj   rb   rc   rd   <module>r      s[               
 K J J J J J : : : : : : B B B B B B B B B B B B G G G G G G A A A A A A Q Q Q Q Q Q M M M M M M L L L L L L O O O O O O C C C C C C I I I I I I I I I I I I I I I I I I ; ; ; ; ; ; I I I I I I I I I I I I B B B B B B J J J J J J 9 9 9 9 9 9 7 7 7 7 7 7 5 5 5 5 5 5 H H H H H H" " " " "4< " " "J S F F FX X X X X< X X X X Xrc   