
    FPh                         d Z ddlmZ ddlZddlZddlZej                  Zej                  fde
defdZdde
dej                  fdZd	e
d
ej                  fdZej                  Zd Zy)zDMonkey patches to update/extend functionality of existing functions.    )PathNfilenameflagsc                 r    t        j                  t        j                  | t        j                        |      S )z
    Read an image from a file.

    Args:
        filename (str): Path to the file to read.
        flags (int, optional): Flag that can take values of cv2.IMREAD_*. Defaults to cv2.IMREAD_COLOR.

    Returns:
        (np.ndarray): The read image.
    )cv2imdecodenpfromfileuint8)r   r   s     dC:\Users\daisl\Desktop\realtime-object-detection\venv\Lib\site-packages\ultralytics/utils/patches.pyimreadr      s$     <<Hbhh7??    imgc                     	 t        j                  t        |       j                  ||      d   j	                  |        y# t
        $ r Y yw xY w)a2  
    Write an image to a file.

    Args:
        filename (str): Path to the file to write.
        img (np.ndarray): Image to write.
        params (list of ints, optional): Additional parameters. See OpenCV documentation.

    Returns:
        (bool): True if the file was written, False otherwise.
       TF)r   imencoder   suffixtofile	Exception)r   r   paramss      r   imwriter      sF    T(^**C8;BB8L s   <? 	A
Awinnamematc                 V    t        | j                  d      j                         |       y)z
    Displays an image in the specified window.

    Args:
        winname (str): Name of the window.
        mat (np.ndarray): Image to be shown.
    unicode_escapeN)_imshowencodedecode)r   r   s     r   imshowr   /   s!     GNN+,335s;r   c                  Z    	 ddl }d|vr||d<   t        | i |S # t        $ r ddl}Y #w xY w)z
    Use dill (if exists) to serialize the lambda functions where pickle does not do this.

    Args:
        *args (tuple): Positional arguments to pass to torch.save.
        **kwargs (dict): Keyword arguments to pass to torch.save.
    r   Npickle_module)dillImportErrorpickle_torch_save)argskwargsr$   s      r   
torch_saver(   >   sB     f$"('''  s    **)N)__doc__pathlibr   r   numpyr	   torchr   r   IMREAD_COLORstrintr   ndarrayr   saver%   r(    r   r   <module>r3      s~    J  
   ** (+'7'7 @S @ @c 

 &<C <bjj < jj(r   