o
    >h;	                     @   s   d dl mZ d dlZd dlZd dlZd dlmZ d dlZd dl	Z	d dl
Z
dd Zdd Zdd Zd	d
 Ze edejddddejdddddd ZedkrZe  dS dS )    )print_functionNc                 C   s&   |\}}}}t d| |||| d S )Nz{},{},{},{},{})printformat)filenamelocationtoprightbottomleft r   i/home/www/facesmatcher.com/frenv_dlib/lib/python3.10/site-packages/face_recognition/face_detection_cli.pyprint_result   s   r   c                 C   s2   t | }t j|d|d}|D ]}t| | qd S )Nr   )Znumber_of_times_to_upsamplemodel)face_recognitionZload_image_fileface_locationsr   )image_to_checkr   Zunknown_imager   Zface_locationr   r   r   
test_image   s
   
r   c                    s    fddt  D S )Nc                    s,   g | ]}t jd |t jdrtj |qS )z.*\.(jpg|jpeg|png))flags)rematchIospathjoin).0ffolderr   r   
<listcomp>   s   , z)image_files_in_folder.<locals>.<listcomp>)r   listdirr   r   r   r   image_files_in_folder   s   r    c                 C   sX   |dkrd }n|}t }dt  v rt d}|j|d}t| t|}|t| d S )NZ
forkserver)	processes)	multiprocessingZget_all_start_methodsZget_contextZPoolzip	itertoolsrepeatstarmapr   )Zimages_to_checkZnumber_of_cpusr   r"   contextpoolZfunction_parametersr   r   r   process_images_in_process_pool   s   
r*   r   z--cpus   zDnumber of CPU cores to use in parallel. -1 means "use all in system")defaulthelpz--modelZhogz>Which face detection model to use. Options are "hog" or "cnn".c                    sp   t jdk r|dkrtd d}tj| r1|dkr' fddt| D  d S tt| |  d S t	|   d S )N)      r+   zmWARNING: Multi-processing support requires Python 3.4 or greater. Falling back to single-threaded processing!c                    s   g | ]}t | qS r   )r   )r   Z
image_filer   r   r   r   >   s    zmain.<locals>.<listcomp>)
sysversion_infoclickZechor   r   isdirr    r*   r   )r   Zcpusr   r   r0   r   main2   s   
r5   __main__)
__future__r   r3   r   r   Zface_recognition.apiapir   r#   r1   r%   r   r   r    r*   commandargumentoptionr5   __name__r   r   r   r   <module>   s(   
