
    uki                         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y)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    | r| j                   sy| 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     d/home/cdr/jupyterlab/.venv/lib/python3.12/site-packages/mediapipe/python/solutions/face_detection.pyget_key_pointr      s)     
)11		 	 	3	3N	CC    c                   (    e Zd ZdZdZdZdZdZdZdZ	y)	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   .   s%    ;)((,r   c                   L     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.
  c                     |dk(  rt         nt        }t        |   || j	                  t        j                         d|i      dg       y)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   r/   zFaceDetection.__init__C   sX     8G!7K3Qm	G+//335"$<8    r   imager   c                 (    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.
    r6   )
input_data)r.   process)r2   r6   r5   s     r   r9   zFaceDetection.processZ   s     7?w&6?77r   )g      ?r   )
r   r   r   r   r/   npndarrayr   r9   __classcell__)r5   s   @r   r%   r%   8   s)     .82:: 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>rG      s       $  5 9 ? 7i g D&&D8FD
4"//@@@AD"4<< 18L 18r   