o
    0ÎjÐ  ã                   @   s,   d gZ ddlZdejdejdefdd „ZdS )Úget_neighbor_boxes_idxé    NÚ	src_boxesÚref_boxÚreturnc           
      C   sÀ   g }t | ƒdkr^t |d | dd…df ¡}t |d | dd…df ¡}t |d | dd…df ¡}t |d | dd…df ¡}|| }|| }t |dk|dk @ |dk@ ¡d }	| |	¡ |S )a  
    Retrieve indices of source boxes that are neighbors to the reference box.

    Parameters:
    src_boxes (np.ndarray): An array of bounding boxes with shape (N, 4),
                            where N is the number of boxes and each box is represented
                            by [x1, y1, x2, y2].
    ref_box (np.ndarray): A single bounding box represented by [x1, y1, x2, y2].

    Returns:
    list: A list of indices of the source boxes that are close to the
          reference box based on the intersection area.
    r   Né   é   é   iñÿÿÿ)ÚlenÚnpÚmaximumÚminimumÚwhereÚextend)
r   r   Zmatch_idx_listÚx1Úy1Zx2Úy2Zpub_wZpub_hZ	match_idx© r   út/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/table_recognition/utils.pyr      s   "
)Ú__all__Únumpyr
   ZndarrayÚlistr   r   r   r   r   Ú<module>   s   