
    j              	       r    d dl mZ d dlZd dlZd dlmZ dgZ	 	 ddedee	e	f         dz  de
d	ej        fd
ZdS )    )PathN)AbstractFileread_img_as_numpyTfileoutput_size
rgb_outputreturnc                    t          | t          t          f          r`t          |                                           st	          d|            t          j        t          |           t
          j                  }nct          | t                    r?t          j
        | t          j                  }t          j        |t
          j                  }nt          d          |t          d          t          |t                    r*t          j        ||ddd         t
          j                  }|rt          j        |t
          j                  }|S )a  Read an image file into numpy format

    >>> from doctr.io import read_img_as_numpy
    >>> page = read_img_as_numpy("path/to/your/doc.jpg")

    Args:
        file: the path to the image file
        output_size: the expected output size of each page in format H x W
        rgb_output: whether the output ndarray channel order should be RGB instead of BGR.

    Returns:
        the page decoded as numpy ndarray of shape H x W x 3
    zunable to access z+unsupported object type for argument 'file'Nzunable to read file.)interpolation)
isinstancestrr   is_fileFileNotFoundErrorcv2imreadIMREAD_COLORbytesnp
frombufferuint8imdecode	TypeError
ValueErrortupleresizeINTER_LINEARcvtColorCOLOR_BGR2RGB)r   r   r   img_files        V/var/www/html/Carbon-Document/venv/lib/python3.11/site-packages/doctr/io/image/base.pyr   r      s"   $ $d$$ GDzz!!## 	@#$>$>$>???jTC$455	D%	 	  GM$99l5#"233EFFF {/000+u%% Qjk$$B$/s?OPPP 3l3 122J    )NT)pathlibr   r   numpyr   doctr.utils.common_typesr   __all__r   intboolndarrayr    r#   r"   <module>r,      s          



     1 1 1 1 1 1

 +/% %
%sCx4'% % Z	% % % % % %r#   