Ë
    ùGìjô  ã                   ó4  — 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  G d„ dej:                  «      ZdZ G d„ de«      Z y)zMediaPipe Hands.é    N)Ú
NamedTuple)Ú#constant_side_packet_calculator_pb2)Úgate_calculator_pb2)Úsplit_vector_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)Ússd_anchors_calculator_pb2)Úassociation_calculator_pb2)Ú"detections_to_rects_calculator_pb2)Úlogic_calculator_pb2)Ú"non_max_suppression_calculator_pb2)Ú"rect_transformation_calculator_pb2)Úthresholding_calculator_pb2)ÚSolutionBase)ÚHAND_CONNECTIONSc                   ód   — 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y)ÚHandLandmarkzThe 21 hand landmarks.r   é   é   é   é   é   é   é   é   é	   é
   é   é   é   é   é   é   é   é   é   é   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚWRISTÚ	THUMB_CMCÚ	THUMB_MCPÚTHUMB_IPÚ	THUMB_TIPÚINDEX_FINGER_MCPÚINDEX_FINGER_PIPÚINDEX_FINGER_DIPÚINDEX_FINGER_TIPÚMIDDLE_FINGER_MCPÚMIDDLE_FINGER_PIPÚMIDDLE_FINGER_DIPÚMIDDLE_FINGER_TIPÚRING_FINGER_MCPÚRING_FINGER_PIPÚRING_FINGER_DIPÚRING_FINGER_TIPÚ	PINKY_MCPÚ	PINKY_PIPÚ	PINKY_DIPÚ	PINKY_TIP© ó    údC:\Users\Stabi\Downloads\virtual-tryon(1)\venv\Lib\site-packages\mediapipe/python/solutions/hands.pyr   r   -   sv   „ ÙØ
€%Ø€)Ø€)Ø€(Ø€)ØÐØÐØÐØÐØÐØÐØÐØÐØ€/Ø€/Ø€/Ø€/Ø€)Ø€)Ø€)Ø�)rE   r   zCmediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypbc                   óV   ‡ — e Zd ZdZ	 	 	 	 	 dˆ fd„	Zdej                  defˆ fd„Zˆ xZ	S )ÚHandsaO  MediaPipe Hands.

  MediaPipe Hands processes an RGB image and returns the hand landmarks and
  handedness (left v.s. right hand) of each detected hand.

  Note that it determines handedness assuming the input image is mirrored,
  i.e., taken with a front-facing/selfie camera (
  https://en.wikipedia.org/wiki/Front-facing_camera) with images flipped
  horizontally. If that is not the case, use, for instance, cv2.flip(image, 1)
  to flip the image first for a correct handedness output.

  Please refer to https://solutions.mediapipe.dev/hands#python-solution-api for
  usage examples.
  c                 óH   •— t         ‰| �  t        ||| dœ||dœg d¢¬«       y)aH  Initializes a MediaPipe Hand 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/hands#static_image_mode.
      max_num_hands: Maximum number of hands to detect. See details in
        https://solutions.mediapipe.dev/hands#max_num_hands.
      model_complexity: Complexity of the hand landmark model: 0 or 1.
        Landmark accuracy as well as inference latency generally go up with the
        model complexity. See details in
        https://solutions.mediapipe.dev/hands#model_complexity.
      min_detection_confidence: Minimum confidence value ([0.0, 1.0]) for hand
        detection to be considered successful. See details in
        https://solutions.mediapipe.dev/hands#min_detection_confidence.
      min_tracking_confidence: Minimum confidence value ([0.0, 1.0]) for the
        hand landmarks to be considered tracked successfully. See details in
        https://solutions.mediapipe.dev/hands#min_tracking_confidence.
    )Úmodel_complexityÚ	num_handsÚuse_prev_landmarks)z@palmdetectioncpu__TensorsToDetectionsCalculator.min_score_threshz1handlandmarkcpu__ThresholdingCalculator.threshold)Úmulti_hand_landmarksÚmulti_hand_world_landmarksÚmulti_handedness)Úbinary_graph_pathÚside_inputsÚcalculator_paramsÚoutputsN)ÚsuperÚ__init__Ú_BINARYPB_FILE_PATH)ÚselfÚstatic_image_modeÚmax_num_handsrJ   Úmin_detection_confidenceÚmin_tracking_confidenceÚ	__class__s         €rF   rU   zHands.__init__Y   s=   ø€ ô2 
�GÑÜ-à 0Ø&Ø&7Ð"7ñ
ð )à'ñ	
ò
ð õ rE   ÚimageÚreturnc                 ó(   •— t         ‰| �  d|i¬«      S )aC  Processes an RGB image and returns the hand landmarks and handedness of each detected hand.

    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 object with the following fields:
        1) a "multi_hand_landmarks" field that contains the hand landmarks on
           each detected hand.
        2) a "multi_hand_world_landmarks" field that contains the hand landmarks
           on each detected hand in real-world 3D coordinates that are in meters
           with the origin at the hand's approximate geometric center.
        3) a "multi_handedness" field that contains the handedness (left v.s.
           right hand) of the detected hand.
    r]   )Ú
input_data)rT   Úprocess)rW   r]   r\   s     €rF   ra   zHands.process„   s   ø€ ô* ‰7‰? w°Ð&6ˆ?Ó7Ð7rE   )Fr   r   ç      à?rb   )
r+   r,   r-   r.   rU   ÚnpÚndarrayr   ra   Ú__classcell__)r\   s   @rF   rH   rH   I   s;   ø„ ñð  "'ØØ !Ø(+Ø'*õ)ðV8˜2Ÿ:™:ð 8¨*÷ 8ñ 8rE   rH   )!r.   ÚenumÚtypingr   Únumpyrc   Úmediapipe.calculators.corer   r   r   Úmediapipe.calculators.tensorr   r   r	   r
   r   Úmediapipe.calculators.tfliter   Úmediapipe.calculators.utilr   r   r   r   r   r   Úmediapipe.python.solution_baser   Ú,mediapipe.python.solutions.hands_connectionsr   ÚIntEnumr   rV   rH   rD   rE   rF   Ú<module>rp      sp   ðñ ã Ý ã õ KÝ :Ý BÝ GÝ AÝ QÝ MÝ LÝ CÝ AÝ IÝ ;Ý IÝ IÝ Bå 7å Iô�4—<‘<ô ð2 \Ð ôP8ˆLõ P8rE   