U
    ‰±ËhÛ  ã                   @   sD   d dl Z d dlZd dlmZ d dlmZ G dd„ dƒZddd„ZdS )	é    N)ÚPathc                   @   s   e Zd Zi ZdS )Ú
ImageCacheN)Ú__name__Ú
__module__Ú__qualname__Údata© r   r   ú:/tmp/pip-unpacked-wheel-5oclok7i/insightface/data/image.pyr      s   r   Fc           	      C   s¼   | |f}|t jkrt j| S t ttƒj ¡ d¡}dddg}d }|D ]*}t |d| |f ¡}t |¡rD|} qpqD|d k	s„t	d|  ƒ‚t
 |¡}|r®|d d …d d …d d d…f }|t j|< |S )NZimagesz.jpgz.pngz.jpegz%s%sz%s not foundéÿÿÿÿ)r   r   ÚospÚjoinr   Ú__file__ÚparentÚabsoluteÚexistsÚAssertionErrorÚcv2Zimread)	ÚnameZto_rgbÚkeyZ
images_dirZ	ext_namesZ
image_fileZext_nameZ_image_fileÚimgr   r   r	   Ú	get_image	   s"    





r   )F)	r   ÚosÚos.pathÚpathr   Úpathlibr   r   r   r   r   r   r	   Ú<module>   s
   