
    Wpf                         d Z ddlZddlmZ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Zd	Zd
ej        dddede	j        j        f         fdZ G d dej                  Z G d de          ZdS )zMediaPipe Face Detection.    N)
NamedTupleUnion)detection_pb2)location_data_pb2)face_detection_pb2)SolutionBasezHmediapipe/modules/face_detection/face_detection_short_range_cpu.binarypbzGmediapipe/modules/face_detection/face_detection_full_range_cpu.binarypb	detectionkey_point_enumFaceKeyPointreturnc                 <    | r| j         sdS | j         j        |         S )zA convenience method to return a face key point by the FaceKeyPoint type.

  Args:
    detection: A detection proto message that contains face key points.
    key_point_enum: A FaceKeyPoint type.

  Returns:
    A RelativeKeypoint proto message.
  N)location_datarelative_keypoints)r	   r
   s     i/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/mediapipe/python/solutions/face_detection.pyget_key_pointr      s,     
 )1 4		 	3N	CC    c                   *    e Zd ZdZdZdZdZdZdZdZ	dS )	r   z3The enum type of the six face detection key points.r                  N)
__name__
__module____qualname____doc__	RIGHT_EYELEFT_EYENOSE_TIPMOUTH_CENTERRIGHT_EAR_TRAGIONLEFT_EAR_TRAGION r   r   r   r   .   s6        ;;)((,r   c                   B     e Zd ZdZd fd	Zdej        def fdZ xZ	S )	FaceDetectionzMediaPipe Face Detection.

  MediaPipe Face Detection processes an RGB image and returns a list of the
  detected face location data.

  Please refer to
  https://solutions.mediapipe.dev/face_detection#python-solution-api
  for usage examples.
        ?r   c                     |dk    rt           nt          }t                                          ||                     t          j                    d|i          dg           dS )a:  Initializes a MediaPipe Face Detection object.

    Args:
      min_detection_confidence: Minimum confidence value ([0.0, 1.0]) for face
        detection to be considered successful. See details in
        https://solutions.mediapipe.dev/face_detection#min_detection_confidence.
      model_selection: 0 or 1. 0 to select a short-range model that works
        best for faces within 2 meters from the camera, and 1 for a full-range
        model best for faces within 5 meters. See details in
        https://solutions.mediapipe.dev/face_detection#model_selection.
    r   min_score_thresh
detections)binary_graph_pathgraph_optionsoutputsN)_FULL_RANGE_GRAPH_FILE_PATH_SHORT_RANGE_GRAPH_FILE_PATHsuper__init__create_graph_optionsr   FaceDetectionOptions)selfmin_detection_confidencemodel_selectionr*   	__class__s       r   r0   zFaceDetection.__init__C   s|     8G!7K7K33Qm	GG+//355"$<8             r   imager   c                 L    t                                          d|i          S )a  Processes an RGB image and returns a list of the detected face location data.

    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 a "detections" field that contains a list of the
      detected face location data.
    r7   )
input_data)r/   process)r3   r7   r6   s     r   r:   zFaceDetection.processZ   s"     77??w&6?777r   )r&   r   )
r   r   r   r   r0   npndarrayr   r:   __classcell__)r6   s   @r   r%   r%   8   su                    .82: 8* 8 8 8 8 8 8 8 8 8 8r   r%   )r   enumtypingr   r   numpyr;   mediapipe.framework.formatsr   r    mediapipe.modules.face_detectionr   mediapipe.python.solution_baser   r.   r-   	DetectionLocationDataRelativeKeypointr   IntEnumr   r%   r#   r   r   <module>rH      s5       $ $ $ $ $ $ $ $     5 5 5 5 5 5 9 9 9 9 9 9 ? ? ? ? ? ? 7 7 7 7 7 7i g D&D8FD
4"/@@AD D D D"    4<   18 18 18 18 18L 18 18 18 18 18r   