Ë
    ¼Ó^jüÞ  ã                  ó&  — d dl mZ d dlZd dlmZ d dlmZ d dlmZm	Z	 d dl
Z
d dlZd dlmZ d dlmZ d dlmZ  G d„ d	e«      Z G d
„ de«      Zej*                  f	 	 	 	 	 	 	 d'd„Zej*                  f	 	 	 	 	 	 	 d(d„Zd)d„Z	 	 	 	 	 	 	 	 d*d„Zd+d„Zd+d„Z	 	 	 	 	 	 d,d„Zej*                  f	 	 	 	 	 	 	 d-d„Zej*                  f	 	 	 	 	 	 	 d.d„Zej*                  f	 	 	 	 	 	 	 d/d„Zej*                  df	 	 	 	 	 	 	 	 	 d0d„Z dej*                  df	 	 	 	 	 	 	 	 	 	 	 d1d„Z!	 	 	 	 d2d„Z"	 	 	 	 	 	 	 	 d3d„Z#dej*                  f	 	 	 	 	 	 	 d4d„Z$dej*                  f	 	 	 	 	 	 	 	 	 d5d„Z%ddej*                  f	 	 	 	 	 	 	 	 	 	 	 d6d„Z&	 	 	 	 	 	 	 	 d7d „Z'	 	 	 	 	 	 d8d!„Z(dej*                  f	 	 	 	 	 	 	 d9d"„Z)dej*                  f	 	 	 	 	 	 	 d9d#„Z*dej*                  f	 	 	 	 	 	 	 	 	 d:d$„Z+dej*                  f	 	 	 	 	 	 	 	 	 d;d%„Z,dej*                  f	 	 	 	 	 	 	 	 	 d;d&„Z-y)<é    )ÚannotationsN)ÚCallable)ÚEnum)ÚAnyÚcast)ÚCompactMask)Úresize_masksc                  ó@   — e Zd ZdZdZdZdZedd„«       Zed	d„«       Z	y)
ÚOverlapFiltera;  
    Enum specifying the strategy for filtering overlapping detections.

    Attributes:
        NONE: Do not filter detections based on overlap.
        NON_MAX_SUPPRESSION: Filter detections using non-max suppression. This means,
            detections that overlap by more than a set threshold will be discarded,
            except for the one with the highest confidence.
        NON_MAX_MERGE: Merge detections with non-max merging. This means,
            detections that overlap by more than a set threshold will be merged
            into a single detection.
    ÚnoneÚnon_max_suppressionÚnon_max_mergec                ó.   — t        t        d„ | «      «      S )Nc                ó   — | j                   S ©N©Úvalue©Úmembers    úr/var/www/ramen.bs-engineer-server.com/venv/lib/python3.12/site-packages/supervision/detection/utils/iou_and_nms.pyú<lambda>z$OverlapFilter.list.<locals>.<lambda>$   ó
   €  v§|¡|€ ó    ©ÚlistÚmap©Úclss    r   r   zOverlapFilter.list"   ó   € ä”CÑ3°SÓ9Ó:Ð:r   c                ó  — t        || «      r|S t        |t        «      r|j                  «       }	  | |«      S t        dt        |«      › d| j                  › d�«      ‚# t        $ r  t        d|› d| j	                  «       › �«      ‚w xY w©NzInvalid value: z. Must be one of zInvalid value type: z. Must be an instance of z or str.)Ú
isinstanceÚstrÚlowerÚ
ValueErrorr   ÚtypeÚ__name__©r   r   s     r   Ú
from_valuezOverlapFilter.from_value&   ó•   € ä�e˜SÔ!ØˆLÜ�eœSÔ!Ø—K‘K“MˆEðYÙ˜5“zÐ!ô Ø"¤4¨£; -Ð/HØ�|‰|ˆn˜Hð&ó
ð 	
øô ò YÜ  ?°5°'Ð9JÈ3Ï8É8Ë:È,Ð!WÓXÐXðYúó   °A Á)BN©Úreturnz	list[str])r   zOverlapFilter | strr-   r   )
r'   Ú
__module__Ú__qualname__Ú__doc__ÚNONEÚNON_MAX_SUPPRESSIONÚNON_MAX_MERGEÚclassmethodr   r)   © r   r   r   r      s?   „ ñð €DØ/ÐØ#€Màò;ó ð;ð ò
ó ñ
r   r   c                  ó<   — e Zd ZdZdZdZedd„«       Zedd„«       Zy)	ÚOverlapMetrica  
    Enum specifying the metric for measuring overlap between detections.

    Attributes:
        IOU: Intersection over Union. A region-overlap metric that compares
            two shapes (usually bounding boxes or masks) by normalising the
            shared area with the area of their union.
        IOS: Intersection over Smaller, a region-overlap metric that compares
            two shapes (usually bounding boxes or masks) by normalising the
            shared area with the smaller of the two shapes.
    ÚIOUÚIOSc                ó.   — t        t        d„ | «      «      S )Nc                ó   — | j                   S r   r   r   s    r   r   z$OverlapMetric.list.<locals>.<lambda>H   r   r   r   r   s    r   r   zOverlapMetric.listF   r   r   c                ó  — t        || «      r|S t        |t        «      r|j                  «       }	  | |«      S t        dt        |«      › d| j                  › d�«      ‚# t        $ r  t        d|› d| j	                  «       › �«      ‚w xY wr!   )r"   r#   Úupperr%   r   r&   r'   r(   s     r   r)   zOverlapMetric.from_valueJ   r*   r+   Nr,   )r   úOverlapMetric | strr-   r7   )	r'   r.   r/   r0   r8   r9   r4   r   r)   r5   r   r   r7   r7   6   s9   „ ñ
ð €CØ
€Càò;ó ð;ð ò
ó ñ
r   r7   c                ó$  — t         j                  |«      }t        j                  | «      \  }}}}t        j                  |«      \  }}}	}
t	        ||«      }t	        ||«      }t        ||	«      }t        ||
«      }t	        d||z
  «      }t	        d||z
  «      }||z  }||z
  ||z
  z  }|	|z
  |
|z
  z  }|t         j                  k(  r	||z   |z
  }n/|t         j                  k(  rt        ||«      }nt        d|› d�«      ‚|dk  ryt        ||z  «      S )a.  
    Compute overlap metric between two bounding boxes.

    Supports standard IOU (intersection-over-union) and IOS
    (intersection-over-smaller-area) metrics. Returns the overlap value in range
    `[0, 1]`.

    Args:
        box_true: Ground truth box in format
          `(x_min, y_min, x_max, y_max)`.
        box_detection: Detected box in format
          `(x_min, y_min, x_max, y_max)`.
        overlap_metric: Overlap type.
          Use `OverlapMetric.IOU` for IOU or
          `OverlapMetric.IOS` for IOS. Defaults to `OverlapMetric.IOU`.

    Returns:
        Overlap value between boxes in `[0, 1]`.

    Raises:
        ValueError: If `overlap_metric` is not IOU or IOS.

    Examples:
        ```pycon
        >>> import supervision as sv
        >>> box_true = [100, 100, 200, 200]
        >>> box_detection = [150, 150, 250, 250]
        >>> sv.box_iou(box_true, box_detection, overlap_metric=sv.OverlapMetric.IOU)
        0.142857...
        >>> sv.box_iou(box_true, box_detection, overlap_metric=sv.OverlapMetric.IOS)
        0.25

        ```
    ç        úoverlap_metric ú5 is not supported, only 'IOU' and 'IOS' are supported)
r7   r)   ÚnpÚarrayÚmaxÚminr8   r9   r%   Úfloat)Úbox_trueÚbox_detectionÚoverlap_metricÚ
x_min_trueÚ
y_min_trueÚ
x_max_trueÚ
y_max_trueÚ	x_min_detÚ	y_min_detÚ	x_max_detÚ	y_max_detÚx_min_interÚy_min_interÚx_max_interÚy_max_interÚinter_wÚinter_hÚ
area_interÚ	area_trueÚarea_detÚ	area_norms                        r   Úbox_iour]   Z   s:  € ôN #×-Ñ-¨nÓ=€NÜ57·X±X¸hÓ5GÑ2€J�
˜J¨
Ü13·±¸-Ó1HÑ.€Iˆy˜) Yä�j )Ó,€KÜ�j )Ó,€KÜ�j )Ó,€KÜ�j )Ó,€Kä�#�{ [Ñ0Ó1€GÜ�#�{ [Ñ0Ó1€Gà˜7Ñ"€Jà˜jÑ(¨Z¸*Ñ-DÑE€IØ˜IÑ%¨)°iÑ*?Ñ@€Hàœ×*Ñ*Ò*Ø Ñ(¨:Ñ5‰	Ø	œ=×,Ñ,Ò	,Ü˜	 8Ó,‰	äØ˜nÐ-ð .1ð 1ó
ð 	
ð
 �CÒØä�˜iÑ'Ó(Ð(r   c                ó¾  — t         j                  |«      }| j                  \  }}}}|j                  \  }}}	}
| j                  d   |j                  d   }}|dk(  s|dk(  rPt	        t
        j                  t        j                     t        j                  ||ft        j                  ¬«      «      S t        j                  ||ft        j                  ¬«      }t        j                  |«      }t        j                  |«      }t        j                  |«      }t        j                  |dd…df   |ddd…f   |¬«       t        j                  |dd…df   |	ddd…f   |¬«       t        j                  |dd…df   |ddd…f   |¬«       t        j                  |dd…df   |
ddd…f   |¬«       t        j                  |||¬«       t        j                  |||¬«       t        j                  |dd|¬«       t        j                  |dd|¬«       ||z  }||z
  ||z
  z  }|	|z
  |
|z
  z  }|t         j                  k(  r|dd…df   |ddd…f   z   |z
  }nG|t         j                   k(  r%t        j                  |dd…df   |ddd…f   «      }nt#        d|› d�«      ‚t        j$                  |t        j                  ¬«      }t        j&                  ||||dkD  ¬«       |S )	a/  
    Compute pairwise overlap scores between batches of bounding boxes.

    Supports standard IOU (intersection-over-union) and IOS
    (intersection-over-smaller-area) metrics for all `boxes_true` and
    `boxes_detection` pairs. Returns a matrix of overlap values in range
    `[0, 1]`, matching each box from the first batch to each from the second.

    Args:
        boxes_true: Array of reference boxes in
            shape `(N, 4)` as `(x_min, y_min, x_max, y_max)`.
        boxes_detection: Array of detected boxes in
            shape `(M, 4)` as `(x_min, y_min, x_max, y_max)`.
        overlap_metric: Overlap type.
            Use `OverlapMetric.IOU` for intersection-over-union,
            `OverlapMetric.IOS` for intersection-over-smaller-area.
            Defaults to `OverlapMetric.IOU`.

    Returns:
        Overlap matrix of shape `(N, M)`, where entry
            `[i, j]` is the overlap between `boxes_true[i]` and
            `boxes_detection[j]`.

    Raises:
        ValueError: If `overlap_metric` is not IOU or IOS.

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> boxes_true = np.array([
        ...     [100, 100, 200, 200],
        ...     [300, 300, 400, 400]
        ... ])
        >>> boxes_detection = np.array([
        ...     [150, 150, 250, 250],
        ...     [320, 320, 420, 420]
        ... ])
        >>> sv.box_iou_batch(
        ...     boxes_true, boxes_detection, overlap_metric=sv.OverlapMetric.IOU
        ... )
        array([[0.14285..., 0.        ],
               [0.        , 0.47058...]], dtype=float32)
        >>> sv.box_iou_batch(
        ...     boxes_true, boxes_detection, overlap_metric=sv.OverlapMetric.IOS
        ... )
        array([[0.25, 0.  ],
               [0.  , 0.64]], dtype=float32)

        ```
    r   ©ÚdtypeN)Úoutr@   rA   rB   ©ra   Úwhere)r7   r)   ÚTÚshaper   ÚnptÚNDArrayrC   Úfloat32ÚemptyÚ
empty_likeÚmaximumÚminimumÚsubtractÚclipr8   r9   r%   Ú
zeros_likeÚdivide)Ú
boxes_trueÚboxes_detectionrJ   rK   rL   rM   rN   rO   rP   rQ   rR   Ú
count_trueÚ	count_detrS   rU   rT   rV   rY   rZ   r[   r\   ra   s                         r   Úbox_iou_batchru   ¢   sŽ  € ôp #×-Ñ-¨nÓ=€NØ5?·\±\Ñ2€J�
˜J¨
Ø1@×1BÑ1BÑ.€Iˆy˜) YØ&×,Ñ,¨QÑ/°×1FÑ1FÀqÑ1I�	€Jà�Q‚˜) qš.ÜÜ�K‰KœŸ
™
Ñ#¤R§X¡X¨z¸9Ð.EÌRÏZÉZÔ%Xó
ð 	
ô —(‘(˜J¨	Ð2¼"¿*¹*ÔE€KÜ—-‘- Ó,€KÜ—-‘- Ó,€KÜ—-‘- Ó,€Kä‡J�Jˆzš!˜T˜'Ñ" I¨d²A¨gÑ$6¸KÕHÜ‡J�Jˆzš!˜T˜'Ñ" I¨d²A¨gÑ$6¸KÕHÜ‡J�Jˆzš!˜T˜'Ñ" I¨d²A¨gÑ$6¸KÕHÜ‡J�Jˆzš!˜T˜'Ñ" I¨d²A¨gÑ$6¸KÕHô ‡K�K�˜[¨kÕ:Ü‡K�K�˜[¨kÕ:Ü‡G�GˆK˜˜d¨Õ4Ü‡G�GˆK˜˜d¨Õ4à˜{Ñ*€Jà˜jÑ(¨Z¸*Ñ-DÑE€IØ˜IÑ%¨)°iÑ*?Ñ@€Hàœ×*Ñ*Ò*Øša ˜gÑ&¨°$º°'Ñ):Ñ:¸ZÑG‰	Ø	œ=×,Ñ,Ò	,Ü—J‘J˜yª¨D¨Ñ1°8¸DÂ!¸GÑ3DÓE‰	äØ˜nÐ-ð .1ð 1ó
ð 	
ô
 $&§=¡=°Ä2Ç:Á:Ô#N€CÜ‡I�Iˆj˜)¨°IÀ±MÕBØ€Jr   c                ó&  — t        j                  d«      }| d   | d   | d   | d   z   | d   | d   z   f\  }}}}|d   |d   |d   |d   z   |d   |d   z   f\  }}	}
}t        ||«      }t        ||
«      }t        ||	«      }t        ||«      }t        ||z
  d«      t        ||z
  d«      z  }t        |
|z
  d«      t        ||	z
  d«      z  }t        ||z
  d«      t        ||z
  d«      z  }|rt	        |||z   z  «      S t	        |||z   |z
  |z   z  «      S )ax  
    Calculate the Jaccard index (intersection over union) between two bounding boxes.
    If a gt object is marked as "iscrowd", a dt is allowed to match any subregion
    of the gt. Choosing gt'=intersect(dt,gt). Since by definition union(gt',dt)=dt, computing
    iou(gt,dt,iscrowd) = iou(gt',dt) = area(intersect(gt,dt)) / area(dt)

    Args:
        box_a: Box coordinates in the format [x, y, width, height].
        box_b: Box coordinates in the format [x, y, width, height].
        iscrowd: Flag indicating if the second box is a crowd region or not.

    Returns:
        Jaccard index between the two bounding boxes.
    é   r   é   é   r@   )rC   ÚspacingrE   rF   rG   )Úbox_aÚbox_bÚis_crowdÚEPSÚxaÚyaÚx2aÚy2aÚxbÚybÚx2bÚy2bÚxiÚx2iÚyiÚy2iÚAaÚAbÚAis                      r   Ú_jaccardrŽ     sH  € ô  �*‰*�Q‹-€Cà˜Q‘x  q¡¨5°©8°e¸A±hÑ+>ÀÀaÁÈ5ÐQRÉ8Ñ@SÐSÑ€BˆˆC�Ø˜Q‘x  q¡¨5°©8°e¸A±hÑ+>ÀÀaÁÈ5ÐQRÉ8Ñ@SÐSÑ€BˆˆC�ô 
ˆR�‹€Bä
ˆc�3‹-€Cä	ˆR�‹€BÜ
ˆc�3‹-€Cô 
ˆS�2‰X�sÓ	œc #¨¡(¨CÓ0Ñ	0€BÜ	ˆS�2‰X�sÓ	œc #¨¡(¨CÓ0Ñ	0€BÜ	ˆS�2‰X�sÓ	œc #¨¡(¨CÓ0Ñ	0€BáÜ�R˜2 ™8‘_Ó%Ð%ä��r˜B‘w ‘| cÑ)Ñ*Ó+Ð+r   c                óÞ  — t        |«      t        | «      k(  sJ d«       ‚t        |«      dk(  st        | «      dk(  r>t        t        j                  t        j
                     t	        j                  g «      «      S t	        j                  t        |«      t        | «      ft        j
                  ¬«      }t        | «      D ]-  \  }}t        |«      D ]  \  }}t        ||||   «      |||f<   Œ Œ/ |S )a  
    Calculate the intersection over union (IoU) between detection bounding boxes (dt)
    and ground-truth bounding boxes (gt).
    Reference: https://github.com/rafaelpadilla/review_object_detection_metrics

    Args:
        boxes_true: List of ground-truth bounding boxes in the
            format [x, y, width, height].
        boxes_detection: List of detection bounding boxes in the
            format [x, y, width, height].
        is_crowd: List indicating if each ground-truth bounding box
            is a crowd region or not.

    Returns:
        Array of IoU values of shape (len(dt), len(gt)).

    Examples:
        ```pycon
        >>> import numpy as np
        >>> import supervision as sv
        >>> boxes_true = [
        ...     [10, 20, 30, 40],  # x, y, w, h
        ...     [15, 25, 35, 45]
        ... ]
        >>> boxes_detection = [
        ...     [12, 22, 28, 38],
        ...     [16, 26, 36, 46]
        ... ]
        >>> is_crowd = [False, False]
        >>> ious = sv.box_iou_batch_with_jaccard(
        ...     boxes_true=boxes_true,
        ...     boxes_detection=boxes_detection,
        ...     is_crowd=is_crowd
        ... )
        >>> ious  # doctest: +ELLIPSIS
        array([[0.886..., 0.496...],
               [0.4  ..., 0.862...]])

        ```
    z4`is_crowd` must have the same length as `boxes_true`r   r_   )
Úlenr   rf   rg   rC   Úfloat64rD   ÚzerosÚ	enumeraterŽ   )rq   rr   r}   ÚiousÚgt_idxÚgt_boxÚdet_idxÚdet_boxs           r   Úbox_iou_batch_with_jaccardr™   0  sà   € ôZ ˆx‹=œC 
›OÒ+ð Ø>óÐ+ô ˆ?Ó˜qÒ ¤C¨
£O°qÒ$8Ü”C—K‘K¤§
¡
Ñ+¬R¯X©X°b«\Ó:Ð:Ü$&§H¡HÜ	ˆ_Ó	œs :›Ð/´r·z±zô%€Dô $ JÓ/ò P‰ˆ�Ü )¨/Ó :ò 	PÑˆG�WÜ$,¨W°f¸hÀvÑ>NÓ$OˆD�˜&�Ò!ñ	PðPð €Kr   c           	     óB  — | dd…dd…df   }| dd…dd…df   }|t        j                  |dd¬«      z  t        j                  |dd¬«      |z  z
  }t        t        j                  t         j
                     dt        j                  |j                  d¬«      «      z  «      S )zÊCompute the area of each oriented-box polygon using the shoelace formula.

    Args:
        polygons: ``(N, 4, 2)`` array of polygon corners.

    Returns:
        ``(N,)`` array of polygon areas.
    Nr   rw   éÿÿÿÿ©Úaxisç      à?)rC   Úrollr   rf   rg   ÚfloatingÚabsÚsum)ÚpolygonsÚxÚyÚcrosss       r   Ú_polygon_areasr§   k  s…   € ð 	’’A�q�Ñ€AØ’’A�q�Ñ€AØ”—‘˜˜2 AÔ&Ñ&¬¯©°°B¸QÔ)?À!Ñ)CÑC€EÜ”—‘œBŸK™KÑ(¨#´·±°u·y±yÀa°yÓ7HÓ0IÑ*IÓJÐJr   c                óè   — | dd…dd…df   }| dd…dd…df   }t        j                  |j                  d¬«      |j                  d¬«      |j                  d¬«      |j                  d¬«      gd¬«      S )zàCompute the axis-aligned bounding envelope of each oriented box.

    Args:
        polygons: ``(N, 4, 2)`` array of polygon corners.

    Returns:
        ``(N, 4)`` array of ``(x_min, y_min, x_max, y_max)`` envelopes.
    Nr   rw   rœ   )rC   ÚstackrF   rE   )r£   ÚxsÚyss      r   Ú_aabb_envelopesr¬   z  sk   € ð 
’!’Q˜�'Ñ	€BØ	’!’Q˜�'Ñ	€BÜ�8‰8Ø	�‰�Qˆ‹˜Ÿ™ Q˜›¨¯©°Q¨«¸¿¹ÀQ¸»ÐHÈqôð r   c                óä  — | dd…ddd…f   }|ddd…dd…f   }t        j                  |d   |d   «      t        j                  |d   |d   «      kD  t        j                  |d   |d   «      t        j                  |d   |d   «      kD  z  }t        t        t
        j                  t         j                     t
        j                  t         j                     f   t        j                  |«      «      S )a*  Return index pairs ``(i, j)`` whose axis-aligned envelopes overlap.

    Uses a fused boolean evaluation to halve peak transient memory compared to
    named-intermediate form (4 separate NxM float64 arrays vs 1 boolean array).

    Note:
        This gate is a correctness guarantee, not an approximation: if two
        axis-aligned bounding boxes do not overlap, the convex polygons they
        contain cannot overlap either.

    Args:
        envelopes_true: ``(N, 4)`` array of ``(x_min, y_min, x_max, y_max)``
            envelopes for the ground-truth boxes.
        envelopes_detection: ``(M, 4)`` array of ``(x_min, y_min, x_max, y_max)``
            envelopes for the detection boxes.

    Returns:
        A pair of 1-D index arrays ``(rows, cols)`` identifying the overlapping
        pairs.
    N).rx   ).r   ).ry   ).rw   )	rC   rl   rk   r   Útuplerf   rg   ÚintpÚnonzero)Úenvelopes_trueÚenvelopes_detectionÚetÚedÚoverlaps        r   Ú_overlapping_envelope_pairsr¶   Š  sÄ   € ð0 
š˜4¢˜
Ñ	#€BØ	˜T¢1¢a˜ZÑ	(€Bä
�
‰
�2�f‘:˜r &™zÓ*¬R¯Z©Z¸¸6¹
ÀBÀvÁJÓ-OÑOÜ	�‰�B�v‘J  6¡
Ó	+¬b¯j©j¸¸F¹ÀRÈÁZÓ.PÑ	PñR€Gô ””c—k‘k¤"§'¡'Ñ*¬C¯K©K¼¿¹Ñ,@Ð@ÑAÄ2Ç:Á:ÈgÓCVÓWÐWr   c                óV  — d| fd|ffD ]©  \  }}|j                   dk(  r.|j                  dd dk7  rt        d|› d|j                  › d	�«      ‚|j                   d
k(  r.|j                  d   dk7  rt        d|› d|j                  › d�«      ‚|j                   dvsŒ�t        d|› d|j                  › d�«      ‚ |t        j                  k(  rd}n%|t        j
                  k(  rd}nt        d|› d�«      ‚| |u }| j                  ddd
«      j                  t        j                  «      } |j                  ddd
«      j                  t        j                  «      }t        | «      t        |«      }}|dk(  s|dk(  r't        j                  ||ft        j                  ¬«      S t        | «      }	t        |«      }
t        | «      }|r|n
t        |«      }t        ||«      \  }}|r||k  }||   ||   }}| D �cg c]!  }|j                  t        j                  «      ‘Œ# }}|D �cg c]!  }|j                  t        j                  «      ‘Œ# }}t        j                  ||ft        j                  ¬«      }t!        ||«      D ]h  \  }}t#        j$                  ||   ||   «      \  }}|dk  rŒ+|r|	|   |
|   z   |z
  nt'        |	|   |
|   «      }|dkD  sŒS||z  }||||f<   |sŒb||||f<   Œj t)        t*        j,                  t        j.                     t        j0                  |dd«      «      S c c}w c c}w )u�  
    Compute pairwise overlap scores between two sets of oriented bounding boxes
    using the configured `overlap_metric`.

    Overlap areas are computed exactly via convex-polygon intersection, gated by
    a cheap axis-aligned envelope pre-filter â€” no rasterization is involved, so
    the result is exact (free of pixel-quantization error) and independent of the
    coordinate magnitudes.

    `boxes_true` and `boxes_detection` are expected to be in
    `((x1, y1), (x2, y2), (x3, y3), (x4, y4))` format.

    Note:
        Inputs must be **convex** quads with finite coordinates. Self-intersecting
        or non-convex polygons produce undefined results via
        ``cv2.intersectConvexConvex``. NaN or Inf coordinates propagate silently
        as ``0.0`` â€” validate inputs before calling if needed.

        When ``boxes_true is boxes_detection`` (the same Python object, not just
        equal values), the function computes only the upper triangle of the
        matrix and mirrors it. This optimization is used automatically by the
        NMS/NMM callers that pass the same array twice. A defensive ``.copy()``
        at the call site would disable the optimization silently â€” see the
        NMS caller comment for context.

    Args:
        boxes_true: A `np.ndarray` representing ground-truth boxes.
            `shape = (N, 4, 2)` where `N` is number of true objects.
            Last axis convention: `[..., 0]` = x-coordinates,
            `[..., 1]` = y-coordinates.
        boxes_detection: A `np.ndarray` representing detection boxes.
            `shape = (M, 4, 2)` where `M` is number of detected objects.
            Last axis convention: `[..., 0]` = x-coordinates,
            `[..., 1]` = y-coordinates.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of oriented boxes (e.g., IoU, IoS).

    Returns:
        Overlap matrix of shape `(N, M)`, where entry `[i, j]` is the overlap
        score between `boxes_true[i]` and `boxes_detection[j]`, in the range
        `[0, 1]` under the configured :attr:`overlap_metric`.

    Raises:
        ValueError: If ``boxes_true`` or ``boxes_detection`` is 3-D with inner
            dimensions other than ``(4, 2)``.
        ValueError: If ``boxes_true`` or ``boxes_detection`` is 2-D with a
            column count other than 8.
        ValueError: If ``boxes_true`` or ``boxes_detection`` is not 2-D or 3-D.
        ValueError: If ``overlap_metric`` is not
            :attr:`~supervision.config.OverlapMetric.IOU` or
            :attr:`~supervision.config.OverlapMetric.IOS`.

    Examples:
        >>> import numpy as np
        >>> import supervision as sv
        >>> a = np.array([[[0, 0], [2, 0], [2, 2], [0, 2]]], dtype=np.float32)
        >>> b = np.array([[[1, 0], [3, 0], [3, 2], [1, 2]]], dtype=np.float32)
        >>> sv.oriented_box_iou_batch(a, b)  # doctest: +ELLIPSIS
        array([[0.333...]])
    rq   rr   ry   rw   N©é   rx   ú`ú` has shape õV   ; expected (N, 4, 2) â€” each box must have exactly 4 corners with (x, y) coordinates.rx   é   úF; expected (N, 8) for flat YOLO format or (N, 4, 2) for corner format.©rx   ry   ú1` must be 2-D (N, 8) or 3-D (N, 4, 2), got shape ú.TFrA   rB   r›   r¹   r   r_   r@   g      ð?)Úndimre   r%   r7   r8   r9   ÚreshapeÚastyperC   r‘   r�   r’   r§   r¬   r¶   rh   ÚzipÚcv2ÚintersectConvexConvexrF   r   rf   rg   r    rn   )rq   rr   rJ   ÚnameÚarrÚnormalize_by_unionÚis_self_comparisonÚnÚmÚ
areas_trueÚareas_detectionr±   r²   ÚrowsÚcolsr=   ÚboxÚpolygons_trueÚpolygons_detectionr”   ÚiÚjÚintersectionÚ_ÚdenominatorÚscores                             r   Úoriented_box_iou_batchrÛ   ª  sR  € ðD $ ZÐ0Ð3DÀoÐ2VÐWò ‰	ˆˆcØ�8‰8�qŠ=˜SŸY™Y q r˜]¨fÒ4ÜØ�D�6˜ c§i¡i [ð 1Tð Uóð ð �X‰X˜Š]˜sŸy™y¨™|¨qÒ0ÜØ�D�6˜ c§i¡i [ð 1>ð ?óð ð �X‰X˜VÒ#ÜØ�D�6ÐJÈ3Ï9É9È+ÐUVÐWóð ðð  œ×*Ñ*Ò*Ø!ÑØ	œ=×,Ñ,Ò	,Ø"ÑäØ˜nÐ-ð .1ð 1ó
ð 	
ð $ Ð6ÐØ×#Ñ# B¨¨1Ó-×4Ñ4´R·Z±ZÓ@€JØ%×-Ñ-¨b°!°QÓ7×>Ñ>¼r¿z¹zÓJ€Oäˆz‹?œC Ó0€q€AØˆA‚v��a’Ü�x‰x˜˜A˜¤b§j¡jÔ1Ð1ä 
Ó+€JÜ$ _Ó5€Oä$ ZÓ0€Ná,‰´/À/Ó2Rð ô -¨^Ð=PÓQ�J€Dˆ$ÙØ˜‘ˆØ˜%‘[ $ u¡+ˆdˆà7AÖB°�S—Z‘Z¤§
¡
Õ+ÐB€MÐBØ<KÖL°S˜#Ÿ*™*¤R§Z¡ZÕ0ÐLÐÐLä$&§H¡H¨a°¨V¼2¿:¹:Ô$F€DÜ�D˜$“ò #‰ˆˆ1Ü×3Ñ3Ø˜!ÑÐ0°Ñ3ó
‰ˆ�að ˜1ÒØñ "ð �q‰M˜O¨AÑ.Ñ.°Ò=ä�Z ‘] O°AÑ$6Ó7ð 	ð
 ˜‹?Ø  ;Ñ.ˆEØˆD��A�‰JÚ!Ø"��Q˜�T’
ð#ô, ”—‘œBŸK™KÑ(¬"¯'©'°$¸¸SÓ*AÓBÐBùò5 CùÚLs   Ç/&L!È&L&c                óÒ  — t        | «      }t        |«      }t        j                  ||ft        ¬«      }|dk(  s|dk(  r|S | j                  }|j                  }| j
                  j                  t        j                  «      }|dd…df   }	|dd…df   }
|dd…df   }|dd…df   }|j
                  j                  t        j                  «      }|dd…df   }|dd…df   }|dd…df   }|dd…df   }t        j                  |	dd…df   |ddd…f   «      }t        j                  |
dd…df   |ddd…f   «      }t        j                  |dd…df   |ddd…f   «      }t        j                  |dd…df   |ddd…f   «      }||k  ||k  z  }i }i }t        j                  |«      D �]½  }t        |d   «      t        |d   «      }}||vr| j                  |«      ||<   ||vr|j                  |«      ||<   t        |||f   «      }t        |||f   «      }t        |||f   «      }t        |||f   «      }t        |	|   «      t        |
|   «      }!} ||   ||!z
  ||!z
  dz   …|| z
  || z
  dz   …f   }"t        ||   «      t        ||   «      }$}#||   ||$z
  ||$z
  dz   …||#z
  ||#z
  dz   …f   }%t        t        j                  |"|%«      j                  «       «      }&t        ||   «      }'t        ||   «      }(|t        j                   k(  r|'|(z   |&z
  })|)dkD  r|&|)z  nd|||f<   �Œ|t        j"                  k(  rt%        |'|(«      }*|*dkD  r|&|*z  nd|||f<   �Œ±t'        d|› d	�«      ‚ |S )
u.  Compute pairwise overlap between two :class:`CompactMask` collections.

    Avoids materialising full ``(N, H, W)`` arrays by:

    1. Vectorised bounding-box pre-filter â€” pairs whose boxes do not overlap
       get IoU = 0 without any mask decoding.
    2. Sub-crop decoding â€” for overlapping pairs, only the intersection region
       of each crop is decoded and compared.
    3. Crop caching â€” each individual crop is decoded at most once even when it
       participates in many pairs.

    The result is numerically identical to running the dense
    :func:`mask_iou_batch` on ``np.asarray(masks_true)`` /
    ``np.asarray(masks_detection)``.

    Args:
        masks_true: :class:`~supervision.detection.compact_mask.CompactMask`
            holding the ground-truth masks.
        masks_detection: :class:`~supervision.detection.compact_mask.CompactMask`
            holding the detection masks.
        overlap_metric: :class:`OverlapMetric` â€” ``IOU`` or ``IOS``.

    Returns:
        Float array of shape ``(N1, N2)`` with pairwise overlap values.
    r_   r   Nrw   rx   ry   r@   rA   rB   )r�   rC   r’   rG   ÚareaÚ	bbox_xyxyrÄ   Úint32rk   rl   ÚargwhereÚintÚcropÚlogical_andr¢   r7   r8   r9   rF   r%   )+Ú
masks_trueÚmasks_detectionrJ   Ún1Ún2ÚresultÚareas_aÚareas_bÚbboxes_aÚx1aÚy1ar�   r‚   Úbboxes_bÚx1bÚy1br…   r†   Úix1Úiy1Úix2Úiy2Úbbox_overlapÚcrops_aÚcrops_bÚidx_pairÚidx_aÚidx_bÚlx1Úly1Úlx2Úly2Úox_aÚoy_aÚsub_aÚox_bÚoy_bÚsub_bÚinterÚarea_a_iÚarea_b_jÚunionÚsmalls+                                              r   Úcompact_mask_iou_batchr
  9  s®  € ô< �*‹o€BÜ�/Ó"€BÜ')§x¡x°°R°ÄÔ'F€Fà	ˆQ‚w�"˜’'Øˆà%/§_¡_€GØ%4×%9Ñ%9€Gð '1×&:Ñ&:×&AÑ&AÄ"Ç(Á(Ó&K€HØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€Cà&5×&?Ñ&?×&FÑ&FÄrÇxÁxÓ&P€HØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€CØ!)ª!¨Q¨$¡€Cô "$§¡¨C²°4°©L¸#¸dÂA¸g¹,Ó!G€CÜ!#§¡¨C²°4°©L¸#¸dÂA¸g¹,Ó!G€CÜ!#§¡¨C²°4°©L¸#¸dÂA¸g¹,Ó!G€CÜ!#§¡¨C²°4°©L¸#¸dÂA¸g¹,Ó!G€CØ+.°#©:¸#À¹*Ñ*E€Lð 13€GØ02€Gä—K‘K Ó-ó !ˆÜ˜8 A™;Ó'¬¨X°a©[Ó)9ˆuˆà˜ÑØ'Ÿ_™_¨UÓ3ˆG�E‰NØ˜ÑØ,×1Ñ1°%Ó8ˆG�E‰Nä�#�e˜U�lÑ#Ó$ˆÜ�#�e˜U�lÑ#Ó$ˆÜ�#�e˜U�lÑ#Ó$ˆÜ�#�e˜U�lÑ#Ó$ˆä˜˜U™“_¤c¨#¨e©*£oˆdˆØ˜‘˜s T™z¨C°$©J¸©NÐ:¸CÀ$¹JÈÈtÉÐVWÉÐ<WÐWÑXˆä˜˜U™“_¤c¨#¨e©*£oˆdˆØ˜‘˜s T™z¨C°$©J¸©NÐ:¸CÀ$¹JÈÈtÉÐVWÉÐ<WÐWÑXˆä”B—N‘N 5¨%Ó0×4Ñ4Ó6Ó7ˆÜ�w˜u‘~Ó&ˆÜ�w˜u‘~Ó&ˆàœ]×.Ñ.Ò.Ø˜xÑ'¨%Ñ/ˆEØ49¸A²I 5¨5¢=À3ˆF�5˜%�<Ó Øœ}×0Ñ0Ò0Ü˜ (Ó+ˆEØ49¸A²I 5¨5¢=À3ˆF�5˜%�<Ó äØ! .Ð!1ð 25ð 5óð ð=!ðF €Mr   c                ó>  — t        t        j                  | j                  dd «      «      }|dk  rt        j                  nt        j
                  }| j                  | j                  d   |«      j                  |d¬«      }|j                  |j                  d   |«      j                  |d¬«      }t        j                  ddd¬«      5  ||j                  z  }ddd«       |j                  d¬	«      }|j                  d¬	«      }	|t        j                  k(  rE|dd…df   |	z   z
  }
t        j                  ||
t        j                  |t        ¬
«      |
dk7  ¬«      }nu|t        j                   k(  rSt        j"                  |dd…df   |	«      }t        j                  |t        j                  |t        ¬
«      |dk7  ¬«      }nt%        d|› d�«      ‚t        j&                  |«      }t)        t*        j,                  t        j.                     |«      S # 1 sw Y   �Œ;xY w)aï  
    Internal function.
    Compute Intersection over Union (IoU) of two sets of masks -
        `masks_true` and `masks_detection`.

    Args:
        masks_true: 3D `np.ndarray` representing ground-truth masks.
        masks_detection: 3D `np.ndarray` representing detection masks.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of masks (e.g., IoU, IoS).

    Returns:
        Pairwise IoU of masks from `masks_true` and `masks_detection`.
    rw   Né   r   F)ÚcopyÚignore)rp   ÚoverÚinvalidrœ   r_   rb   rA   rB   )rá   rC   Úprodre   rh   r‘   rÃ   rÄ   Úerrstaterd   r¢   r7   r8   rp   ro   rG   r9   rl   r%   Ú
nan_to_numr   rf   rg   r    )rä   rå   rJ   ÚpixelsÚcount_dtypeÚ	true_flatÚdetection_flatÚintersection_areaÚmasks_true_areaÚmasks_detection_areaÚ
union_arear”   Ú
small_areas                r   Ú_mask_iou_batch_splitr     sô  € ô. ”—‘˜×)Ñ)¨!¨"Ð-Ó.Ó/€FØ &¨%¢”"—*’*´R·Z±Z€KØ×"Ñ" :×#3Ñ#3°AÑ#6¸Ó?×FÑFØ˜%ð Gó €Ið %×,Ñ,¨_×-BÑ-BÀ1Ñ-EÀvÓN×UÑUØ˜%ð Vó €Nô 
�‰˜H¨8¸XÔ	Fñ XØ;DÀ~×GWÑGWÑ;WÐ÷Xð  —m‘m¨�mÓ+€OØ)×-Ñ-°1Ð-Ó5Ðàœ×*Ñ*Ò*Ø$¢Q¨ WÑ-Ð0DÑDÐGXÑXˆ
Ü�y‰yØØÜ—‘Ð/´uÔ=Ø ‘/ô	
‰ð 
œ=×,Ñ,Ò	,ä—Z‘Z ²°4°Ñ 8Ð:NÓOˆ
Ü�y‰yØØÜ—‘Ð/´uÔ=Ø ‘/ô	
‰ô Ø˜nÐ-ð .1ð 1ó
ð 	
ô
 �=‰=˜Ó€DÜ”—‘œBŸK™KÑ(¨$Ó/Ð/÷=Xñ Xús   Ã	HÈHi   c           	     ó  — t        | t        «      rt        |t        «      rt        | ||«      S t        | t        «      rt        j                  | «      } t        |t        «      rt        j                  |«      }| j
                  dk7  s|j
                  dk7  r&t        d| j
                  › d|j
                  › d�«      ‚| j                  dd |j                  dd k7  r,t        d| j                  dd › d|j                  dd › d�«      ‚| j                  d	   d	k(  s|j                  d	   d	k(  rt        | ||«      S | j                  d   | j                  d
   z  }|dk  rdnd}|dz  dz  }|j                  d	   |z  |z  }||z  d|j                  d	   z  dz  z   }||cxkD  rd	kD  r,n n)t        j                  d|dz  dz  › d|› d�t        d
¬«       || j                  d	   |z  z   |k  rt        | ||«      S g }	t        ||z
  |z  d«      }
t        d	| j                  d	   |
«      D ]$  }|	j                  t        | |||
z    ||«      «       Œ& t        t         j"                  t        j$                     t        j&                  |	«      «      S )aÀ  
    Compute Intersection over Union (IoU) of two sets of masks -
        `masks_true` and `masks_detection`.

    Accepts both dense ``(N, H, W)`` boolean arrays and
    :class:`~supervision.detection.compact_mask.CompactMask` objects.
    When both inputs are :class:`~supervision.detection.compact_mask.CompactMask`,
    the computation uses :func:`compact_mask_iou_batch` to avoid materialising
    full ``(N, H, W)`` arrays.

    Args:
        masks_true: 3D `np.ndarray` representing ground-truth masks.
        masks_detection: 3D `np.ndarray` representing detection masks.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of masks (e.g., IoU, IoS).
        memory_limit: Memory limit in MB, default is 1024 * 5 MB (5GB).
            Controls chunking of ``masks_true`` so that flattened detection
            masks plus each chunk's buffers stay within this limit. A
            ``UserWarning`` is raised when ``masks_detection`` alone
            exceeds the limit, as chunking cannot reduce peak memory
            below that floor. Ignored when both inputs are
            :class:`~supervision.detection.compact_mask.CompactMask`.

    Returns:
        Pairwise IoU of masks from `masks_true` and `masks_detection`.

    Raises:
        ValueError: If ``masks_true`` or ``masks_detection`` are not 3D
            ``(N, H, W)`` arrays, or if they do not share the same
            spatial dimensions ``(H, W)``.
    ry   z>masks_true and masks_detection must be 3D (N, H, W); got ndim=z
 and ndim=rÁ   rw   Nz?masks_true and masks_detection must share the same (H, W); got ú and r   rx   r  r¹   r½   i   zdetection masks (z MB) exceed memory_limit (z: MB); chunking cannot reduce peak memory below this floor.)Ú
stacklevel)r"   r   r
  rC   ÚasarrayrÂ   r%   re   r  ÚwarningsÚwarnÚUserWarningrE   ÚrangeÚappendr   rf   rg   r    Úvstack)rä   rå   rJ   Úmemory_limitr  ÚitemsizeÚlimit_bytesÚdetection_bytesÚper_true_rowr”   ÚstepÚchunk_starts               r   Úmask_iou_batchr/  à  s¹  € ôL �*œkÔ*¬z¸/Ì;Ô/WÜ% j°/À>ÓRÐRô �*œkÔ*Ü—Z‘Z 
Ó+ˆ
Ü�/¤;Ô/ÜŸ*™* _Ó5ˆà‡�˜!Ò˜×3Ñ3°qÒ8ÜðØ—O‘OÐ$ J¨×/CÑ/CÐ.DÀAðGó
ð 	
ð ×Ñ˜˜Ð˜×4Ñ4°Q°RÐ8Ò8ÜØMØ×Ñ  Ð#Ð$ E¨/×*?Ñ*?ÀÀÐ*CÐ)DÀAðGó
ð 	
ð
 ×Ñ˜Ñ˜aÒ ?×#8Ñ#8¸Ñ#;¸qÒ#@Ü$ Z°À.ÓQÐQð ×Ñ˜aÑ  :×#3Ñ#3°AÑ#6Ñ6€FØ˜e’O‰q¨€HØ Ñ%¨Ñ,€KØ%×+Ñ+¨AÑ.°Ñ7¸(ÑB€OØ˜HÑ$ q¨?×+@Ñ+@ÀÑ+CÑ'CÀaÑ'GÑG€LØ˜Ô( qÕ(Ü�‰Ø °4Ñ 7¸4Ñ ?Ð@ð AØ)˜Nð +'ð'ô Øõ	
ð ˜×)Ñ)¨!Ñ,¨|Ñ;Ñ;¸{ÒJÜ$ Z°À.ÓQÐQà€DÜ�˜oÑ-°,Ñ>ÀÓB€DÜ˜Q 
× 0Ñ 0°Ñ 3°TÓ:ò 
ˆØ�‰Ü!Ø˜;¨°tÑ);Ð<ØØóõ	
ð
ô ”—‘œBŸK™KÑ(¬"¯)©)°D«/Ó:Ð:r   rž   i€  c                ór  — d|cxk  rdk  sn J d|› d�«       ‚| j                   \  }}|dk(  r(t        j                  | t        j                  |«      f   } | dd…df   j	                  «       ddd…   }| |   } ||   }t        |||«      }| dd…df   }	t        j                  |t        ¬	«      }
t        |«      D ]B  }|
|   sŒ	||   |kD  |	|   |	k(  z  }t        j                  ||dz   d d
|
|dz   d «      |
|dz   d ŒD t        t        j                  t        j                     |
|j	                  «          «      S )u‘  
    Perform Non-Maximum Suppression (NMS) on segmentation predictions.

    IoU is computed exactly on the full-resolution masks for both dense and
    :class:`~supervision.detection.compact_mask.CompactMask` inputs.  The
    ``mask_dimension`` parameter is kept for backward compatibility but is no
    longer used â€” dense masks are **not** resized before IoU computation.

    Args:
        predictions: A 2D array of object detection predictions in
            the format of `(x_min, y_min, x_max, y_max, score)`
            or `(x_min, y_min, x_max, y_max, score, class)`. Shape: `(N, 5)` or
            `(N, 6)`, where N is the number of predictions.
        masks: A 3D array of binary masks corresponding to the predictions.
            Shape: `(N, H, W)`, where N is the number of predictions, and H, W are the
            dimensions of each mask.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of masks (e.g., IoU, IoS).
        mask_dimension: Deprecated, no longer used. Kept for backward
            compatibility.

    Returns:
        A boolean array indicating which predictions to keep after
            non-maximum suppression.

    Raises:
        AssertionError: If `iou_threshold` is not within the closed
            range from `0` to `1`.
    r   rw   úBValue of `iou_threshold` must be in the closed range from 0 to 1, ú given.é   Nr¹   r›   r_   F)re   rC   Úc_r’   Úargsortr/  ÚonesÚboolr%  rc   r   rf   rg   Úbool_)ÚpredictionsÚmasksÚiou_thresholdrJ   Úmask_dimensionrÐ   ÚcolumnsÚ
sort_indexr”   Ú
categoriesÚkeepÚrow_idxÚ	conditions                r   Úmask_non_max_suppressionrC  @  s]  € ðL �Ô" Ô"ð ØLØˆ/˜ð	"óÐ"ð  ×%Ñ%�M€Dˆ'à�!‚|Ü—e‘e˜K¬¯©°$«Ð7Ñ8ˆàšQ ˜TÑ"×*Ñ*Ó,©T¨r¨TÑ2€JØ˜jÑ)€KØ�*Ñ€Eä˜% ¨Ó7€DØšQ ˜TÑ"€Jä�7‰7�4œtÔ$€DÜ˜“;ò ˆØ�‹=Ø˜g™¨Ñ6Ø˜7Ñ# zÑ1ñˆIô #%§(¡(Ø˜' A™+˜-Ð(¨%°°gÀ±k°mÐ1Dó#ˆD�˜1‘�Ñðô ”—‘œBŸH™HÑ% t¨J×,>Ñ,>Ó,@Ñ'AÓBÐBr   c                óô   — | j                   \  }}|dk(  r(t        j                  | t        j                  |«      f   } t        j                  | dd…df   j                  «       «      }| |   } | dd…df   }|| |fS )zÏAdd an agnostic class column when missing, sort by descending score.

    Returns the score-descending sort index, the reordered predictions, and the
    category vector for the loop callers to consume.
    r3  Nr¹   )re   rC   r4  r’   Úflipr5  )r9  rÐ   r=  r>  r?  s        r   Ú_prepare_predictions_for_nmsrF  ƒ  sz   € ð  ×%Ñ%�M€Dˆ'Ø�!‚|Ü—e‘e˜K¬¯©°$«Ð7Ñ8ˆÜ—‘˜¢Q¨ TÑ*×2Ñ2Ó4Ó5€JØ˜jÑ)€KØšQ ˜TÑ"€JØ�{ JÐ.Ð.r   c                óð   — t        | «      }| t        j                  |«      z
  } t        j                  |t        ¬«      }t        t        | |«      «      D ]  \  }\  }}||   sŒ||kD  ||k(  z  }|| z  }Œ! |S )a  Greedy NMS suppression loop given a precomputed pairwise IoU matrix.

    Assumes `ious` is square with row/column order matching `categories`.
    Detections sharing a category whose IoU exceeds `iou_threshold` are dropped
    in favour of the higher-confidence entry.
    r_   )r�   rC   Úeyer6  r7  r“   rÅ   )	r”   r?  r;  rÐ   r@  ÚindexÚiouÚcategoryrB  s	            r   Ú_nms_loop_from_iou_matrixrL  ”  s„   € ô ˆt‹9€DØ”"—&‘&˜“,Ñ€DÜ"$§'¡'¨$´dÔ";€DÜ"+¬C°°jÓ,AÓ"Bò !Ñˆ‰��XØ�EŠ{ØØ˜=Ñ(¨Z¸8Ñ-CÑDˆ	Ø�y�jÑ ‰ð	!ð
 €Kr   c                ó   — d|cxk  rdk  sn J d|› d�«       ‚t        | «      \  }} }t        | dd…dd…f   | dd…dd…f   |«      }t        |||«      }t        t        j
                  t        j                     ||j                  «          «      S )aê  
    Perform Non-Maximum Suppression (NMS) on object detection predictions.

    Args:
        predictions: An array of object detection predictions in
            the format of `(x_min, y_min, x_max, y_max, score)`
            or `(x_min, y_min, x_max, y_max, score, class)`.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of boxes (e.g., IoU, IoS).

    Returns:
        A boolean array indicating which predictions to keep after
            non-maximum suppression.

    Raises:
        AssertionError: If `iou_threshold` is not within the
            closed range from `0` to `1`.
    r   rw   r1  r2  Nr¹   )	rF  ru   rL  r   rf   rg   rC   r8  r5  )r9  r;  rJ   r>  r?  r”   r@  s          r   Úbox_non_max_suppressionrN  ª  sŸ   € ð2 �Ô" Ô"ð ØLØˆ/˜ð	"óÐ"ô +GÀ{Ó*SÑ'€J�˜ZÜ˜¢Q¨¨¨ UÑ+¨[º¸B¸Q¸B¸Ñ-?ÀÓP€DÜ$ T¨:°}ÓE€DÜ”—‘œBŸH™HÑ% t¨J×,>Ñ,>Ó,@Ñ'AÓBÐBr   c                ó®  — g }| dd…df   }|j                  «       }t        |«      dkD  �r*t        |d   «      }|dd }t        |«      dk(  r|j                  |g«       	 |S ||   d   }|g}	t        |«      dkD  rºt	        ||   ||«      }
|
j                  «       |k\  }|j                  «       sn†||   }t        j                  j                  t        j                  ||   |g«      dd¬«      }|	j                  t        j                  |«      j                  «       «       ||    }t        |«      dkD  rŒº|j                  |	«       t        |«      dkD  r�Œ*|S )aË  
    Apply greedy version of non-maximum merging to avoid detecting too many

    Args:
        predictions: An array of shape `(n, 5)` containing
            the bounding boxes coordinates in format `[x1, y1, x2, y2]`
            and the confidence scores.
        masks: A 3D array of binary masks corresponding to
            the predictions.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression. Defaults to 0.5.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of masks (e.g., IoU, IoS).

    Returns:
        Groups of prediction indices to be merged.
            Each group may have 1 or more elements.
    Nr¹   r   r›   ©N.T)r�   Úkeepdims)r5  r�   rá   r&  r/  ÚflattenÚanyrC   Ú
logical_orÚreduceÚconcatenateÚextendrE  Útolist)r9  r:  r;  rJ   Úmerge_groupsÚscoresÚorderÚidxÚmerge_candidateÚcandidate_groupsr”   Úabove_thresholdÚ	above_idxs                r   Ú_group_overlapping_masksra  Í  sa  € ð0 %'€Làš˜A˜Ñ€FØ�N‰NÓ€Eä
ˆe‹*�q‹.Ü�%˜‘)‹nˆà�c�r�
ˆÜˆu‹:˜Š?Ø×Ñ  Ô&Øð& Ðð#   ™* YÑ/ˆØ˜5ÐÜ�%‹j˜1ŠnÜ! %¨¡,°ÀÓPˆDØ59·\±\³^À}Ñ5TˆOØ"×&Ñ&Ô(ØØ˜oÑ.ˆIÜ Ÿm™m×2Ñ2Ü—‘  iÑ 0°/ÐBÓCØØð 3ó ˆOð
 ×#Ñ#¤B§G¡G¨IÓ$6×$=Ñ$=Ó$?Ô@Ø˜?Ð*Ñ+ˆEô �%‹j˜1‹nð 	×ÑÐ,Ô-ô1 ˆe‹*�qŒ.ð2 Ðr   c                ó  — t        |t        «      r t        t        j                  |«      |«      }nt        ||«      }|}| j
                  d   dk(  rt        | |||«      S | dd…df   }g }t        j                  |«      D ]Z  }t        j                  ||k(  «      d   }	t        | |	   ||	   ||«      }
|
D ]$  }|j                  |	|   j                  «       «       Œ& Œ\ |D ]  }t        |«      dk(  sŒt        d|› �«      ‚ |S )aH  
    Perform Non-Maximum Merging (NMM) on segmentation predictions.

    Args:
        predictions: A 2D array of object detection predictions in
            the format of `(x_min, y_min, x_max, y_max, score)`
            or `(x_min, y_min, x_max, y_max, score, class)`. Shape: `(N, 5)` or
            `(N, 6)`, where N is the number of predictions.
        masks: A 3D array of binary masks corresponding to the predictions.
            Shape: `(N, H, W)`, where N is the number of predictions, and H, W are the
            dimensions of each mask.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression.
        mask_dimension: The dimension to which the masks should be
            resized before computing IOU values. Defaults to 640.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of masks (e.g., IoU, IoS).

    Returns:
        A list of groups of prediction indices. Each inner list contains
            the indices of predictions whose masks overlap above `iou_threshold`
            according to the chosen `overlap_metric`, and should be merged or
            kept together as a single detection by non-maximum merging.

    Raises:
        AssertionError: If `iou_threshold` is not within the closed
            range from `0` to `1`.
    rw   r3  Nr   ú6Empty group detected when non-max-merging detections: )r"   r   r	   rC   r!  re   ra  Úuniquerc   r&  rX  r�   r%   )r9  r:  r;  r<  rJ   Úmasks_resizedÚcategory_idsrY  Úcategory_idÚcurr_indicesÚmerge_class_groupsÚmerge_class_groupÚmerge_groups                r   Úmask_non_max_mergerl    s6  € ôH �%œÔ%ô œRŸZ™Z¨Ó.°Ó?‰ä˜U NÓ3ˆØ€Mà×Ñ˜Ñ˜qÒ Ü'Ø˜¨°~ó
ð 	
ð šq !˜tÑ$€LØ€LÜ—y‘y Ó.ò 
JˆÜ—x‘x °Ñ ;Ó<¸QÑ?ˆÜ5Ø˜Ñ%Ø˜,Ñ'ØØó	
Ðð "4ò 	JÐØ×Ñ Ð->Ñ ?× FÑ FÓ HÕIñ	Jð
Jð $ò ˆÜˆ{Ó˜qÓ ÜØHÈÈÐWóð ðð
 Ðr   c                ó~  — g }| dd…df   }|j                  «       }t        |«      dkD  r“t        |d   «      }|dd }t        |«      dk(  r|j                  |g«       	 |S  |||«      }||k\  }|gt	        j
                  ||   «      j                  «       ¢}	|j                  |	«       ||    }t        |«      dkD  rŒ“|S )aU  Greedy non-maximum merging loop, independent of how overlap is computed.

    ``iou_against_candidate(order_indices, candidate_idx)`` must return the IoU
    vector between every prediction in ``order_indices`` and the candidate at
    ``candidate_idx``. Predictions whose IoU meets ``iou_threshold`` are
    grouped with the candidate.
    Nr¹   r   r›   )r5  r�   rá   r&  rC   rE  rX  )
r9  Úiou_against_candidater;  rY  rZ  r[  r\  r”   r_  rk  s
             r   Ú_greedy_nmm_via_iou_callbackro  Q  sØ   € ð %'€LØš˜A˜Ñ€FØ�N‰NÓ€EÜ
ˆe‹*�qŠ.Ü�%˜‘)‹nˆØ�c�r�
ˆÜˆu‹:˜Š?Ø×Ñ  Ô&Øð Ðñ % U¨CÓ0ˆØ -Ñ/ˆØÐFœRŸW™W U¨?Ñ%;Ó<×CÑCÓEÐFˆØ×Ñ˜KÔ(Ø�Ð&Ñ'ˆô ˆe‹*�q‹.ð Ðr   c                óî  — | j                   d   dk(  rKt        j                  t        | «      t        ¬«      } ||«      D �cg c]  }||   j                  «       ‘Œ c}S | dd…df   }g }t        j                  |«      D ]L  }t        j                  ||k(  «      d   } ||«      D ]$  }|j                  ||   j                  «       «       Œ& ŒN |D ]  }	t        |	«      dk(  sŒt        d|› �«      ‚ |S c c}w )a“  Dispatch NMM grouping per class, then translate local indices back to
    the global row positions of ``predictions``.

    ``group_within(global_indices)`` must return merge groups expressed in
    terms of *positions inside `global_indices`*, not absolute row positions.
    When ``predictions`` has no class column, a single pass over all rows is
    performed instead of per-category iteration.
    rw   r3  r_   Nr   rc  )
re   rC   Úaranger�   rá   rX  rd  rc   r&  r%   )
r9  Úgroup_withinÚglobal_indicesÚgrouprf  rY  rg  rh  Úlocal_grouprk  s
             r   Ú_non_max_merge_per_categoryrv  p  s  € ð ×Ñ˜Ñ˜qÒ ÜŸ™¤3 {Ó#3¼3Ô?ˆá8DÀ^Ó8Tö
Ø/4ˆN˜5Ñ!×(Ñ(Õ*ò
ð 	
ð šq !˜tÑ$€LØ$&€LÜ—y‘y Ó.ò DˆÜ—x‘x °Ñ ;Ó<¸QÑ?ˆÙ'¨Ó5ò 	DˆKØ×Ñ ¨[Ñ 9× @Ñ @Ó BÕCñ	DðDð
 $ò ˆÜˆ{Ó˜qÓ ÜØHÈÈÐWóð ðð
 Ðùò!
s   ÁC2c                ó:   ‡ ‡— 	 	 	 	 	 	 dˆˆ fd„}t        ‰ ||«      S )a¦  
    Apply greedy version of non-maximum merging to avoid detecting too many
    overlapping bounding boxes for a given object.

    Args:
        predictions: An array of shape `(n, 5)` containing
            the bounding boxes coordinates in format `[x1, y1, x2, y2]`
            and the confidence scores.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression. Defaults to 0.5.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of boxes (e.g., IoU, IoS).

    Returns:
        Groups of prediction indices to be merged.
            Each group may have 1 or more elements.
    c                ój   •— t        ‰|    d d …d d…f   ‰||dz   …d d…f   ‰«      j                  «       S )Nr¹   rw   )ru   rR  )r[  r\  rJ   r9  s     €€r   rn  z7_group_overlapping_boxes.<locals>.iou_against_candidate¨  sL   ø€ ô Ø˜Ñšq " 1 "˜uÑ%Ø˜˜c A™g˜ r¨ rÐ)Ñ*Øó
÷ ‰'‹)ð		r   ©r[  únpt.NDArray[np.int_]r\  rá   r-   únpt.NDArray[np.floating]©ro  )r9  r;  rJ   rn  s   ` ` r   Ú_group_overlapping_boxesr}  ‘  s7   ù€ ð.Ø#ðØ*-ðà	!öô (ØÐ*¨Móð r   c                ó0   ‡ ‡‡— dˆˆˆ fd„}t        ‰ |«      S )a0  
    Apply greedy version of non-maximum merging per category to avoid detecting
    too many overlapping bounding boxes for a given object.

    Args:
        predictions: An array of shape `(n, 5)` or `(n, 6)`
            containing the bounding boxes coordinates in format `[x1, y1, x2, y2]`,
            the confidence scores and class_ids. Omit class_id column to allow
            detections of different classes to be merged.
        iou_threshold: The intersection-over-union threshold
            to use for non-maximum suppression. Defaults to 0.5.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of boxes (e.g., IoU, IoS).

    Returns:
        list[list[int]]: Groups of prediction indices be merged.
            Each group may have 1 or more elements.
    c                ó$   •— t        ‰|    ‰‰«      S r   )r}  )rs  r;  rJ   r9  s    €€€r   rr  z'box_non_max_merge.<locals>.group_withinÎ  s   ø€ Ü'Ø˜Ñ'¨¸ó
ð 	
r   ©rs  rz  r-   úlist[list[int]])rv  )r9  r;  rJ   rr  s   ``` r   Úbox_non_max_merger‚  ¶  s   ú€ ÷0
ô
 ' {°LÓAÐAr   c                óh  — d|cxk  rdk  sn J d|› d�«       ‚d| fd|ffD ]ë  \  }}|dk(  r=|j                   dk7  s|j                  d   dvrt        d	|› d
|j                  › d�«      ‚ŒH|j                   dk(  r.|j                  dd dk7  rt        d	|› d
|j                  › d�«      ‚|j                   dk(  r.|j                  d   dk7  rt        d	|› d
|j                  › d�«      ‚|j                   dvsŒÑt        d	|› d|j                  › d�«      ‚ t        | «      t        |«      k7  r$t        dt        | «      › dt        |«      › d�«      ‚t	        | «      \  }}}||   }t        |||«      }	t        |	||«      }
t        t        j                  t        j                     |
|j                  «          «      S )u„  
    Perform Non-Maximum Suppression on oriented bounding box predictions.

    Overlap is computed via :func:`oriented_box_iou_batch` on the four
    corners of each box, so detections whose axis-aligned bounding boxes
    overlap heavily but whose oriented bodies do not are kept â€” unlike
    :func:`box_non_max_suppression`, which would suppress them.

    Args:
        predictions: An array of object detection predictions in the
            format ``(x_min, y_min, x_max, y_max, score)`` or
            ``(x_min, y_min, x_max, y_max, score, class)``. Shape ``(N, 5)``
            or ``(N, 6)``. Only the score (column 4) and optional class
            (column 5) are read; the axis-aligned coordinates are not used.
        oriented_boxes: Array of shape ``(N, 4, 2)`` containing the four
            ``(x, y)`` corners of each oriented box, aligned with
            ``predictions`` row-by-row.
        iou_threshold: The intersection-over-union threshold to use for
            non-maximum suppression.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of oriented boxes (e.g., IoU, IoS).

    Returns:
        A boolean array of shape ``(N,)`` indicating which predictions
            to keep after non-maximum suppression.

    Raises:
        AssertionError: If ``iou_threshold`` is not within the closed
            range from 0 to 1.
        ValueError: If ``predictions`` and ``oriented_boxes`` have
            mismatched lengths or invalid shapes.

    Examples:
        >>> import numpy as np
        >>> import supervision as sv
        >>> oriented_boxes = np.array([
        ...     [[10, 10], [50, 10], [50, 30], [10, 30]],
        ...     [[11, 11], [51, 11], [51, 31], [11, 31]],
        ... ], dtype=np.float32)
        >>> predictions = np.array([
        ...     [10, 10, 50, 30, 0.9, 0],
        ...     [11, 11, 51, 31, 0.8, 0],
        ... ], dtype=np.float32)
        >>> keep = sv.oriented_box_non_max_suppression(
        ...     predictions=predictions,
        ...     oriented_boxes=oriented_boxes,
        ...     iou_threshold=0.5,
        ... )
        >>> keep
        array([ True, False])
    r   rw   r1  r2  r9  Úoriented_boxesrx   ©r3  é   rº   r»   ú; expected (N, 5) or (N, 6).ry   Nr¸   r¼   r½   r¾   r¿   rÀ   rÁ   úB`predictions` and `oriented_boxes` must have the same length, got r  )rÂ   re   r%   r�   rF  rÛ   rL  r   rf   rg   rC   r8  r5  )r9  r„  r;  rJ   rÈ   rÉ   r>  rØ   r?  r”   r@  s              r   Ú oriented_box_non_max_suppressionr‰  Ö  s  € ðr �Ô" Ô"ð ØLØˆ/˜ð	"óÐ"ð % kÐ2Ð5EÀ~Ð4VÐWò ‰	ˆˆcØ�=Ò Ø�x‰x˜1Š} §	¡	¨!¡°FÑ :Ü Ø˜�v˜\¨#¯)©)¨Ð4PÐQóð ð Ø�8‰8�qŠ=˜SŸY™Y q r˜]¨fÒ4ÜØ�D�6˜ c§i¡i [ð 1Tð Uóð ð �X‰X˜Š]˜sŸy™y¨™|¨qÒ0ÜØ�D�6˜ c§i¡i [ð 1>ð ?óð ð �X‰X˜VÒ#ÜØ�D�6ÐJÈ3Ï9É9È+ÐUVÐWóð ð%ô* ˆ;Óœ3˜~Ó.Ò.ÜðÜ�{Ó#Ð$ E¬#¨nÓ*=Ð)>¸aðAó
ð 	
ô !=¸[Ó IÑ€J��:Ø# JÑ/€Nä! .°.À.ÓQ€DÜ$ T¨:°}ÓE€DÜ”—‘œBŸH™HÑ% t¨J×,>Ñ,>Ó,@Ñ'AÓBÐBr   c                ó:   ‡‡— 	 	 	 	 	 	 dˆˆfd„}t        | ||«      S )z�
    Greedy non-maximum merging on oriented boxes. Mirrors
    :func:`_group_overlapping_boxes` but uses :func:`oriented_box_iou_batch`.
    c                óL   •— t        ‰|    ‰|   d   ‰«      j                  «       S )NrP  )rÛ   rR  )r[  r\  r„  rJ   s     €€r   rn  z@_group_overlapping_oriented_boxes.<locals>.iou_against_candidate@  s3   ø€ ô &Ø˜5Ñ!Ø˜3Ñ 	Ñ*Øó
÷ ‰'‹)ð		r   ry  r|  )r9  r„  r;  rJ   rn  s    ` ` r   Ú!_group_overlapping_oriented_boxesrŒ  5  s7   ù€ ðØ#ðØ*-ðà	!öô (ØÐ*¨Móð r   c                óÆ  ‡ ‡‡‡— d‰ fd‰ffD ]ë  \  }}|dk(  r=|j                   dk7  s|j                  d   dvrt        d|› d|j                  › d�«      ‚ŒH|j                   d	k(  r.|j                  dd
 dk7  rt        d|› d|j                  › d�«      ‚|j                   dk(  r.|j                  d   dk7  rt        d|› d|j                  › d�«      ‚|j                   dvsŒÑt        d|› d|j                  › d�«      ‚ t        ‰ «      t        ‰«      k7  r$t        dt        ‰ «      › dt        ‰«      › d�«      ‚d‰cxk  rdk  sn J d‰› d�«       ‚dˆˆˆˆ fd„}t	        ‰ |«      S )uÊ  
    Perform Non-Maximum Merging on oriented bounding box predictions,
    grouped per category.

    Mirrors :func:`box_non_max_merge` but uses oriented-box IoU, so groups
    of rotated detections sharing the same body â€” rather than the same
    axis-aligned bounding box â€” are merged.

    Args:
        predictions: An array of shape ``(n, 5)`` or ``(n, 6)`` containing
            the axis-aligned coordinates ``[x1, y1, x2, y2]``, confidence
            scores, and optionally class ids. Only the score and optional
            class are used by the grouping logic; overlap is computed on
            ``oriented_boxes``.
        oriented_boxes: Array of shape ``(N, 4, 2)`` containing the four
            ``(x, y)`` corners of each oriented box.
        iou_threshold: The intersection-over-union threshold to use for
            non-maximum merging.
        overlap_metric: Metric used to compute the degree of overlap
            between pairs of oriented boxes (e.g., IoU, IoS).

    Returns:
        Groups of prediction indices to be merged. Each group may have 1
            or more elements.

    Raises:
        AssertionError: If ``iou_threshold`` is not within the closed
            range from 0 to 1.
        ValueError: If ``predictions`` and ``oriented_boxes`` have
            mismatched lengths or invalid shapes.

    Examples:
        >>> import numpy as np
        >>> import supervision as sv
        >>> oriented_boxes = np.array([
        ...     [[10, 10], [50, 10], [50, 30], [10, 30]],
        ...     [[11, 11], [51, 11], [51, 31], [11, 31]],
        ... ], dtype=np.float32)
        >>> predictions = np.array([
        ...     [10, 10, 50, 30, 0.9, 0],
        ...     [11, 11, 51, 31, 0.8, 0],
        ... ], dtype=np.float32)
        >>> groups = sv.oriented_box_non_max_merge(
        ...     predictions=predictions,
        ...     oriented_boxes=oriented_boxes,
        ...     iou_threshold=0.5,
        ... )
        >>> len(groups)
        1
    r9  r„  rx   rw   r…  rº   r»   r‡  ry   Nr¸   r¼   r½   r¾   r¿   rÀ   rÁ   rˆ  r  r   r1  r2  c                ó,   •— t        ‰|    ‰|    ‰‰«      S r   )rŒ  )rs  r;  r„  rJ   r9  s    €€€€r   rr  z0oriented_box_non_max_merge.<locals>.group_within¥  s&   ø€ Ü0Ø˜Ñ'Ø˜>Ñ*ØØó	
ð 	
r   r€  )rÂ   re   r%   r�   rv  )r9  r„  r;  rJ   rÈ   rÉ   rr  s   ````   r   Úoriented_box_non_max_merger�  N  sº  û€ ðp % kÐ2Ð5EÀ~Ð4VÐWò ‰	ˆˆcØ�=Ò Ø�x‰x˜1Š} §	¡	¨!¡°FÑ :Ü Ø˜�v˜\¨#¯)©)¨Ð4PÐQóð ð Ø�8‰8�qŠ=˜SŸY™Y q r˜]¨fÒ4ÜØ�D�6˜ c§i¡i [ð 1Tð Uóð ð �X‰X˜Š]˜sŸy™y¨™|¨qÒ0ÜØ�D�6˜ c§i¡i [ð 1>ð ?óð ð �X‰X˜VÒ#ÜØ�D�6ÐJÈ3Ï9É9È+ÐUVÐWóð ð%ô* ˆ;Óœ3˜~Ó.Ò.ÜðÜ�{Ó#Ð$ E¬#¨nÓ*=Ð)>¸aðAó
ð 	
ð �Ô" Ô"ð ØLØˆ/˜ð	"óÐ"÷

ð 
ô ' {°LÓAÐAr   )rH   ú&list[float] | npt.NDArray[np.floating]rI   r�  rJ   r>   r-   rG   )rq   únpt.NDArray[np.number]rr   r‘  rJ   r>   r-   znpt.NDArray[np.float32])r{   úlist[float]r|   r’  r}   r7  r-   rG   )rq   úlist[list[float]]rr   r“  r}   z
list[bool]r-   únpt.NDArray[np.float64])r£   r{  r-   r{  )r±   r{  r²   r{  r-   z1tuple[npt.NDArray[np.intp], npt.NDArray[np.intp]])rq   r‘  rr   r‘  rJ   r7   r-   r{  )rä   r   rå   r   rJ   r7   r-   r{  )rä   únpt.NDArray[Any]rå   r•  rJ   r7   r-   r{  )
rä   r•  rå   r•  rJ   r7   r(  rá   r-   r{  )r9  r{  r:  r•  r;  rG   rJ   r7   r<  rá   r-   únpt.NDArray[np.bool_])r9  r{  r-   zOtuple[npt.NDArray[np.int_], npt.NDArray[np.floating], npt.NDArray[np.floating]])r”   r{  r?  r{  r;  rG   r-   r–  )r9  r{  r;  rG   rJ   r7   r-   r–  )
r9  r”  r:  r”  r;  rG   rJ   r7   r-   r�  )r9  r{  r:  r•  r;  rG   r<  rá   rJ   r7   r-   r�  )r9  r”  rn  z?Callable[[npt.NDArray[np.int_], int], npt.NDArray[np.floating]]r;  rG   r-   r�  )r9  r”  rr  z1Callable[[npt.NDArray[np.int_]], list[list[int]]]r-   r�  )r9  r”  r;  rG   rJ   r7   r-   r�  )
r9  r{  r„  r{  r;  rG   rJ   r7   r-   r–  )
r9  r{  r„  r{  r;  rG   rJ   r7   r-   r�  ).Ú
__future__r   r"  Úcollections.abcr   Úenumr   Útypingr   r   rÆ   ÚnumpyrC   Únumpy.typingrf   Ú"supervision.detection.compact_maskr   Ú!supervision.detection.utils.masksr	   r   r7   r8   r]   ru   rŽ   r™   r§   r¬   r¶   rÛ   r
  r  r/  rC  rF  rL  rN  ra  rl  ro  rv  r}  r‚  r‰  rŒ  r�  r5   r   r   ú<module>rŸ     s  ðÝ "ã Ý $Ý ß ã 
Û Ý å :Ý :ô#
�Dô #
ôL!
�Dô !
ðN +8×*;Ñ*;ðE)Ø4ðE)à9ðE)ð (ðE)ð ó	E)ðV +8×*;Ñ*;ðcØ&ðcà+ðcð (ðcð ó	cóL%,ðP8Ø!ð8à&ð8ð ð8ð ó	8óvKóð XØ,ðXà1ðXð 7óXðF %2×$5Ñ$5ðLCØ&ðLCà+ðLCð "ðLCð ó	LCðd %2×$5Ñ$5ðdØðdàðdð "ðdð ó	dðT %2×$5Ñ$5ð=0Ø ð=0à%ð=0ð "ð=0ð ó	=0ðF %2×$5Ñ$5Ø ð	];Ø ð];à%ð];ð "ð];ð ð	];ð
 ó];ðF Ø$1×$5Ñ$5Øð@CØ)ð@Càð@Cð ð@Cð "ð	@Cð
 ð@Cð ó@CðF/Ø)ð/àTó/ð"Ø
"ðà(ðð ðð ó	ð0 Ø$1×$5Ñ$5ð CØ)ð Càð Cð "ð Cð ó	 CðL Ø$1×$5Ñ$5ð	6Ø(ð6à"ð6ð ð6ð "ð	6ð
 ó6ðx ØØ$1×$5Ñ$5ðHØ)ðHàðHð ðHð ð	Hð
 "ðHð óHðVØ(ðððð
 ðð óð>Ø(ðàCðð óðF Ø$1×$5Ñ$5ð"Ø(ð"àð"ð "ð"ð ó	"ðN Ø$1×$5Ñ$5ðBØ(ðBàðBð "ðBð ó	BðF Ø$1×$5Ñ$5ð	\CØ)ð\Cà,ð\Cð ð\Cð "ð	\Cð
 ó\CðD Ø$1×$5Ñ$5ð	Ø)ðà,ðð ðð "ð	ð
 óð8 Ø$1×$5Ñ$5ð	_BØ)ð_Bà,ð_Bð ð_Bð "ð	_Bð
 ô_Br   