
    9i
                         S SK rSSKJrJr  SSKJr  SSKJr  \" S5      (       a  S SK	r	\R                  " SSS	9\" S5       " S
 S5      5       5       rg)    N   )class_requires_depsis_dep_available   )	benchmark)ImageReaderzopencv-contrib-pythonT)nameis_read_operationc                   <   ^  \ rS rSrSrSU 4S jjrS rS rSrU =r	$ )	ReadImage   zLoad image from the file.c                    > [         TU ]  5         Xl        [        R                  [        R                  [        R
                  S.U R                     n[        SUS9U l        g)z
Initialize the instance.

Args:
    format (str, optional): Target color format to convert the image to.
        Choices are 'BGR', 'RGB', and 'GRAY'. Default: 'BGR'.
)BGRRGBGRAYopencv)backendflagsN)super__init__formatcv2IMREAD_COLORIMREAD_GRAYSCALEr   _img_reader)selfr   r   	__class__s      l/var/www/html/land-doc-ocr/venv/lib/python3.13/site-packages/paddlex/inference/common/reader/image_reader.pyr   ReadImage.__init__   sV     	####((
 ++	
 'xuE    c                 N    U Vs/ s H  o R                  U5      PM     sn$ s  snf )apply)read)r   imgsimgs      r   __call__ReadImage.__call__/   s     *./$3		#$///s   "c                    [        U[        R                  5      (       a7  U R                  S:X  a%  [        R
                  " U[        R                  5      nU$ [        U[        5      (       a~  U R                  R                  U5      nUc  [        SU 35      eU R                  S:X  a@  UR                  S:w  a  [        S5      e[        R
                  " U[        R                  5      nU$ [        S[        U5      R                   S35      e)Nr   zImage read Error: r   zArray is not 3-dimensional.zReadImage only supports the following types:
1. str, indicating a image file path or a directory containing image files.
2. numpy.ndarray.
However, got type: .)
isinstancenpndarrayr   r   cvtColorCOLOR_BGR2RGBstrr   r#   	ExceptionndimRuntimeError	TypeErrortype__name__)r   r%   blobs      r   r#   ReadImage.read3   s    c2::&&{{e#ll3(9(9:JS!!##((-D|"4SE :;;{{e#99>&'DEE||D#*;*;<K& '+3i&8&8%9< r    )r   r   )r   )
r5   
__module____qualname____firstlineno____doc__r   r&   r#   __static_attributes____classcell__)r   s   @r   r   r      s     $F"0 r    r   )numpyr+   
utils.depsr   r   utils.benchmarkr   utils.ior   r   timeit_with_optionsr    r    r   <module>rD      sW     @ ( #+,, DDA,-. . . B.r    