
    ih8                     J    d dl mZ d dlZd dlmZ d dlmZmZ  G d de      Z	y)    )ListN)MTCNN)DetectorFacialAreaRegionc                   @    e Zd ZdZd Zdej                  dee   fdZ	y)MtCnnClientzO
    Class to cover common face detection functionalitiy for MtCnn backend
    c                 "    t               | _        y )N)r   model)selfs    V/var/www/html/dev/engine/venv/lib/python3.12/site-packages/deepface/detectors/MtCnn.py__init__zMtCnnClient.__init__   s    W
    imgreturnc           
         g }|dddddddf   }| j                   j                  |      }|Wt        |      dkD  rI|D ]D  }|d   \  }}}}	|d   }
|d   d   }|d   d   }t        ||||	|||
	      }|j	                  |       F |S )
z
        Detect and align face with mtcnn

        Args:
            img (np.ndarray): pre-loaded image as numpy array

        Returns:
            results (List[FacialAreaRegion]): A list of FacialAreaRegion objects
        Nr   box
confidence	keypointsleft_eye	right_eye)xywhr   r   r   )r
   detect_faceslenr   append)r   r   respimg_rgb
detectionscurrent_detectionr   r   r   r   r   r   r   facial_areas                 r   r   zMtCnnClient.detect_faces   s      aDbDj/ZZ,,W5
!c*o&9%/ )!.u5
1a.|<
,[9*E-k:;G	.%') K(!)$ r   N)
__name__
__module____qualname____doc__r   npndarrayr   r   r    r   r   r   r      s)    &

 &t4D/E &r   r   )
typingr   numpyr(   mtcnnr   deepface.models.Detectorr   r   r   r*   r   r   <module>r/      s       ?.( .r   