§
    >²¸jÒ ã                   óú  — d dl mZ d dlmZ d dlmZ d dlmZmZm	Z	 d dl
Zd dlmZ d dlmZmZ d dlmZmZmZ d dlmZmZ d d	lmZ d d
lmZ d dlmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z) d dl*m+Z+ d dl,m-Z- d dl.m/Z/ d dl0m1Z1m2Z2 d dl3m4Z4m5Z5m6Z6 d dl7m8Z8 d dl9m:Z: d dl;m<Z<m=Z= d dl>m?Z?m@Z@mAZA d dlBmCZCmDZDmEZE d dlFmGZGmHZH d dlImJZJmKZKmLZLmMZM d dlNmOZO  eOeP¦  «        ZQedeRdeSeTeTf         dejU        ejV                 fd„¦   «         ZWde<e=z  eRz  de<e=z  fd„ZXejY        ZZ G d„ d e¦  «        Z[ G d!„ d"e¦  «        Z\ G d#„ d$e¦  «        Z]d%e/deeSeTejU        ej^                 ejU        ej_                 dz  f                  fd&„Z`	 	 dXd)ejU        ejV                 d%e/de<e=z  d*eejU        eja                 z  d+ebd,eSeTeTf         dejU        ej^                 dz  fd-„Zc G d.„ d/e¦  «        Zd G d0„ d1e¦  «        Ze G d2„ d3e¦  «        Zf G d4„ d5e¦  «        Zg G d6„ d7e¦  «        Zh G d8„ d9e¦  «        Zi G d:„ d;e¦  «        Zj G d<„ d=e¦  «        Zk G d>„ d?e[¦  «        Zl G d@„ dAe[¦  «        Zm G dB„ dCe¦  «        Zn G dD„ dEe¦  «        Zo G dF„ dGe¦  «        Zp G dH„ dIe¦  «        Zq G dJ„ dKe¦  «        Zr G dL„ dMe¦  «        Zs G dN„ dOe¦  «        Zt G dP„ dQe¦  «        Zu G dR„ dSe¦  «        Zv G dT„ dUe¦  «        Zw G dV„ dW¦  «        ZxdS )Yé    )ÚIterator)Ú	lru_cache)Úsqrt)ÚAnyÚClassVarÚcastN)Ú
deprecatedÚvoid)ÚImageÚ	ImageDrawÚ	ImageFont)ÚsplevÚsplprep)Ú_cv2)ÚBaseAnnotator)ÚPENDING_TRACK_IDÚColorLookupÚTraceÚ_validate_labelsÚcalculate_dynamic_kernel_sizeÚcalculate_dynamic_pixel_sizeÚget_labels_textÚhex_to_rgbaÚresolve_colorÚresolve_text_background_xyxyÚ
snap_boxesÚ	wrap_text)ÚORIENTED_BOX_COORDINATES)ÚCompactMask)Ú
Detections)Ú
clip_boxesÚspread_out_boxes)Úmask_to_polygonsÚpolygon_to_maskÚxyxy_to_polygons)Ú_masks_to_roi)Ú	ImageType)ÚColorÚColorPalette)Údraw_polygonÚdraw_rounded_rectangleÚ	draw_text)ÚPointÚPositionÚRect)Ú!ensure_cv2_image_for_class_methodÚ!ensure_pil_image_for_class_method)Ú_overlay_imageÚ
crop_imageÚletterbox_imageÚscale_image)Ú_get_loggerÚ	icon_pathÚicon_resolution_whÚreturnc                 ó¤  — t          j        | t           j        ¦  «        }|€t          d| › �¦  «        ‚|j        t
          j        k    r+t          t          j	        t
          j                 |¦  «        }ny|j        t
          j
        k    rIt          j        t          j        |dz  ¦  «        dd¦  «                             t
          j        ¦  «        }nt          d| › d|j        › d�¦  «        ‚|j        d	k    rGt          t          j	        t
          j                 t          j        |t           j        ¦  «        ¦  «        }t%          ||¬
¦  «        }|S )a†  Load and resize an icon image through a cache shared by annotators.

    Icons are read unchanged to keep their alpha channel, which also keeps a grayscale
    PNG as a 2-D array and a 16-bit PNG at 16 bits. A 16-bit icon is scaled down to 8
    bits and a grayscale icon is expanded to BGR, the depth and layout the icon overlay
    draws; an icon of any other pixel type is rejected.
    Nz)Error: Couldn't load the icon image from é   r   éÿ   zIcon image ('z#') has an unsupported pixel type ('z$'); an icon must be 8-bit or 16-bit.é   )ÚimageÚresolution_wh)Úcv2ÚimreadÚIMREAD_UNCHANGEDÚFileNotFoundErrorÚdtypeÚnpÚuint8r   ÚnptÚNDArrayÚuint16ÚclipÚrintÚastypeÚ
ValueErrorÚndimÚcvtColorÚCOLOR_GRAY2BGRr4   )r7   r8   ÚiconÚ
icon_arrayÚresults        úk/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/supervision/annotators/core.pyÚ_load_icon_from_pathrU   9   s<  € õ Œ:�i¥Ô!5Ñ6Ô6€DØ€|ÝÐ WÈIÐ WÐ WÑXÔXÐXà„z•R”XÒÐÝ�#œ+¥b¤hÔ/°Ñ6Ô6ˆ
ˆ
Ø	Œ•r”yÒ	 Ð	 õ ”W�RœW T¨C¡ZÑ0Ô0°!°SÑ9Ô9×@Ò@ÅÄÑJÔJˆ
ˆ
åðB˜Ið Bð BØ”ðBð Bð Bñ
ô 
ð 	
ð „˜!ÒÐÝÝŒK�œÔ!¥3¤<°
½CÔ<NÑ#OÔ#Oñ
ô 
ˆ
õ %4ØÐ(:ð%ñ %ô %€Fð €Mó    Úcolorc                 ó†   — t          | t          ¦  «        r+t          | ¦  «        \  }}}}t          j        |||f¦  «        S | S )a  Normalize accepted color inputs to internal color objects.

    Accepts `Color`, `ColorPalette`, or hex string input. Hex strings are parsed via
    `hex_to_rgba` and converted to `Color` (alpha channel is ignored because annotator
    drawing uses RGB/BGR colors).
    )Ú
isinstanceÚstrr   r(   Úfrom_rgb_tuple)rW   ÚrÚgÚbÚ_s        rT   Ú_normalize_color_inputr`   ]   sG   € õ �%�ÑÔð /Ý  Ñ'Ô'‰
ˆˆ1ˆa�ÝÔ# Q¨¨1 IÑ.Ô.Ð.Ø€LrV   c                   ó  — e Zd ZdZej        ej        ej	        de
j        ddddf	deez  ez  ded	eez  ez  d
ede
deeef         dedededz  fd„Zdeeef         dee         dej        ej                 dej        ej                 fd„ZdS )Ú_BaseLabelAnnotatora…  
    Base class for annotators that add labels to detections.

    Attributes:
        color: The color to use for the label background.
        color_lookup: The method used to determine the color of the label.
        text_color: The color to use for the label text.
        text_padding: The padding around the label text, in pixels.
        text_anchor: The position of the text relative to the detection
            bounding box.
        text_offset: A tuple of 2D coordinates `(x, y)` to
            offset the text position from the anchor point, in pixels.
        border_radius: The radius of the label background corners, in pixels.
        smart_position: Whether to intelligently adjust the label position to
            avoid overlapping with other elements.
        max_line_length: Maximum number of characters per line before
            wrapping the text. None means no wrapping.
    é
   ©r   r   r   FNrW   Úcolor_lookupÚ
text_colorÚtext_paddingÚtext_positionÚtext_offsetÚborder_radiusÚsmart_positionÚmax_line_lengthc
                 ó¸   — t          |¦  «        | _        || _        t          |¦  «        | _        || _        || _        || _        || _        || _        |	| _	        dS )aì  
        Initializes the _BaseLabelAnnotator.

        Args:
            color: The color to use for the label
                background.
            color_lookup: The method used to determine the color
                of the label
            text_color: The color to use for the
                label text.
            text_padding: The padding around the label text, in pixels.
            text_position: The position of the text relative to the
                detection bounding box.
            text_offset: A tuple of 2D coordinates
                `(x, y)` to offset the text position from the anchor point, in pixels.
            border_radius: The radius of the label background corners,
                in pixels.
            smart_position: Whether to intelligently adjust the label
                position to avoid overlapping with other elements.
            max_line_length: Maximum number of characters per
                line before wrapping the text. None means no wrapping.
        N)
r`   rW   re   rf   rg   Útext_anchorri   rj   rk   rl   )
ÚselfrW   re   rf   rg   rh   ri   rj   rk   rl   s
             rT   Ú__init__z_BaseLabelAnnotator.__init__�   sb   € õD ,BÀ%Ñ+HÔ+HˆŒ
Ø)5ˆÔÝ0FÀzÑ0RÔ0RˆŒØ!-ˆÔØ%2ˆÔØ,7ˆÔØ"/ˆÔØ,ˆÔØ+:ˆÔÐÐrV   r?   ÚlabelsÚlabel_propertiesr9   c                 óÄ  — |                      ¦   «         }t          |dd…dd…f         |¦  «        |dd…dd…f<   t          |¦  «        dk    rM|dd…dd…f         }t          |¦  «        }||dd…dd…f<   t          |dd…dd…f         |¦  «        |dd…dd…f<   t	          t
          j        t          j                 t          j	        |t          j        ¬¦  «        ¦  «        S )a¬  
        Adjusts the position of labels to ensure they stay within the frame boundaries.

        Args:
            resolution_wh: The width and height of the frame.
            labels: The list of text labels.
            label_properties: An array of label properties, where each row
                            contains [x1, y1, x2, y2, text_height, ...].

        Returns:
            The adjusted label properties.
        Né   é   ©rD   )
Úcopyr   Úlenr"   r   rG   rH   rE   Úfloat32Úasarray)ro   r?   rq   rr   Úadjusted_propertiesÚboxesÚspread_boxess          rT   Ú_adjust_labels_in_framez+_BaseLabelAnnotator._adjust_labels_in_frame­   s	  € ð$ /×3Ò3Ñ5Ô5Ðõ &0Ø    2 A 2 Ô&Øñ&
ô &
Ð˜A˜A˜A˜r ˜r˜EÑ"õ ˆv‰;Œ;˜Š?ˆ?à'¨¨¨¨2¨A¨2¨Ô.ˆEå+¨EÑ2Ô2ˆLà)5Ð    2 A 2 Ñ&õ *4Ø# A A A r¨ r EÔ*¨Mñ*ô *Ð    2 A 2 Ñ&õ ÝŒK�œ
Ô#ÝŒJÐ*µ"´*Ð=Ñ=Ô=ñ
ô 
ð 	
rV   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r)   ÚDEFAULTr   ÚCLASSr(   ÚWHITEr.   ÚTOP_LEFTrZ   ÚintÚtupleÚboolrp   ÚlistrG   rH   rE   ry   r~   © rV   rT   rb   rb   m   s0  € € € € € ðð ð* -9Ô,@Ø$/Ô$5Ø16´ØØ"*Ô"3Ø'-ØØ$Ø&*ð*;ð *;à�|Ñ# cÑ)ð*;ð "ð*;ð ˜LÑ(¨3Ñ.ð	*;ð
 ð*;ð  ð*;ð ˜3 ˜8”_ð*;ð ð*;ð ð*;ð ˜t™ð*;ð *;ð *;ð *;ðX+
à˜S #˜X”ð+
ð �S”	ð+
ð œ+ b¤jÔ1ð	+
ð
 
Œ�R”ZÔ	 ð+
ð +
ð +
ð +
ð +
ð +
rV   rb   c            
       ó    — e Zd ZdZej        dej        fdeez  e	z  de
defd„Ze	 dded	ed
ej        ej                 dz  defd„¦   «         ZdS )ÚBoxAnnotatorzS
    A class for drawing bounding boxes on an image using provided detections.
    r=   rW   Ú	thicknessre   c                 óJ   — t          |¦  «        | _        || _        || _        dS ©a0  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the bounding box lines.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        N©r`   rW   rŽ   re   ©ro   rW   rŽ   re   s       rT   rp   zBoxAnnotator.__init__à   ó)   € õ ,BÀ%Ñ+HÔ+HˆŒ
Ø'ˆŒØ)5ˆÔÐÐrV   NÚsceneÚ
detectionsÚcustom_color_lookupr9   c                 óz  — t          |t          j        ¦  «        s|S t          t	          |¦  «        ¦  «        D ]�}|j        |                              t          ¦  «        \  }}}}t          | j	        |||€| j
        n|¬¦  «        }	t          j        |||f||f|	                     ¦   «         | j        ¬¦  «         Œ‚|S )a7  
        Annotates the given scene with bounding boxes based on the provided detections.

        Args:
            scene: The image where bounding boxes will be drawn. `ImageType`
                is a flexible type, accepting either `numpy.ndarray` or
                `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> box_annotator = sv.BoxAnnotator()
            >>> annotated_frame = box_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![bounding-box-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/bounding-box-annotator-example-purple.png)
        N©rW   r•   Údetection_idxre   ©ÚimgÚpt1Úpt2rW   rŽ   )rY   rE   ÚndarrayÚrangerx   ÚxyxyrL   r‡   r   rW   re   r@   Ú	rectangleÚas_bgrrŽ   )
ro   r”   r•   r–   r™   Úx1Úy1Úx2Úy2rW   s
             rT   ÚannotatezBoxAnnotator.annotateò   sØ   € õT ˜%¥¤Ñ,Ô,ð 	ØˆLÝ"¥3 z¡?¤?Ñ3Ô3ð 	ð 	ˆMØ'œ_¨]Ô;×BÒBÅ3ÑGÔG‰NˆB��B˜Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ŒMØØ˜�HØ˜�HØ—l’l‘n”nØœ.ðñ ô ð ð ð ˆrV   ©N©r   r€   r�   r‚   r)   rƒ   r   r„   r(   rZ   r‡   rp   r0   r'   r    rG   rH   rE   Úint_r§   r‹   rV   rT   r�   r�   Û   sÎ   € € € € € ðð ð -9Ô,@ØØ$/Ô$5ð	6ð 6à�|Ñ# cÑ)ð6ð ð6ð "ð	6ð 6ð 6ð 6ð$ 'ð
 <@ð	<ð <àð<ð ð<ð !œ[¨¬Ô1°DÑ8ð	<ð
 
ð<ð <ð <ñ 'Ô&ð<ð <ð <rV   r�   c            
       ó    — e Zd ZdZej        dej        fdeez  e	z  de
defd„Ze	 dded	ed
ej        ej                 dz  defd„¦   «         ZdS )ÚOrientedBoxAnnotatorz\
    A class for drawing oriented bounding boxes on an image using provided detections.
    r=   rW   rŽ   re   c                 óJ   — t          |¦  «        | _        || _        || _        dS r�   r‘   r’   s       rT   rp   zOrientedBoxAnnotator.__init__7  r“   rV   Nr”   r•   r–   r9   c                 óÔ  — t          |t          j        ¦  «        s|S |j        �t          |j        vr|S t          j        |j        t                   ¦  «                             t          ¦  «        }t          t          |¦  «        ¦  «        D ][}||         }t          | j        |||€| j        n|¬¦  «        }t          j        ||gd|                     ¦   «         | j        ¦  «         Œ\|S )aÛ  
        Annotates the given scene with oriented bounding boxes based on the
        provided detections.

        Args:
            scene: The image where bounding boxes will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```python
            from supervision import _cv2 as cv2
            import supervision as sv
            from ultralytics import YOLO

            image = cv2.imread("<SOURCE_IMAGE_PATH>")
            model = YOLO("yolov8n-obb.pt")

            result = model(image)[0]
            detections = sv.Detections.from_ultralytics(result)

            oriented_box_annotator = sv.OrientedBoxAnnotator()
            annotated_frame = oriented_box_annotator.annotate(
                scene=image.copy(),
                detections=detections
            )
            ```

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> from supervision.config import ORIENTED_BOX_COORDINATES
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> obb = np.array([[[20, 20], [80, 20], [80, 80], [20, 80]]])
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0]),
            ...     data={ORIENTED_BOX_COORDINATES: obb},
            ... )
            >>> oriented_box_annotator = sv.OrientedBoxAnnotator()
            >>> annotated_frame = oriented_box_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```
        Nr˜   r   )rY   rE   rž   Údatar   ÚarrayrL   r‡   rŸ   rx   r   rW   re   r@   ÚdrawContoursr¢   rŽ   )ro   r”   r•   r–   Ú	obb_boxesr™   ÚobbrW   s           rT   r§   zOrientedBoxAnnotator.annotateI  sè   € õz ˜%¥¤Ñ,Ô,ð 	ØˆLØŒ?Ð"Õ&>ÀjÄoÐ&UÐ&UØˆLÝ”H˜Zœ_Õ-EÔFÑGÔG×NÒNÍsÑSÔSˆ	å"¥3 z¡?¤?Ñ3Ô3ð 	Nð 	NˆMØ˜MÔ*ˆCÝ!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ Ô˜U S E¨1¨e¯lªl©n¬n¸d¼nÑMÔMÐMÐMàˆrV   r¨   r©   r‹   rV   rT   r¬   r¬   2  sÙ   € € € € € ðð ð -9Ô,@ØØ$/Ô$5ð	6ð 6à�|Ñ# cÑ)ð6ð ð6ð "ð	6ð 6ð 6ð 6ð$ 'ð
 <@ð	Oð OàðOð ðOð !œ[¨¬Ô1°DÑ8ð	Oð
 
ðOð Oð Oñ 'Ô&ðOð Oð OrV   r¬   r•   c              #   óJ  K  — | j         }|€dS t          |t          ¦  «        r|nd}t          t	          | ¦  «        ¦  «        D ]_}|€6|t          t          j        t          j	                 ||         ¦  «        dfV — Œ:|| 
                    |¦  «        |j        |         fV — Œ`dS )uè  Yield ``(detection_idx, mask_or_crop, offset_or_None)`` for each mask.

    Encapsulates the ``CompactMask`` vs dense dispatch so individual annotators
    do not need inline ``isinstance`` checks. For ``CompactMask`` inputs yields
    the bbox crop and its ``(x1, y1)`` image-space origin; for dense masks
    yields the full-frame boolean slice with ``offset=None``.

    Args:
        detections: Object detections whose masks to iterate.

    Yields:
        Tuple of ``(detection_idx, mask_or_crop, offset_or_None)``.
        ``mask_or_crop`` is boolean (crop-sized for ``CompactMask``, full-frame
        for dense). ``offset_or_None`` is an int32 ``(x1, y1)`` array for
        cropâ†’image translation, or ``None`` for dense masks.
    N)ÚmaskrY   r   rŸ   rx   r   rG   rH   rE   Úbool_ÚcropÚoffsets)r•   ÚmasksÚcompact_maskr™   s       rT   Ú_iter_mask_cropsr»   �  sÒ   è è € ð& ŒO€EØ€}Øˆå& u­kÑ:Ô:ÐD�5�5À€LÝ�s :™œÑ/Ô/ð ð ˆØÐàÝ•S”[¥¤Ô*¨E°-Ô,@ÑAÔAØðð ð ð ð ð Ø×!Ò! -Ñ0Ô0ØÔ$ ]Ô3ðð ð ð ð ðð rV   Frd   Úcanvasre   Úcollect_unionÚcanvas_originc                 óZ  — |j         }|€dS |r(t          j        | j        dd…         t          ¬¦  «        nd}t          |t          ¦  «        r|nd}|\  }	}
| j        dd…         \  }}t          j        t          j        |j	        ¦  «        ¦  «        D �]–}t          ||||¬¦  «                             ¦   «         }|��*t          |j        |df         ¦  «        }t          |j        |df         ¦  «        }|                     |¦  «        }|j        \  }}t          d|	|z
  ¦  «        }t          d|
|z
  ¦  «        }t          d||	z
  ¦  «        }t          d||
z
  ¦  «        }t!          ||z
  ||z
  ¦  «        }t!          ||z
  ||z
  ¦  «        }|dk    s|dk    r�Œ||||z   …|||z   …f         }| |||z   …|||z   …f         }|||<   |�||||z   …|||z   …fxx         |z  cc<   �ŒUt          j        ||         t          ¬¦  «        }||
|
|z   …|	|	|z   …f         }|| |<   |�||z  }�Œ˜|S )a<  Paint each detection's mask into `canvas` in descending-area order.

    Smaller masks are drawn on top of larger ones. `CompactMask` detections
    are painted into their bounding-box crop only, avoiding a full `(H, W)`
    allocation per mask; dense masks fall back to full-frame boolean indexing.

    Args:
        canvas: BGR image array painted in place. Shape ``(H, W, 3)``.
        detections: Detections whose masks to paint. Returns immediately
            without modifying `canvas` when ``detections.mask`` is ``None``.
        color: Single color or palette used to resolve each detection's color.
        color_lookup: Strategy for mapping colors to detection indices.
        collect_union: When ``True``, allocate and return a ``(H, W)``
            boolean array that accumulates the union of all painted masks
            (useful for callers like `HaloAnnotator` that need the combined
            mask footprint). When ``False`` (default), returns ``None``.
        canvas_origin: Absolute ``(x, y)`` origin of `canvas` within the source
            image. Use the default for full-frame painting.

    Returns:
        A boolean array matching the canvas dimensions when
        ``collect_union=True``, otherwise ``None``. When called with an
        ROI sub-canvas, dimensions are the ROI size, not the full image.
    Nr=   rv   r˜   r   ru   )rµ   rE   ÚzerosÚshaper‰   rY   r   ÚflipÚargsortÚarear   r¢   r‡   r¸   r·   ÚmaxÚminrz   )r¼   r•   rW   re   r½   r¾   r¹   Úunionrº   Úorigin_xÚorigin_yÚcanvas_hÚcanvas_wr™   Ú	color_bgrr£   r¤   Úcrop_mÚcrop_hÚcrop_wÚcrop_x1Úcrop_y1Ú	canvas_x1Ú	canvas_y1Úpaint_wÚpaint_hÚ
crop_sliceÚcanvas_slicerµ   s                                rT   Ú_paint_masks_by_arearØ   Ä  sÄ  € ð@ ŒO€EØ€}Øˆtà2?ÐI�Œ�”˜b˜q˜bÔ!­Ð.Ñ.Ô.Ð.ÀTð 
õ ' u­kÑ:Ô:ÐD�5�5À€LØ&Ñ€HˆhØœ b q bÔ)Ñ€HˆhÝœ¥¤¨J¬OÑ!<Ô!<Ñ=Ô=ð &ñ &ˆÝ!ØØ!Ø'Ø%ð	
ñ 
ô 
÷
 Š&‰(Œ(ð 	ð Ñ#Ý�\Ô)¨-¸Ð*:Ô;Ñ<Ô<ˆBÝ�\Ô)¨-¸Ð*:Ô;Ñ<Ô<ˆBØ!×&Ò& }Ñ5Ô5ˆFØ#œ\‰NˆF�FÝ˜!˜X¨™]Ñ+Ô+ˆGÝ˜!˜X¨™]Ñ+Ô+ˆGÝ˜A˜r H™}Ñ-Ô-ˆIÝ˜A˜r H™}Ñ-Ô-ˆIÝ˜& 7Ñ*¨H°yÑ,@ÑAÔAˆGÝ˜& 7Ñ*¨H°yÑ,@ÑAÔAˆGØ˜!Š|ˆ|˜w¨!š|˜|ÙØØ˜' GÑ+Ð+¨W°wÀÑ7HÐ-HÐHôˆJð "Ø˜I¨Ñ/Ð/Ø˜I¨Ñ/Ð/ð1ôˆLð (1ˆL˜Ñ$ØÐ ØØ 	¨GÑ 3Ð3Ø 	¨GÑ 3Ð3ð5ðð ô ð  ñ ð ð ñ ùõ
 ”:˜e MÔ2½$Ð?Ñ?Ô?ˆDØ˜ 8¨hÑ#6Ð6¸À8ÈhÑCVÐ8VÐVÔWˆDØ$ˆF�4‰LØÐ Ø˜‘�ùØ€LrV   c            
       ó¤   — e Zd ZdZdZej        dej        fde	ez  e
z  dedefd„Ze	 dd	ed
edej        ej                 dz  defd„¦   «         ZdS )ÚMaskAnnotatorzŽ
    A class for drawing masks on an image using provided detections.

    !!! warning

        This annotator uses `sv.Detections.mask`.
    Tç      à?rW   Úopacityre   c                 óJ   — t          |¦  «        | _        || _        || _        dS ©aC  
        Args:
            color: The color or color palette to use for
                annotating detections.
            opacity: Opacity of the overlay mask. Must be between `0` and `1`.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        N)r`   rW   rÜ   re   ©ro   rW   rÜ   re   s       rT   rp   zMaskAnnotator.__init__"  s)   € õ ,BÀ%Ñ+HÔ+HˆŒ
ØˆŒØ)5ˆÔÐÐrV   Nr”   r•   r–   r9   c                 ó€  — t          |t          j        ¦  «        s|S |j        €|S t	          |j        d         ¦  «        t	          |j        d         ¦  «        f}|€| j        n|}t          |¦  «        dk    rt          | j	        |d|¬¦  «         t          |j        ||j        ¦  «        }|€|S |\  }}}	}
|||
…||	…f         }t          j        |dt          j        ¬¦  «        }t          ||| j	        |||f¬¦  «         t          j        || j        |                     ¦   «         d| j        z
  d¦  «        }||dd…<   |S )aV  
        Annotates the given scene with masks based on the provided detections.

        Args:
            scene: The image where masks will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     mask=np.zeros((1, 100, 100), dtype=bool),
            ...     class_id=np.array([0])
            ... )
            >>> mask_annotator = sv.MaskAnnotator()
            >>> annotated_frame = mask_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![mask-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/mask-annotator-example-purple.png)
        Nr   ru   r˜   T)rw   rD   )r¾   )rY   rE   rž   rµ   r‡   rÁ   re   rx   r   rW   r&   r    r°   rF   rØ   r@   ÚaddWeightedrÜ   rw   )ro   r”   r•   r–   Úimage_shapeÚeffective_lookupÚroir£   r¤   r¥   r¦   Ú	scene_roiÚcolored_maskÚtmps                 rT   r§   zMaskAnnotator.annotate4  sl  € õV ˜%¥¤Ñ,Ô,ð 	ØˆLØŒ?Ð"ØˆLå˜5œ; qœ>Ñ*Ô*­C°´¸A´Ñ,?Ô,?Ð@ˆà!4Ð!<ˆDÔÐÐBUð 	õ ˆz‰?Œ?˜QÒÐÝØ”jØ%ØØ-ð	ñ ô ð õ ˜JœO¨[¸*¼/ÑJÔJˆØˆ;ØˆLà‰ˆˆB��BØ˜"˜R˜%  B ˜,Ô'ˆ	Ý”x 	°½B¼HÐEÑEÔEˆÝØØØŒJØØ˜r˜(ð	
ñ 	
ô 	
ð 	
õ ŒoØ˜$œ,¨	¯ªÑ(8Ô(8¸!¸d¼lÑ:JÈAñ
ô 
ˆð ˆ	�!�!�!‰ØˆrV   r¨   )r   r€   r�   r‚   Úrequires_maskr)   rƒ   r   r„   r(   rZ   Úfloatrp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   rÚ   rÚ     sà   € € € € € ðð ð €Mð -9Ô,@ØØ$/Ô$5ð	6ð 6à�|Ñ# cÑ)ð6ð ð6ð "ð	6ð 6ð 6ð 6ð$ 'ð
 <@ð	Lð LàðLð ðLð !œ[¨¬Ô1°DÑ8ð	Lð
 
ðLð Lð Lñ 'Ô&ðLð Lð LrV   rÚ   c            
       ó¤   — e Zd ZdZdZej        dej        fde	ez  e
z  dedefd„Ze	 dd	ed
edej        ej                 dz  defd„¦   «         ZdS )ÚPolygonAnnotatorz‘
    A class for drawing polygons on an image using provided detections.

    !!! warning

        This annotator uses `sv.Detections.mask`.
    Tr=   rW   rŽ   re   c                 óJ   — t          |¦  «        | _        || _        || _        dS )a+  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the polygon lines.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        Nr‘   r’   s       rT   rp   zPolygonAnnotator.__init__�  r“   rV   Nr”   r•   r–   r9   c           	      ór  — t          |t          j        ¦  «        s|S |j        €|S t	          |¦  «        D ]�\  }}}t          | j        |||€| j        n|¬¦  «        }t          |¬¦  «        D ]I}|�||z   }t          |t          t          j        t          j                 |¦  «        || j        ¬¦  «        }ŒJŒ‚|S )u  
        Annotates the given scene with polygons based on the provided detections.

        Args:
            scene: The image where polygons will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> polygon_annotator = sv.PolygonAnnotator()
            >>> annotated_frame = polygon_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        Note:
            When `detections.mask` is a `CompactMask`, each detection's polygon
            is decoded from a bbox-sized crop (O(crop_area)) rather than a
            full-frame ``(H, W)`` allocation (O(HÂ·W)). Polygon coordinates are
            shifted from crop-local space to image space via the stored
            ``(x1, y1)`` bbox origin. Pixels outside the declared ``xyxy`` box
            are not represented in compact storage and will not be drawn.

        ![polygon-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/polygon-annotator-example-purple.png)
        Nr˜   )rµ   )r”   ÚpolygonrW   rŽ   )rY   rE   rž   rµ   r»   r   rW   re   r#   r*   r   rG   rH   rª   rŽ   )	ro   r”   r•   r–   r™   rµ   ÚoffsetrW   rî   s	            rT   r§   zPolygonAnnotator.annotate¡  së   € õd ˜%¥¤Ñ,Ô,ð 	ØˆLØŒ?Ð"ØˆLå+;¸JÑ+GÔ+Gð 	ð 	Ñ'ˆM˜4 Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ,°Ð6Ñ6Ô6ð 	ð 	�ØÐ%à%¨Ñ.�GÝ$ØÝ ¥¤­R¬WÔ!5°wÑ?Ô?ØØ"œnð	ñ ô ��ð		ð ˆrV   r¨   )r   r€   r�   r‚   rè   r)   rƒ   r   r„   r(   rZ   r‡   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   rë   rë   „  sà   € € € € € ðð ð €Mð -9Ô,@ØØ$/Ô$5ð	6ð 6à�|Ñ# cÑ)ð6ð ð6ð "ð	6ð 6ð 6ð 6ð$ 'ð
 <@ð	Jð JàðJð ðJð !œ[¨¬Ô1°DÑ8ð	Jð
 
ðJð Jð Jñ 'Ô&ðJð Jð JrV   rë   c            
       ó    — e Zd ZdZej        dej        fdeez  e	z  de
defd„Ze	 dded	ed
ej        ej                 dz  defd„¦   «         ZdS )ÚColorAnnotatorzN
    A class for drawing box masks on an image using provided detections.
    rÛ   rW   rÜ   re   c                 óJ   — t          |¦  «        | _        || _        || _        dS rÞ   )r`   rW   re   rÜ   rß   s       rT   rp   zColorAnnotator.__init__ô  s'   € õ ,BÀ%Ñ+HÔ+HˆŒ
Ø)5ˆÔØˆŒˆˆrV   Nr”   r•   r–   r9   c                 óæ  — t          |t          j        ¦  «        s|S |                     ¦   «         }t	          t          |¦  «        ¦  «        D ]|}|j        |                              t          ¦  «        \  }}}}	t          | j
        |||€| j        n|¬¦  «        }
t          j        |||f||	f|
                     ¦   «         d¬¦  «         Œ}t          j        || j        |d| j        z
  d|¬¦  «         |S )a0  
        Annotates the given scene with box masks based on the provided detections.

        Args:
            scene: The image where bounding boxes will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> color_annotator = sv.ColorAnnotator()
            >>> annotated_frame = color_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![box-mask-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/box-mask-annotator-example-purple.png)
        Nr˜   éÿÿÿÿrš   ru   r   )ÚgammaÚdst)rY   rE   rž   rw   rŸ   rx   r    rL   r‡   r   rW   re   r@   r¡   r¢   rá   rÜ   )ro   r”   r•   r–   Úscene_with_boxesr™   r£   r¤   r¥   r¦   rW   s              rT   r§   zColorAnnotator.annotate  s  € õT ˜%¥¤Ñ,Ô,ð 	ØˆLØ Ÿ:š:™<œ<ÐÝ"¥3 z¡?¤?Ñ3Ô3ð 	ð 	ˆMØ'œ_¨]Ô;×BÒBÅ3ÑGÔG‰NˆB��B˜Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ŒMØ$Ø˜�HØ˜�HØ—l’l‘n”nØðñ ô ð ð õ 	ŒØ˜dœl¨E°1°t´|Ñ3CÈ1ÐRWð	
ñ 	
ô 	
ð 	
ð ˆrV   r¨   )r   r€   r�   r‚   r)   rƒ   r   r„   r(   rZ   ré   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   rñ   rñ   ï  sÙ   € € € € € ðð ð -9Ô,@ØØ$/Ô$5ð	ð à�|Ñ# cÑ)ðð ðð "ð	ð ð ð ð$ 'ð
 <@ð	Að AàðAð ðAð !œ[¨¬Ô1°DÑ8ð	Að
 
ðAð Að Añ 'Ô&ðAð Að ArV   rñ   c            
       óª   — e Zd ZdZdZej        ddej        fde	ez  e
z  dededefd	„Ze	 ddededej        ej                 d
z  defd„¦   «         Zd
S )ÚHaloAnnotatorzŽ
    A class for drawing Halos on an image using provided detections.

    !!! warning

        This annotator uses `sv.Detections.mask`.
    Tgš™™™™™é?é(   rW   rÜ   Úkernel_sizere   c                 óX   — t          |¦  «        | _        || _        || _        || _        dS )a¯  
        Args:
            color: The color or color palette to use for
                annotating detections.
            opacity: Opacity of the overlay mask. Must be between `0` and `1`.
            kernel_size: The size of the average pooling kernel used for creating
                the halo.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        N)r`   rW   rÜ   re   rû   )ro   rW   rÜ   rû   re   s        rT   rp   zHaloAnnotator.__init__V  s1   € õ" ,BÀ%Ñ+HÔ+HˆŒ
ØˆŒØ)5ˆÔØ +ˆÔÐÐrV   Nr”   r•   r–   r9   c                 óZ  — t          |t          j        ¦  «        s|S |j        €|S t          j        |t          j        ¬¦  «        }t          ||| j        |€| j        n|d¬¦  «        }|€J ‚t          t          j        t          j                 t          j        || j        | j        f¦  «        ¦  «        }g d¢||<   t          j        |t          j        ¦  «        }|                     ¦   «         }|dk    r|S | j        |z  |z  }|dd…dd…t          j        f         }	t          j        |                     t          j        ¦  «        d|	z
  z  |                     t          j        ¦  «        |	z  z   dd¦  «                             t          j        ¦  «        }
t          j        ||
¦  «         |S )	ab  
        Annotates the given scene with halos based on the provided detections.

        Args:
            scene: The image where the halo effect will be applied.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     mask=np.zeros((1, 100, 100), dtype=bool),
            ...     class_id=np.array([0])
            ... )
            >>> halo_annotator = sv.HaloAnnotator()
            >>> annotated_frame = halo_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![halo-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/halo-annotator-example-purple.png)
        Nrv   T)r½   )r   r   r   r   ru   r<   )rY   rE   rž   rµ   Ú
zeros_likerF   rØ   rW   re   r   rG   rH   r@   Úblurrû   rO   ÚCOLOR_BGR2GRAYrÅ   rÜ   ÚnewaxisrJ   rL   ry   Úcopyto)ro   r”   r•   r–   ræ   ÚfmaskÚgrayÚgray_maxÚalphaÚ
alpha_maskÚblended_scenes              rT   r§   zHaloAnnotator.annotatel  s�  € õV ˜%¥¤Ñ,Ô,ð 	ØˆLØŒ?Ð"ØˆLÝ”} Uµ"´(Ð;Ñ;Ô;ˆÝ$ØØØŒJØ!4Ð!<ˆDÔÐÐBUØð
ñ 
ô 
ˆð Ð Ð Ð åÝŒK�œÔ!ÝŒH�\ DÔ$4°dÔ6FÐ#GÑHÔHñ
ô 
ˆð (˜i˜iˆ�UÑÝŒ|˜L­#Ô*<Ñ=Ô=ˆØ—8’8‘:”:ˆØ�qŠ=ˆ=àˆLØ”˜tÑ# hÑ.ˆØ˜1˜1˜1˜a˜a˜a¥¤Ð+Ô,ˆ
åœØ�LŠL�œÑ$Ô$¨¨J©Ñ7Ø×!Ò!¥"¤*Ñ-Ô-°
Ñ:ñ;àØñ	
ô 
÷
 Š&•”Ñ
Ô
ð 	õ 	Œ	�%˜Ñ'Ô'Ð'ØˆrV   r¨   )r   r€   r�   r‚   rè   r)   rƒ   r   r„   r(   rZ   ré   r‡   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   rù   rù   K  sí   € € € € € ðð ð €Mð -9Ô,@ØØØ$/Ô$5ð,ð ,à�|Ñ# cÑ)ð,ð ð,ð ð	,ð
 "ð,ð ,ð ,ð ,ð, 'ð
 <@ð	Lð LàðLð ðLð !œ[¨¬Ô1°DÑ8ð	Lð
 
ðLð Lð Lñ 'Ô&ðLð Lð LrV   rù   c                   ó¬   — e Zd ZdZej        dddej        fdeez  e	z  de
de
de
d	ef
d
„Ze	 ddededej        ej                 dz  defd„¦   «         ZdS )ÚEllipseAnnotatorzM
    A class for drawing ellipses on an image using provided detections.
    r=   iÓÿÿÿéë   rW   rŽ   Ústart_angleÚ	end_anglere   c                 óf   — t          |¦  «        | _        || _        || _        || _        || _        dS )a—  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the ellipse lines.
            start_angle: Starting angle of the ellipse.
            end_angle: Ending angle of the ellipse.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        N)r`   rW   rŽ   r  r  re   )ro   rW   rŽ   r  r  re   s         rT   rp   zEllipseAnnotator.__init__Á  s8   € õ$ ,BÀ%Ñ+HÔ+HˆŒ
Ø'ˆŒØ +ˆÔØ'ˆŒØ)5ˆÔÐÐrV   Nr”   r•   r–   r9   c                 ó  — t          |t          j        ¦  «        s|S t          t	          |¦  «        ¦  «        D ]Ð}|j        |                              t          ¦  «        \  }}}}t          | j	        |||€| j
        n|¬¦  «        }	t          ||z   dz  ¦  «        |f}
||z
  }t          j        ||
t          |¦  «        t          d|z  ¦  «        fd| j        | j        |	                     ¦   «         | j        t          j        ¬¦	  «	         ŒÑ|S )a-  
        Annotates the given scene with ellipses based on the provided detections.

        Args:
            scene: The image where ellipses will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> ellipse_annotator = sv.EllipseAnnotator()
            >>> annotated_frame = ellipse_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![ellipse-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/ellipse-annotator-example-purple.png)
        Nr˜   r=   gffffffÖ?ç        )ÚcenterÚaxesÚangleÚ
startAngleÚendAnglerW   rŽ   ÚlineType)rY   rE   rž   rŸ   rx   r    rL   r‡   r   rW   re   r@   Úellipser  r  r¢   rŽ   ÚLINE_4)ro   r”   r•   r–   r™   r£   Ú_y1r¥   r¦   rW   r  Úwidths               rT   r§   zEllipseAnnotator.annotateÙ  s  € õT ˜%¥¤Ñ,Ô,ð 	ØˆLÝ"¥3 z¡?¤?Ñ3Ô3ð 	ð 	ˆMØ(œo¨mÔ<×CÒCÅCÑHÔH‰OˆB��R˜Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ˜2 ™7 a™-Ñ(Ô(¨"Ð-ˆFØ˜‘GˆEÝŒKØØÝ˜%‘j”j¥# d¨U¡lÑ"3Ô"3Ð4ØØÔ+ØœØ—l’l‘n”nØœ.Ýœð
ñ 
ô 
ð 
ð 
ð ˆrV   r¨   r©   r‹   rV   rT   r
  r
  ¼  só   € € € € € ðð ð -9Ô,@ØØØØ$/Ô$5ð6ð 6à�|Ñ# cÑ)ð6ð ð6ð ð	6ð
 ð6ð "ð6ð 6ð 6ð 6ð0 'ð
 <@ð	Bð BàðBð ðBð !œ[¨¬Ô1°DÑ8ð	Bð
 
ðBð Bð Bñ 'Ô&ðBð Bð BrV   r
  c            
       ó¦   — e Zd ZdZej        ddej        fdeez  e	z  de
de
defd„Ze	 dd
ededej        ej                 d	z  defd„¦   «         Zd	S )ÚBoxCornerAnnotatorzP
    A class for drawing box corners on an image using provided detections.
    rt   é   rW   rŽ   Úcorner_lengthre   c                 óX   — t          |¦  «        | _        || _        || _        || _        dS )aa  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the corner lines.
            corner_length: Length of each corner line.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        N)r`   rW   rŽ   r  re   )ro   rW   rŽ   r  re   s        rT   rp   zBoxCornerAnnotator.__init__$  s1   € õ  ,BÀ%Ñ+HÔ+HˆŒ
Ø'ˆŒØ"/ˆÔØ)5ˆÔÐÐrV   Nr”   r•   r–   r9   c           	      óz  — t          |t          j        ¦  «        s|S t          t	          |¦  «        ¦  «        D �] }|j        |                              t          ¦  «        \  }}}}t          | j	        |||€| j
        n|¬¦  «        }	||f||f||f||fg}
|
D ]¡\  }}||k    r
|| j        z   n	|| j        z
  }t          j        |||f||f|	                     ¦   «         | j        ¬¦  «         ||k    r
|| j        z   n	|| j        z
  }t          j        |||f||f|	                     ¦   «         | j        ¬¦  «         Œ¢�Œ|S )a9  
        Annotates the given scene with box corners based on the provided detections.

        Args:
            scene: The image where box corners will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> corner_annotator = sv.BoxCornerAnnotator()
            >>> annotated_frame = corner_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![box-corner-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/box-corner-annotator-example-purple.png)
        Nr˜   ©rŽ   )rY   rE   rž   rŸ   rx   r    rL   r‡   r   rW   re   r  r@   Úliner¢   rŽ   )ro   r”   r•   r–   r™   r£   r¤   r¥   r¦   rW   ÚcornersÚxÚyÚx_endÚy_ends                  rT   r§   zBoxCornerAnnotator.annotate9  s†  € õT ˜%¥¤Ñ,Ô,ð 	ØˆLÝ"¥3 z¡?¤?Ñ3Ô3ð 	ñ 	ˆMØ'œ_¨]Ô;×BÒBÅ3ÑGÔG‰NˆB��B˜Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEð ˜B�x " b ¨B°¨8°b¸"°XÐ>ˆGàð 	ð 	‘��1Ø23°r²'°'˜˜DÔ.Ñ.Ð.¸qÀ4ÔCUÑ?U�Ý”Ø˜A˜q˜6 E¨1 :¨u¯|ª|©~¬~ÈÌðñ ô ð ð 34°r²'°'˜˜DÔ.Ñ.Ð.¸qÀ4ÔCUÑ?U�Ý”Ø˜A˜q˜6 A u :¨u¯|ª|©~¬~ÈÌðñ ô ð ð ñ	ð ˆrV   r¨   r©   r‹   rV   rT   r  r    sæ   € € € € € ðð ð -9Ô,@ØØØ$/Ô$5ð6ð 6à�|Ñ# cÑ)ð6ð ð6ð ð	6ð
 "ð6ð 6ð 6ð 6ð* 'ð
 <@ð	Að AàðAð ðAð !œ[¨¬Ô1°DÑ8ð	Að
 
ðAð Að Añ 'Ô&ðAð Að ArV   r  c            
       ó    — e Zd ZdZej        dej        fdeez  e	z  de
defd„Ze	 dded	ed
ej        ej                 dz  defd„¦   «         ZdS )ÚCircleAnnotatorzK
    A class for drawing circle on an image using provided detections.
    r=   rW   rŽ   re   c                 óJ   — t          |¦  «        | _        || _        || _        dS )a)  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the circle line.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        Nr‘   r’   s       rT   rp   zCircleAnnotator.__init__ƒ  s)   € õ ,BÀ%Ñ+HÔ+HˆŒ
Ø'ˆŒØ)5ˆÔÐÐrV   Nr”   r•   r–   r9   c                 ó   — t          |t          j        ¦  «        s|S t          t	          |¦  «        ¦  «        D ]Ä}|j        |                              t          ¦  «        \  }}}}||z   dz  ||z   dz  f}	t          ||	d         z
  dz  ||	d         z
  dz  z   ¦  «        }
t          | j
        |||€| j        n|¬¦  «        }t          j        ||	t          |
¦  «        |                     ¦   «         | j        ¬¦  «         ŒÅ|S )a+  
        Annotates the given scene with circles based on the provided detections.

        Args:
            scene: The image where box corners will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> circle_annotator = sv.CircleAnnotator()
            >>> annotated_frame = circle_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```


        ![circle-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/circle-annotator-example-purple.png)
        r=   r   ru   Nr˜   ©r›   r  ÚradiusrW   rŽ   )rY   rE   rž   rŸ   rx   r    rL   r‡   r   r   rW   re   r@   Úcircler¢   rŽ   )ro   r”   r•   r–   r™   r£   r¤   r¥   r¦   r  ÚdistancerW   s               rT   r§   zCircleAnnotator.annotate–  s  € õV ˜%¥¤Ñ,Ô,ð 	ØˆLÝ"¥3 z¡?¤?Ñ3Ô3ð 	ð 	ˆMØ'œ_¨]Ô;×BÒBÅ3ÑGÔG‰NˆB��B˜Ø˜B‘w 1‘n r¨B¡w°1¡nÐ5ˆFÝ˜R &¨¤)™^°Ñ1°R¸&À¼)±^ÈÑ4IÑIÑJÔJˆHÝ!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ŒJØØÝ˜8‘}”}Ø—l’l‘n”nØœ.ðñ ô ð ð ð ˆrV   r¨   r©   r‹   rV   rT   r)  r)  ~  sÙ   € € € € € ðð ð -9Ô,@ØØ$/Ô$5ð	6ð 6à�|Ñ# cÑ)ð6ð ð6ð "ð	6ð 6ð 6ð 6ð& 'ð
 <@ð	@ð @àð@ð ð@ð !œ[¨¬Ô1°DÑ8ð	@ð
 
ð@ð @ð @ñ 'Ô&ð@ð @ð @rV   r)  c                   óÒ   — e Zd ZdZej        dej        ej	        de
j        fde
ez  ez  dedededed	e
ez  ez  fd
„Ze	 ddededej        ej                 dz  defd„¦   «         ZdS )ÚDotAnnotatorzh
    A class for drawing dots on an image at specific coordinates based on provided
    detections.
    rt   r   rW   r-  Úpositionre   Úoutline_thicknessÚoutline_colorc                 óŽ   — t          |¦  «        | _        || _        || _        || _        || _        t          |¦  «        | _        dS )aW  
        Args:
            color: The color or color palette to use for
                annotating detections.
            radius: Radius of the drawn dots.
            position: The anchor position for placing the dot.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            outline_thickness: Thickness of the outline of the dot.
            outline_color: The color or color palette to
                use for outline. It is activated by setting outline_thickness to a value
                greater than 0.
        N)r`   rW   r-  r2  re   r3  r4  )ro   rW   r-  r2  re   r3  r4  s          rT   rp   zDotAnnotator.__init__à  sH   € õ, ,BÀ%Ñ+HÔ+HˆŒ
Ø!ˆŒØ"*ˆŒØ)5ˆÔØ!2ˆÔÝ3IÈ-Ñ3XÔ3XˆÔÐÐrV   Nr”   r•   r–   r9   c                 óf  — t          |t          j        ¦  «        s|S |                     | j        ¬¦  «        }t          t          |¦  «        ¦  «        D ]Ü}t          | j        |||€| j	        n|¬¦  «        }t          ||df         ¦  «        t          ||df         ¦  «        f}t          j        ||| j        |                     ¦   «         d¦  «         | j        rUt          | j        |||€| j	        n|¬¦  «        }t          j        ||| j        |                     ¦   «         | j        ¦  «         ŒÝ|S )a  
        Annotates the given scene with dots based on the provided detections.

        Args:
            scene: The image where dots will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> dot_annotator = sv.DotAnnotator()
            >>> annotated_frame = dot_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![dot-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/dot-annotator-example-purple.png)
        ©ÚanchorNr˜   r   ru   rô   )rY   rE   rž   Úget_anchors_coordinatesr2  rŸ   rx   r   rW   re   r‡   r@   r.  r-  r¢   r3  r4  )	ro   r”   r•   r–   Úxyr™   rW   r  r4  s	            rT   r§   zDotAnnotator.annotateý  sU  € õT ˜%¥¤Ñ,Ô,ð 	ØˆLØ×/Ò/°t´}Ð/ÑEÔEˆÝ"¥3 z¡?¤?Ñ3Ô3ð 	ð 	ˆMÝ!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ˜"˜]¨AÐ-Ô.Ñ/Ô/µ°R¸ÀqÐ8HÔ5IÑ1JÔ1JÐKˆFåŒJ�u˜f d¤k°5·<²<±>´>À2ÑFÔFÐFØÔ%ð Ý -ØÔ,Ø)Ø"/à*Ð2ð "&Ô!2Ð!2à,ð!ñ !ô !�õ ”
ØØØ”KØ!×(Ò(Ñ*Ô*ØÔ*ñô ð øð ˆrV   r¨   )r   r€   r�   r‚   r)   rƒ   r.   ÚCENTERr   r„   r(   ÚBLACKrZ   r‡   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   r1  r1  Ú  s  € € € € € ðð ð -9Ô,@ØØ%œ_Ø$/Ô$5Ø!"Ø49´KðYð Yà�|Ñ# cÑ)ðYð ðYð ð	Yð
 "ðYð ðYð ˜|Ñ+¨cÑ1ðYð Yð Yð Yð: 'ð
 <@ð	Hð HàðHð ðHð !œ[¨¬Ô1°DÑ8ð	Hð
 
ðHð Hð Hñ 'Ô&ðHð Hð HrV   r1  c                   ól  ‡ — e Zd ZdZej        ej        ej	        ddde
j        ddddfd	eez  ez  d
edeez  ez  dededede
deeef         dedededz  fˆ fd„Ze	 	 d dededee         dz  dej        ej                 dz  def
d„¦   «         Zdedee         defd„Zdej        ej                 dee         dej        ej                 dedej        ej                 dz  ddfd„Ze dej        ej                 deeeeef         d	eeeef         dedej        ej                 f
d„¦   «         Z!ˆ xZ"S )!ÚLabelAnnotatorzN
    A class for annotating labels on an image using provided detections.
    rÛ   ru   rc   rd   r   FNrW   re   rf   Ú
text_scaleÚtext_thicknessrg   rh   ri   rj   rk   rl   c                 óx   •— || _         || _        t          ¦   «                              |||||||	|
|¬¦	  «	         dS )aš  
        Args:
            color: The color or color palette to use for
                annotating the text background.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            text_color: The color or color palette to use
                for the text.
            text_scale: Font scale for the text.
            text_thickness: Thickness of the text characters.
            text_padding: Padding around the text within its background box.
            text_position: Position of the text relative to the detection.
                Possible values are defined in the `Position` enum.
            text_offset: A tuple of 2D coordinates `(x, y)` to
                offset the text position from the anchor point, in pixels.
            border_radius: The radius to apply round edges. If the selected
                value is higher than the lower dimension, width or height, is clipped.
            smart_position: Spread out the labels to avoid overlapping.
            max_line_length: Maximum number of characters per line
                before wrapping the text. None means no wrapping.
        ©	rW   re   rf   rg   rh   ri   rj   rk   rl   N)r?  r@  Úsuperrp   )ro   rW   re   rf   r?  r@  rg   rh   ri   rj   rk   rl   Ú	__class__s               €rT   rp   zLabelAnnotator.__init__N  s[   ø€ ðF ",ˆŒØ#1ˆÔÝ‰Œ×ÒØØ%Ø!Ø%Ø'Ø#Ø'Ø)Ø+ð 	ñ 
	
ô 
	
ð 
	
ð 
	
ð 
	
rV   r”   r•   rq   r–   r9   c                 óJ  — t          |t          j        ¦  «        s|S t          ||¦  «         t	          ||¦  «        }|                      ||¦  «        }| j        r/|                      |j        d         |j        d         f||¦  «        }|  	                    |||||¬¦  «         |S )aä  
        Annotates the given scene with labels based on the provided detections.

        Args:
            scene: The image where labels will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            labels: Custom labels for each detection.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     confidence=np.array([0.9]),
            ...     class_id=np.array([0]),
            ...     data={'class_name': np.array(['person'])}
            ... )
            >>> labels = [
            ...     f"{class_name} {confidence:.2f}"
            ...     for class_name, confidence
            ...     in zip(detections['class_name'], detections.confidence)
            ... ]
            >>> label_annotator = sv.LabelAnnotator(text_position=sv.Position.CENTER)
            >>> annotated_frame = label_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections,
            ...     labels=labels
            ... )

            ```

        ![label-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/label-annotator-example-purple.png)
        ru   r   )r”   rq   rr   r•   r–   )
rY   rE   rž   r   r   Ú_get_label_propertiesrk   r~   rÁ   Ú_draw_labels)ro   r”   r•   rq   r–   rr   s         rT   r§   zLabelAnnotator.annotate  sÊ   € õh ˜%¥¤Ñ,Ô,ð 	ØˆLÝ˜ Ñ,Ô,Ð,å  ¨VÑ4Ô4ˆØ48×4NÒ4NØ˜ñ5
ô 5
Ðð Ôð 	Ø#×;Ò;Ø”˜Q” ¤¨Q¤Ð0ØØ ñ ô  Ðð 	×ÒØØØ-Ø!Ø 3ð 	ñ 	
ô 	
ð 	
ð ˆrV   c                 ó^  — g }|                      | j        ¬¦  «                             t          ¦  «        }t	          ||¦  «        D �]3\  }}|d         | j        d         z   |d         | j        d         z   f}t          || j        ¦  «        }g }g }	|D ]\}
t          j	        |
t          | j        | j        ¬¦  «        d         \  }}|                     |¦  «         |	                     |¦  «         Œ]|	rt          |	¦  «        nd}t          |¦  «        t!          |¦  «        dz
  | j        z  z   }|d| j        z  z   }|d| j        z  z   }t%          |||f| j        ¬¦  «        }|                     g |¢|‘¦  «         �Œ5t'          j        |t&          j        ¬¦  «                             dd	¦  «        S )
Nr7  r   ru   ©ÚtextÚfontFaceÚ	fontScalerŽ   r=   ©Úcenter_coordinatesÚtext_whr2  rv   rô   é   )r9  rn   rL   r‡   Úzipri   r   rl   r@   ÚgetTextSizeÚCV2_FONTr?  r@  ÚappendrÅ   Úsumrx   rg   r   rE   r°   ry   Úreshape)ro   r•   rq   rr   Úanchors_coordinatesÚlabelrN  Úwrapped_linesÚline_heightsÚline_widthsr"  Útext_wÚtext_hÚ	max_widthÚtotal_heightÚwidth_paddedÚheight_paddedÚtext_background_xyxys                     rT   rF  z$LabelAnnotator._get_label_propertiesÍ  s
  € ð
 ÐØ5?×5WÒ5WØÔ#ð 6Xñ 6
ô 6
ç
Š&•‰+Œ+ð 	õ *-¨VÐ5HÑ)IÔ)Ið )	ñ )	Ñ%ˆEÐ%à" 1Ô%¨Ô(8¸Ô(;Ñ;Ø" 1Ô%¨Ô(8¸Ô(;Ñ;ð"Ðõ
 & e¨TÔ-AÑBÔBˆMØˆLØˆKà%ð +ð +�Ý#&¤?ØÝ%Ø"œoØ"Ô1ð	$ñ $ô $ð
 ô$Ñ �˜ð ×#Ò# FÑ+Ô+Ð+Ø×"Ò" 6Ñ*Ô*Ð*Ð*ð -8Ð>�˜KÑ(Ô(Ð(¸QˆIå�LÑ!Ô!¥S¨Ñ%6Ô%6¸Ñ%:¸dÔ>OÑ$OÑOð ð
 % q¨4Ô+<Ñ'<Ñ<ˆLØ(¨1¨tÔ/@Ñ+@Ñ@ˆMå#?Ø#5Ø% }Ð5ØÔ)ð$ñ $ô $Ð ð ×#Ò#ðØ)ðà ðñô ð ñ õ ŒxÐ(µ´
Ð;Ñ;Ô;×CÒCÀBÈÑJÔJÐJrV   rr   c                 óF  — t          |¦  «        t          |¦  «        cxk    rt          |¦  «        k    s=n J dt          |¦  «        › dt          |¦  «        › dt          |¦  «        › d�¦   «         ‚|�|n| j        }t          |¦  «        D �]“\  }}t          | j        |||¬¦  «        }	t          | j        |||¬¦  «        }
|d d…                              t          ¦  «        }|                      |||	 	                    ¦   «         | j
        ¬¦  «         t          ||         | j        ¦  «        }|d         | j        z   }|D ]Ý}|s>t          j        d	t           | j        | j        ¬
¦  «        d         \  }}||| j        z   z  }ŒBt          j        |t           | j        | j        ¬
¦  «        d         \  }}|d         | j        z   }||z   }t          j        ||||ft           | j        |
 	                    ¦   «         | j        t          j        ¬¦  «         ||| j        z   z  }ŒÞ�Œ•d S )NúNumber of label properties (ú), labels (ú) and detections (ú) do not match.r˜   rt   )r”   r    rW   rj   ru   ÚTgrI  r   )r›   rJ  ÚorgrK  rL  rW   rŽ   r  )rx   re   Ú	enumerater   rW   rf   rL   r‡   r+   r¢   rj   r   rl   rg   r@   rR  rS  r?  r@  ÚputTextÚLINE_AA)ro   r”   rq   rr   r•   r–   re   ÚidxÚlabel_propertyÚbackground_colorrf   Úbox_xyxyrY  Ú	current_yr"  r_   r]  Útext_xÚtext_ys                      rT   rG  zLabelAnnotator._draw_labels  s°  € õ �6‰{Œ{�cÐ"2Ñ3Ô3ÐFÐFÒFÐFµs¸:±´ÒFÐFÐFÐFÐFð­3Ð/?Ñ+@Ô+@ð ð Ý˜6‘{”{ðð Ý69¸*±o´oðð ð ñ GÔFÐFð #Ð.ð  ÐàÔ"ð 	õ $-Ð-=Ñ#>Ô#>ð <	8ñ <	8ÑˆC�Ý,Ø”jØ%Ø!Ø)ð	 ñ  ô  Ðõ 'Ø”oØ%Ø!Ø)ð	ñ ô ˆJð & b q bÔ)×0Ò0µÑ5Ô5ˆHà×'Ò'ØØØ&×-Ò-Ñ/Ô/Ø"Ô0ð	 (ñ ô ð õ & f¨S¤k°4Ô3GÑHÔHˆMØ  œ dÔ&7Ñ7ˆIà%ð !8ð !8�Øð 	å"%¤/Ø!Ý!)Ø"&¤/Ø"&Ô"5ð	#ñ #ô #ð
 ô#‘K�Q˜ð  ¨$Ô*;Ñ!;Ñ;�IØå!œoØÝ%Ø"œoØ"Ô1ð	ñ ô ð
 ô‘��Fð " !œ tÔ'8Ñ8�Ø" VÑ+�å”ØØØ Ð(Ý%Ø"œoØ$×+Ò+Ñ-Ô-Ø"Ô1Ý œ[ð	ñ 	ô 	ð 	ð ˜V dÔ&7Ñ7Ñ7�	�	ñC!8ð7<	8ð <	8rV   r    c                 óÈ  — |\  }}}}||z
  }||z
  }	t          |t          ||	¦  «        dz  ¦  «        }|dk    rt          j        | ||f||f|d¬¦  «         | S ||z   |f||z
  |ff|||z   f|||z
  ffg}
||z   ||z   f||z
  ||z   f||z   ||z
  f||z
  ||z
  fg}|
D ]'}t          j        | |d         |d         |d¬¦  «         Œ(|D ]}t          j        | |||d¬¦  «         Œ| S )aG  Draw a filled rectangle with optional rounded corners on an image.

        Args:
            scene: BGR image array to draw on; modified in-place and returned.
            xyxy: Bounding box as (x1, y1, x2, y2) pixel coordinates.
            color: Fill color as a BGR tuple (e.g. ``(0, 0, 255)`` for red).
            border_radius: Corner rounding radius in pixels. Values <= 0
                (including values clamped to 0 by a degenerate box) draw a
                plain filled rectangle with square corners.

        Returns:
            The annotated ``scene`` array.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> scene = np.zeros((200, 200, 3), dtype=np.uint8)
            >>> scene = sv.LabelAnnotator.draw_rounded_rectangle(
            ...     scene=scene,
            ...     xyxy=(10, 10, 100, 50),
            ...     color=(0, 255, 0),
            ...     border_radius=0,
            ... )
            >>> bool(scene[30, 50].tolist() == [0, 255, 0])
            True

            ```
        r=   r   rô   rš   ru   r,  )rÆ   r@   r¡   r.  )r”   r    rW   rj   r£   r¤   r¥   r¦   r  ÚheightÚrectangle_coordinatesÚcircle_centersÚcoordinatesr  s                 rT   r+   z%LabelAnnotator.draw_rounded_rectangleU  s¤  € ðH ‰ˆˆB��BØ�R‘ˆØ�b‘ˆå˜M­3¨u°fÑ+=Ô+=ÀÑ+BÑCÔCˆà˜AÒÐõ ŒMØØ˜�HØ˜�HØØðñ ô ð ð ˆLð �=Ñ  "Ð%¨¨]Ñ(:¸BÐ'?Ð@Ø�"�}Ñ$Ð%¨¨B°Ñ,>Ð'?Ð@ð!
Ðð
 �-Ñ  mÑ!3Ð4Ø�-Ñ  mÑ!3Ð4Ø�-Ñ  mÑ!3Ð4Ø�-Ñ  mÑ!3Ð4ð	
ˆð 1ð 	ð 	ˆKÝŒMØØ ”NØ ”NØØðñ ô ð ð ð %ð 	ð 	ˆFÝŒJØØØ$ØØðñ ô ð ð ð ˆrV   ©NN)#r   r€   r�   r‚   r)   rƒ   r   r„   r(   r…   r.   r†   rZ   ré   r‡   rˆ   r‰   rp   r0   r'   r    rŠ   rG   rH   rE   rª   r§   r   rF  rF   ry   rG  Ústaticmethodr+   Ú__classcell__©rD  s   @rT   r>  r>  I  sÆ  ø€ € € € € ðð ð -9Ô,@Ø$/Ô$5Ø16´ØØØØ"*Ô"3Ø'-ØØ$Ø&*ð/
ð /
à�|Ñ# cÑ)ð/
ð "ð/
ð ˜LÑ(¨3Ñ.ð	/
ð
 ð/
ð ð/
ð ð/
ð  ð/
ð ˜3 ˜8”_ð/
ð ð/
ð ð/
ð ˜t™ð/
ð /
ð /
ð /
ð /
ð /
ðb 'ð
 $(Ø;?ðKð KàðKð ðKð �S”	˜DÑ ð	Kð
 !œ[¨¬Ô1°DÑ8ðKð 
ðKð Kð Kñ 'Ô&ðKðZ4Kàð4Kð �S”	ð4Kð 
ð	4Kð 4Kð 4Kð 4KðlP8àŒ{˜2œ8Ô$ðP8ð �S”	ðP8ð œ+ b¤jÔ1ð	P8ð
 ðP8ð !œ[¨¬Ô1°DÑ8ðP8ð 
ðP8ð P8ð P8ð P8ðd ðPØŒ{˜2œ8Ô$ðPà�C˜˜c 3Ð&Ô'ðPð �S˜#˜s�]Ô#ðPð ð	Pð
 
Œ�R”XÔ	ðPð Pð Pñ „\ðPð Pð Pð Pð PrV   r>  c                   ó  ‡ — e Zd ZdZej        ej        ej	        ddde
j        ddddfdeez  ez  ded	eez  ez  d
edz  dedede
deeef         dedededz  fˆ fd„Ze	 	 ddededee         dz  dej        ej                 dz  def
d„¦   «         Zdej        dedee         defd„Zdej        dee         dej        ej                 dedej        ej                 dz  ddfd„Zeded
edz  de j!        e j         z  fd„¦   «         Z"ˆ xZ#S )ÚRichLabelAnnotatorzŽ
    A class for annotating labels on an image using provided detections,
    with support for Unicode characters by using a custom font.
    Nrc   rd   r   FrW   re   rf   Ú	font_pathÚ	font_sizerg   rh   ri   rj   rk   rl   c                 ó®   •— || _         || _        |                      ||¦  «        | _        t	          ¦   «                              |||||||	|
|¬¦	  «	         dS )aØ  
        Args:
            color: The color or color palette to use for
                annotating the text background.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            text_color: The color to use for the text.
            font_path: Path to the font file (e.g., ".ttf" or ".otf")
                to use for rendering text. If `None`, the default PIL font will be used.
            font_size: Font size for the text.
            text_padding: Padding around the text within its background box.
            text_position: Position of the text relative to the detection.
                Possible values are defined in the `Position` enum.
            text_offset: A tuple of 2D coordinates `(x, y)` to
                offset the text position from the anchor point, in pixels.
            border_radius: The radius to apply round edges. If the selected
                value is higher than the lower dimension, width or height, is clipped.
            smart_position: Spread out the labels to avoid overlapping.
            max_line_length: Maximum number of characters per line
                before wrapping the text. None means no wrapping.
        rB  N)r  r€  Ú
_load_fontÚfontrC  rp   )ro   rW   re   rf   r  r€  rg   rh   ri   rj   rk   rl   rD  s               €rT   rp   zRichLabelAnnotator.__init__¯  so   ø€ ðF #ˆŒØ"ˆŒØ—O’O I¨yÑ9Ô9ˆŒ	Ý‰Œ×ÒØØ%Ø!Ø%Ø'Ø#Ø'Ø)Ø+ð 	ñ 
	
ô 
	
ð 
	
ð 
	
ð 
	
rV   r”   r•   rq   r–   r9   c                 óX  — t          ||¦  «         t          j        |¦  «        }t          ||¦  «        }|                      |||¦  «        }| j        r=t          t          j        |¦  «        }|                      |j	        |j
        f||¦  «        }|                      |||||¬¦  «         |S )a«  
        Annotates the given scene with labels based on the provided
        detections, with support for Unicode characters.

        Args:
            scene: The image where labels will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            labels: Custom labels for each detection.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> from PIL import Image
            >>> image = Image.fromarray(np.zeros((100, 100, 3), dtype=np.uint8))
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     confidence=np.array([0.9]),
            ...     class_id=np.array([0]),
            ...     data={'class_name': np.array(['person'])}
            ... )
            >>> labels = [
            ...     f"{class_name} {confidence:.2f}"
            ...     for class_name, confidence
            ...     in zip(detections['class_name'], detections.confidence)
            ... ]
            >>> rich_label_annotator = sv.RichLabelAnnotator()
            >>> annotated_frame = rich_label_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections,
            ...     labels=labels
            ... )

            ```
        )Údrawrq   rr   r•   r–   )r   r   ÚDrawr   rF  rk   r   r   r~   r  ru  rG  )ro   r”   r•   rq   r–   r…  rr   Ú	scene_pils           rT   r§   zRichLabelAnnotator.annotateá  sÌ   € õf 	˜ Ñ,Ô,Ð,åŒ~˜eÑ$Ô$ˆÝ  ¨VÑ4Ô4ˆØ48×4NÒ4NØ�*˜fñ5
ô 5
Ðð Ôð 	Ý�Uœ[¨%Ñ0Ô0ˆIØ#×;Ò;Ø” )Ô"2Ð3ØØ ñ ô  Ðð 	×ÒØØØ-Ø!Ø 3ð 	ñ 	
ô 	
ð 	
ð ˆrV   r…  c                 ó’  — g }|                      | j        ¬¦  «                             t          ¦  «        }t	          ||¦  «        D �]K\  }}|d         | j        d         z   |d         | j        d         z   f}t          || j        ¦  «        }d}	d}
|D ]C}|                     d|| j	        ¬¦  «        \  }}}}||z
  }||z
  }t          |	|¦  «        }	|
|z  }
ŒDt          |¦  «        dk    r|
t          |¦  «        dz
  | j        z  z  }
t          |	d| j        z  z   ¦  «        }t          |
d| j        z  z   ¦  «        }t          |||f| j        ¬¦  «        }|                     dd	| j	        ¬¦  «        \  }}}}|                     g |¢|‘|‘¦  «         �ŒMt          j        |t          j        ¬
¦  «                             dd¦  «        }|S )Nr7  r   ru   r  rd   ©rƒ  r=   rM  rh  rv   rô   é   )r9  rn   rL   r‡   rQ  ri   r   rl   Útextbboxrƒ  rÅ   rx   rg   r   rT  rE   r°   ry   rV  )ro   r…  r•   rq   rr   Úanchor_coordinatesrX  rN  rY  r^  r_  r"  ÚleftÚtopÚrightÚbottomÚ
line_widthÚline_heightr`  ra  rb  Ú	text_leftÚtext_topr_   rS   s                            rT   rF  z(RichLabelAnnotator._get_label_properties.  s  € ð Ðà4>×4VÒ4VØÔ#ð 5Wñ 5
ô 5
ç
Š&•‰+Œ+ð 	õ *-¨VÐ5GÑ)HÔ)Hð $	Rñ $	RÑ%ˆEÐ%à" 1Ô%¨Ô(8¸Ô(;Ñ;Ø" 1Ô%¨Ô(8¸Ô(;Ñ;ð"Ðõ
 & e¨TÔ-AÑBÔBˆMð ˆIØˆLà%ð ,ð ,�Ø+/¯=ª=¸ÀÈDÌI¨=Ñ+VÔ+VÑ(��c˜5 &Ø" T™\�
Ø$ s™l�å 	¨:Ñ6Ô6�	Ø Ñ+��õ �=Ñ!Ô! AÒ%Ð%Ø¥ ]Ñ!3Ô!3°aÑ!7¸4Ô;LÑ LÑL�å˜y¨1¨tÔ/@Ñ+@Ñ@ÑAÔAˆLÝ ¨q°4Ô3DÑ/DÑ DÑEÔEˆMå#?Ø#5Ø% }Ð5ØÔ)ð$ñ $ô $Ð ð )-¯ª°f¸dÈÌ¨Ñ(SÔ(SÑ%ˆI�x  Aà×#Ò#Ð$PÐ&:Ð$P¸IÐ$PÀxÐ$PÑQÔQÐQÑQå*,¬(Ø¥B¤Jð+
ñ +
ô +
ç
Š'�"�a‰.Œ.ð 	ð ˆrV   rr   c           	      óÂ  — t          |¦  «        t          |¦  «        cxk    rt          |¦  «        k    s=n J dt          |¦  «        › dt          |¦  «        › dt          |¦  «        › d�¦   «         ‚|�|n| j        }t          |¦  «        D �]Q\  }}t          | j        |||¬¦  «        }	t          | j        |||¬¦  «        }
|d d…                              t          ¦  «        }|d         }|d         }|                     t          |¦  «        | j
        |	                     ¦   «         d ¬¦  «         t          ||         | j        ¦  «        }|d	         | j        z   |z
  }|d
         | j        z   |z
  }|D ]h}|                     ||f|| j        |
                     ¦   «         ¬¦  «         |                     d|| j        ¬¦  «        \  }}}}||z
  }||| j        z   z  }Œi�ŒSd S )Nrd  re  rf  rg  r˜   rt   rP  )r-  ÚfillÚoutliner   ru   )r:  rJ  rƒ  r–  rd   r‰  )rx   re   rj  r   rW   rf   rL   r‡   Úrounded_rectanglerˆ   rj   Úas_rgbr   rl   rg   rJ  rƒ  r‹  )ro   r…  rq   rr   r•   r–   re   rm  rn  ro  rf   rp  r“  r”  rY  Ú
x_positionÚ
y_positionr"  Ú_leftrŽ  Ú_rightr�  r’  s                          rT   rG  zRichLabelAnnotator._draw_labelsb  s\  € õ �6‰{Œ{�cÐ"2Ñ3Ô3ÐFÐFÒFÐFµs¸:±´ÒFÐFÐFÐFÐFð­3Ð/?Ñ+@Ô+@ð ð Ý˜6‘{”{ðð Ý69¸*±o´oðð ð ñ GÔFÐFð #Ð.ð  ÐàÔ"ð 	õ $-Ð-=Ñ#>Ô#>ð *	>ñ *	>ÑˆC�Ý,Ø”jØ%Ø!Ø)ð	 ñ  ô  Ðõ 'Ø”oØ%Ø!Ø)ð	ñ ô ˆJð & b q bÔ)×0Ò0µÑ5Ô5ˆHØ& qÔ)ˆIØ% aÔ(ˆHð ×"Ò"Ý�h‘”ØÔ)Ø%×,Ò,Ñ.Ô.Øð	 #ñ ô ð õ & f¨S¤k°4Ô3GÑHÔHˆMØ! !œ tÔ'8Ñ8¸9ÑDˆJØ! !œ tÔ'8Ñ8¸8ÑCˆJà%ð >ð >�Ø—	’	Ø" JÐ/ØØœØ#×*Ò*Ñ,Ô,ð	 ñ ô ð ð .2¯]ª]¸6À4ÈdÌi¨]Ñ-XÔ-XÑ*��s˜F FØ$ s™l�Ø˜k¨DÔ,=Ñ=Ñ=�
�
ñ>ð?*	>ð *	>rV   c                 óü   — dt           dt          j        t          j        z  fd„}|€ || ¦  «        S 	 t          j        || ¦  «        S # t          $ r) t
                               d|¦  «          || ¦  «        cY S w xY w)NÚsizer9   c                 ór   — 	 t          j        | ¦  «        S # t          $ r t          j        ¦   «         cY S w xY wr¨   )r   Úload_defaultÚ	TypeError)rŸ  s    rT   Úload_default_fontz8RichLabelAnnotator._load_font.<locals>.load_default_font¥  sH   € ð0Ý Ô-¨dÑ3Ô3Ð3øÝð 0ð 0ð 0Ý Ô-Ñ/Ô/Ð/Ð/Ð/ð0øøøs   ‚ –6µ6z3Font path '%s' not found. Using PIL's default font.)r‡   r   ÚFreeTypeFontÚtruetypeÚOSErrorÚloggerÚwarning)r€  r  r£  s      rT   r‚  zRichLabelAnnotator._load_font¡  s±   € ð	0Ýð	0åÔ#¥iÔ&9Ñ9ð	0ð 	0ð 	0ð 	0ð ÐØ$Ð$ YÑ/Ô/Ð/ð	0ÝÔ% i°Ñ;Ô;Ð;øÝð 	0ð 	0ð 	0Ý�NŠNØEÀyñô ð ð %Ð$ YÑ/Ô/Ð/Ð/Ð/ð		0øøøs   ³A Á0A;Á:A;ry  )$r   r€   r�   r‚   r)   rƒ   r   r„   r(   r…   r.   r†   rZ   r‡   rˆ   r‰   rp   r1   r'   r    rŠ   rG   rH   rE   rª   r§   r   r   rF  ry   rG  rz  r   r¤  r‚  r{  r|  s   @rT   r~  r~  ©  s{  ø€ € € € € ðð ð -9Ô,@Ø$/Ô$5Ø16´Ø $ØØØ"*Ô"3Ø'-ØØ$Ø&*ð0
ð 0
à�|Ñ# cÑ)ð0
ð "ð0
ð ˜LÑ(¨3Ñ.ð	0
ð
 ˜‘:ð0
ð ð0
ð ð0
ð  ð0
ð ˜3 ˜8”_ð0
ð ð0
ð ð0
ð ˜t™ð0
ð 0
ð 0
ð 0
ð 0
ð 0
ðd 'ð
 $(Ø;?ðJð JàðJð ðJð �S”	˜DÑ ð	Jð
 !œ[¨¬Ô1°DÑ8ðJð 
ðJð Jð Jñ 'Ô&ðJðX2ØÔ'ð2Ø5?ð2ØIMÈcÌð2à	ð2ð 2ð 2ð 2ðh=>àÔ!ð=>ð �S”	ð=>ð œ+ b¤jÔ1ð	=>ð
 ð=>ð !œ[¨¬Ô1°DÑ8ð=>ð 
ð=>ð =>ð =>ð =>ð~ ð0Øð0Ø#&¨¡:ð0à	Ô	 )Ô"5Ñ	5ð0ð 0ð 0ñ „\ð0ð 0ð 0ð 0ð 0rV   r~  c            
       óÆ   — e Zd ZdZdej        dfdeeef         dedeeef         fd„Ze		 dd	e
d
edeee         z  de
fd„¦   «         Zdedej        ej                 fd„ZdS )ÚIconAnnotatorzM
    A class for drawing an icon on an image, using provided detections.
    )é@   r«  rd   r8   Úicon_positionÚ	offset_xyc                 ó0   — || _         || _        || _        dS )a\  
        Args:
            icon_resolution_wh: The size of drawn icons.
                All icons will be resized to this resolution, keeping the aspect ratio.
            icon_position: The position of the icon.
            offset_xy: The offset to apply to the icon position,
                in pixels. Can be both positive and negative.
        N)r8   r2  r­  )ro   r8   r¬  r­  s       rT   rp   zIconAnnotator.__init__¾  s   € ð #5ˆÔØ%ˆŒØ"ˆŒˆˆrV   Ú r”   r•   r7   r9   c                 ó"  — t          |t          j        ¦  «        s|S t          |t          ¦  «        rPt	          |¦  «        t	          |¦  «        k    r0t          dt	          |¦  «        › dt	          |¦  «        › d�¦  «        ‚|                     | j        ¬¦  «                             t          ¦  «        }t          t	          |¦  «        ¦  «        D ]½}t          |t          ¦  «        r|n||         }|dk    rŒ(|                      |¦  «        }|j        dd…         \  }}	t          ||df         |	dz  z
  | j        d         z   ¦  «        }
t          ||d	f         |dz  z
  | j        d	         z   ¦  «        }t          |||
|f¦  «        |dd…<   Œ¾|S )
a#  
        Annotates the given scene with given icons.

        Args:
            scene: The image where labels will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            icon_path: The path to the PNG image to use as an
                icon. Must be a single path or a list of paths, one for each detection.
                Pass an empty string `""` to draw nothing.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Example:
            ```python
            import supervision as sv

            image = ...
            detections = sv.Detections(...)

            available_icons = ["roboflow.png", "lenny.png"]
            icon_paths = [np.random.choice(available_icons) for _ in detections]

            icon_annotator = sv.IconAnnotator()
            annotated_frame = icon_annotator.annotate(
                scene=image.copy(),
                detections=detections,
                icon_path=icon_paths
            )
            ```

        ![icon-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/icon-annotator-example.png)
        z#The number of icon paths provided (z+) does not match the number of detections (z?). Either provide a single icon path or one for each detection.r7  r¯  Nr=   r   ru   )rY   rE   rž   rŠ   rx   rM   r9  r2  rL   r‡   rŸ   rZ   Ú
_load_iconrÁ   r­  r2   )ro   r”   r•   r7   r:  r™   Úcurrent_pathrQ   Úicon_hÚicon_wr$  r%  s               rT   r§   zIconAnnotator.annotateÐ  s¦  € õX ˜%¥¤Ñ,Ô,ð 	ØˆLÝ�i¥Ñ&Ô&ð 	­3¨y©>¬>½SÀ¹_¼_Ò+LÐ+LÝð9µc¸)±n´nð 9ð 9Ý-0°©_¬_ð9ð 9ð 9ñô ð ð %/×$FÒ$FØ”=ð %Gñ %
ô %
ç
Š&•‰+Œ+ð 	õ #¥3 z¡?¤?Ñ3Ô3ð 	;ð 	;ˆMå'¨	µ3Ñ7Ô7ÐU�	�	¸YÀ}Ô=Uð ð ˜rÒ!Ð!ØØ—?’? <Ñ0Ô0ˆDØ!œZ¨¨¨œ^‰NˆF�Få�B�} aÐ'Ô(¨6°A©:Ñ5¸¼ÀqÔ8IÑIÑJÔJˆAÝ�B�} aÐ'Ô(¨6°A©:Ñ5¸¼ÀqÔ8IÑIÑJÔJˆAå% e¨T°A°q°6Ñ:Ô:ˆE�!�!�!‰HˆHØˆrV   c                 ó.   — t          || j        ¬¦  «        S )zALoad an icon through the module-level cache shared by annotators.)r7   r8   )rU   r8   )ro   r7   s     rT   r±  zIconAnnotator._load_icon  s!   € å#Ø°DÔ4Kð
ñ 
ô 
ð 	
rV   N)r¯  )r   r€   r�   r‚   r.   Ú
TOP_CENTERrˆ   r‡   rp   r0   r'   r    rZ   rŠ   r§   rG   rH   rE   rF   r±  r‹   rV   rT   rª  rª  ¹  sÿ   € € € € € ðð ð /7Ø"*Ô"5Ø%+ð	#ð #à! # s (œOð#ð  ð#ð ˜˜c˜”?ð	#ð #ð #ð #ð$ 'ð
 &(ð	Eð EàðEð ðEð ˜˜cœ‘?ð	Eð
 
ðEð Eð Eñ 'Ô&ðEðN
 Cð 
¨C¬K¸¼Ô,Að 
ð 
ð 
ð 
ð 
ð 
rV   rª  c                   óJ   — e Zd ZdZd	dedz  fd„Zedededefd„¦   «         Z	dS )
ÚBlurAnnotatorzM
    A class for blurring regions in an image using provided detections.
    Nrû   c                 óJ   — |�|dk     rt          d|› d�¦  «        ‚|| _        dS )a  
        Args:
            kernel_size: The size of the average pooling kernel used for blurring.
                If not set, a dynamic size is computed as one-third of the shorter
                bounding-box dimension. Must be >= 1 when provided.
        Nru   zkernel_size must be >= 1, got ú.)rM   rû   )ro   rû   s     rT   rp   zBlurAnnotator.__init__$  s:   € ð Ð" {°Q¢ ÝÐL¸kÐLÐLÐLÑMÔMÐMØ'2ˆÔÐÐrV   r”   r•   r9   c           	      óà  — t          |t          j        ¦  «        s|S |j        dd…         \  }}t	          |j        ||f¬¦  «                             t          ¦  «        }|D ]Œ\  }}}}	||k    s|	|k    rŒ|||	…||…f         }
| j        �| j        nt          ||||	¦  «        }t          t          j        t          j                 t          j        |
||f¦  «        ¦  «        }
|
|||	…||…f<   Œ�|S )a£  
        Annotates the given scene by blurring regions based on the provided detections.

        Args:
            scene: The image where blurring will be applied.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> blur_annotator = sv.BlurAnnotator()
            >>> annotated_frame = blur_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![blur-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/blur-annotator-example-purple.png)
        Nr=   ©r    r?   )rY   rE   rž   rÁ   r!   r    rL   r‡   rû   r   r   rG   rH   rF   r@   rÿ   )ro   r”   r•   Úimage_heightÚimage_widthÚclipped_xyxyr£   r¤   r¥   r¦   rä   rû   s               rT   r§   zBlurAnnotator.annotate/  s  € õN ˜%¥¤Ñ,Ô,ð 	ØˆLØ$)¤K°°°¤OÑ!ˆ�kÝ.8Ø”Ø&¨Ð5ð/
ñ /
ô /
÷ Š&•‰+Œ+ð 	ð
 +ð 
	&ð 
	&‰NˆB��B˜Ø�RŠxˆx˜2 š8˜8ØØ˜˜2˜˜r "˜u˜Ô%ˆCð Ô#Ð/ð Ô Ð å2°2°r¸2¸rÑBÔBð õ
 •s”{¥2¤8Ô,­c¬h°s¸[È+Ð<VÑ.WÔ.WÑXÔXˆCØ"%ˆE�"�R�%˜˜B˜�,ÑÐàˆrV   r¨   ©
r   r€   r�   r‚   r‡   rp   r0   r'   r    r§   r‹   rV   rT   r¸  r¸    s   € € € € € ðð ð	3ð 	3 C¨$¡Jð 	3ð 	3ð 	3ð 	3ð 'ð:àð:ð ð:ð 
ð	:ð :ð :ñ 'Ô&ð:ð :ð :rV   r¸  c                   óÄ   — e Zd ZdZej        ej        dddej	        fde
ez  ez  dededed	ed
efd„Zdd„Ze	 ddededej        ej                 dz  defd„¦   «         ZdS )ÚTraceAnnotatora  
    A class for drawing trace paths on an image based on detection coordinates.

    !!! warning

        This annotator uses the `sv.Detections.tracker_id`. Read
        [here](/latest/trackers/) to learn how to plug
        tracking into your inference pipeline.
    é   r=   FrW   r2  Útrace_lengthrŽ   Úsmoothre   c                 ó„   — t          |¦  «        | _        t          ||¬¦  «        | _        || _        || _        || _        dS )a)  
        Args:
            color: The color to draw the trace, can be
                a single color or a color palette.
            position: The position of the trace.
                Defaults to `CENTER`.
            trace_length: The maximum length of the trace in terms of historical
                points. Defaults to `30`.
            thickness: The thickness of the trace lines. Defaults to `2`.
            smooth: If `True`, applies spline smoothing to trace lines using
                consecutive unique anchor points. Falls back to a raw polyline
                when fewer than 4 unique points are available (e.g. when a
                tracker is stationary).
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
        )Úmax_sizer8  N)r`   rW   r   ÚtracerŽ   rÅ  re   )ro   rW   r2  rÄ  rŽ   rÅ  re   s          rT   rp   zTraceAnnotator.__init__x  sD   € õ2 ,BÀ%Ñ+HÔ+HˆŒ
Ý L¸ÐBÑBÔBˆŒ
Ø"ˆŒØˆŒØ)5ˆÔÐÐrV   r9   Nc                 ó8   — | j                              ¦   «          dS )aÃ  
        Clears the accumulated trace history so the annotator can be reused
        across independent streams without carrying over points from a
        previous stream.

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((20, 20, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[1, 1, 10, 10]]),
            ...     class_id=np.array([0]),
            ...     tracker_id=np.array([1])
            ... )
            >>> trace_annotator = sv.TraceAnnotator()
            >>> _ = trace_annotator.annotate(scene=image.copy(), detections=detections)
            >>> trace_annotator.trace.xy.shape
            (1, 2)
            >>> trace_annotator.reset()
            >>> trace_annotator.trace.current_frame_id
            0
            >>> trace_annotator.trace.xy.shape
            (0, 2)

            ```
        N)rÈ  Úreset©ro   s    rT   rÊ  zTraceAnnotator.reset—  s   € ð8 	Œ
×ÒÑÔÐÐÐrV   r”   r•   r–   c                 óÄ  — t          |t          j        ¦  «        s|S t          |¦  «        dk    r| j                             |¦  «         |S |j        €t          d¦  «        ‚|j        t          k    }||         }|�Wt          |¦  «        t          |¦  «        k    r/t          dt          |¦  «        › dt          |¦  «        › �¦  «        ‚||         }| j                             |¦  «         t          t          |¦  «        ¦  «        D �]U}|j        |         }|€Œt          |¦  «        }t          | j        |||€| j        n|¬¦  «        }	| j                             |¬¦  «        }
|
                     t          j        ¦  «        }| j        �rŒ|
t          j        dgt          j        t          j        |
d¬	¦  «        dk    d
¬	¦  «        f¦  «                 }t          |¦  «        dk    �r	 |dd…df         |dd…d
f         }}t+          ||gd¬¦  «        \  }}t-          t          j        dd
d¦  «        t1          t2          t4          j        t          j                 t4          j        t          j                 t          f         |¦  «        ¦  «        \  }}t          j        ||fd
¬	¦  «                             t          j        ¦  «        }nN# t          $ r" |                     t          j        ¦  «        }Y n#w xY w|                     t          j        ¦  «        }t          |
¦  «        d
k    r1t=          j        ||gd|	                      ¦   «         | j!        ¬¦  «         �ŒW|S )a.  
        Draws trace paths on the frame based on the detection coordinates provided.

        Args:
            scene: The image on which the traces will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: The detections which include coordinates for
                which the traces will be drawn. An empty `Detections` batch
                is a no-op: `scene` is returned unmodified.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Raises:
            ValueError: If `detections` is non-empty and its `tracker_id` field is
                missing.

        Examples:
            ```python
            import supervision as sv
            from rfdetr import RFDETRMedium

            model = RFDETRMedium()
            trace_annotator = sv.TraceAnnotator()

            video_info = sv.VideoInfo.from_video_path(video_path='...')
            frames_generator = sv.get_video_frames_generator(source_path='...')
            tracker = sv.ByteTrack()

            with sv.VideoSink(target_path='...', video_info=video_info) as sink:
               for frame in frames_generator:
                   detections = model.predict(frame[:, :, ::-1])
                   detections = tracker.update_with_detections(detections)
                   annotated_frame = trace_annotator.annotate(
                       scene=frame.copy(),
                       detections=detections)
                   sink.write_frame(frame=annotated_frame)
            ```

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> trace_annotator = sv.TraceAnnotator()
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[10, 10, 30, 30]]),
            ...     class_id=np.array([0]),
            ...     tracker_id=np.array([1]),
            ... )
            >>> _ = trace_annotator.annotate(scene=image.copy(), detections=detections)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[70, 70, 90, 90]]),
            ...     class_id=np.array([0]),
            ...     tracker_id=np.array([1]),
            ... )
            >>> annotated_frame = trace_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )
            >>> bool(annotated_frame.any())
            True
            >>> annotated_frame = trace_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=sv.Detections.empty()
            ... )
            >>> np.array_equal(annotated_frame, image)
            True

            ```

        ![trace-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/trace-annotator-example-purple.png)
        r   Nz„The `tracker_id` field is missing in the provided detections. See more: https://supervision.roboflow.com/latest/how_to/track_objectszLength of color lookup z% does not match length of detections r˜   )Ú
tracker_idT)Úaxisru   é   é   )Úséd   F)rW   rŽ   )"rY   rE   rž   rx   rÈ  ÚputrÍ  rM   r   rŸ   r‡   r   rW   re   ÚgetrL   Úint32rÅ  ÚconcatenateÚanyÚdiffr   r   Úlinspacer   rˆ   rG   rH   Úfloat64Ústackr@   Ú	polylinesr¢   rŽ   )ro   r”   r•   r–   Úis_confirmedÚfiltered_detectionsr™   Útracker_id_valrÍ  rW   r:  Úspline_pointsÚ	unique_xyr$  r%  ÚtckÚ_uÚx_newÚy_news                      rT   r§   zTraceAnnotator.annotateµ  sy  € õh ˜%¥¤Ñ,Ô,ð 	ØˆLõ ˆz‰?Œ?˜aÒÐØŒJ�NŠN˜:Ñ&Ô&Ð&ØˆLàÔ Ð(ÝðZñô ð ð "Ô,Õ0@Ò@ˆØ*4°\Ô*BÐð Ð*ÝÐ&Ñ'Ô'­3¨z©?¬?Ò:Ð:Ý ðM­cÐ2EÑ.FÔ.Fð Mð MÝ;>¸z¹?¼?ðMð Mñô ð ð #6°lÔ"CÐàŒ
�ŠÐ*Ñ+Ô+Ð+Ý"¥3Ð':Ñ#;Ô#;Ñ<Ô<ð 2	ñ 2	ˆMØ0Ô;¸MÔJˆNØÐ%ØÝ˜^Ñ,Ô,ˆJÝ!Ø”jØ.Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEð ”—’¨:�Ñ6Ô6ˆBØ35·9²9½R¼XÑ3FÔ3FˆMàŒ{ñ ?ØÝ”N T F­B¬Fµ2´7¸2ÀAÐ3FÑ3FÔ3FÈ!Ò3KÐRSÐ,TÑ,TÔ,TÐ#UÑVÔVô�	õ �y‘>”> AÒ%Ñ%ðCØ(¨¨¨¨A¨œ°	¸!¸!¸!¸Q¸$´˜1˜Ý")¨1¨a¨&°BÐ"7Ñ"7Ô"7™˜˜RÝ',ÝœK¨¨1¨cÑ2Ô2Ý Ý %Ý$'¤Kµ´
Ô$;Ý$'¤Kµ´
Ô$;Ý$'ð%)ô!"ð
 !$ñô ñ
(ô 
(™˜˜uõ )+¬°%¸°ÀaÐ(HÑ(HÔ(H×(OÒ(OÝœHñ)ô )˜˜øõ &ð Cð Cð CØ(1×(8Ò(8½¼Ñ(BÔ(B˜˜˜ðCøøøð %.×$4Ò$4µR´XÑ$>Ô$>�Må�2‰wŒw˜Š{ˆ{Ý”ØØ"�OØØŸ,š,™.œ.Ø"œnðñ ô ð ùð ˆs   Ç,CKË)K8Ë7K8©r9   Nr¨   )r   r€   r�   r‚   r)   rƒ   r.   r;  r   r„   r(   rZ   r‡   r‰   rp   rÊ  r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   rÂ  rÂ  m  s  € € € € € ðð ð -9Ô,@Ø%œ_ØØØØ$/Ô$5ð6ð 6à�|Ñ# cÑ)ð6ð ð6ð ð	6ð
 ð6ð ð6ð "ð6ð 6ð 6ð 6ð>ð ð ð ð< 'ð
 <@ð	eð eàðeð ðeð !œ[¨¬Ô1°DÑ8ð	eð
 
ðeð eð eñ 'Ô&ðeð eð erV   rÂ  c                   ó|   — e Zd ZdZej        dddddfdeded	ed
edz  dedefd„Zdd„Z	e
dededefd„¦   «         ZdS )ÚHeatMapAnnotatorz²
    A class for drawing heatmaps on an image based on provided detections.
    Heat accumulates over time and is drawn as a semi-transparent overlay
    of blurred circles.
    gš™™™™™É?rú   é   r   é}   r2  rÜ   r-  rû   NÚtop_hueÚlow_huec                 óh   — || _         || _        || _        || _        || _        || _        d| _        dS )a  
        Args:
            position: The position of the heatmap. Defaults to
                `BOTTOM_CENTER`.
            opacity: Opacity of the overlay mask. Must be between `0` and `1`.
            radius: Radius of the heat circle.
            kernel_size: Kernel size for blurring the heatmap. Pass `None`
                to disable blurring entirely.
            top_hue: Hue at the top of the heatmap. Defaults to 0 (red).
            low_hue: Hue at the bottom of the heatmap. Defaults to 125 (blue).
        N)r2  rÜ   r-  rû   rë  rì  Ú	heat_mask)ro   r2  rÜ   r-  rû   rë  rì  s          rT   rp   zHeatMapAnnotator.__init__e	  s:   € ð( !ˆŒØˆŒØˆŒØ&ˆÔØˆŒØˆŒØ9=ˆŒˆˆrV   r9   c                 ó   — d| _         dS )aÄ  
        Clears the accumulated heat so the annotator can be reused across
        independent streams. `annotate` already reinitializes the heat mask
        when the scene resolution changes; call this to discard heat from a
        previous stream that shares the same resolution.

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((40, 40, 3), dtype=np.uint8)
            >>> detections = sv.Detections(xyxy=np.array([[10, 10, 20, 20]]))
            >>> heat_map_annotator = sv.HeatMapAnnotator()
            >>> _ = heat_map_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )
            >>> bool(heat_map_annotator.heat_mask.sum() > 0)
            True
            >>> heat_map_annotator.reset()
            >>> heat_map_annotator.heat_mask is None
            True

            ```
        N)rî  rË  s    rT   rÊ  zHeatMapAnnotator.reset�	  s   € ð4 ˆŒˆˆrV   r”   r•   c                 ó²  — t          |t          j        ¦  «        s|S | j        �| j        j        |j        dd…         k    r2t          j        |j        dd…         t          j        ¬¦  «        | _        t          j        |j        dd…         t          j        ¬¦  «        }|                     | j        ¦  «        D ]L}t          |d         ¦  «        t          |d         ¦  «        }}t          j        |||f| j        dd¬¦  «         ŒM|| j        z   | _        | j        }|                     ¦   «         }|                     ¦   «         }	|	dk    r| j        ||	z  | j        | j        z
  z  z
  }|                     t          j        ¦  «        }
| j        �It)          t*          j        t          j                 t          j        |
| j        | j        f¦  «        ¦  «        }
t          j        |j        d	t          j        ¬¦  «        }|
|d
<   t          j        |t          j        ¦  «        }|dk    }t          j        || j        |d| j        z
  d¦  «        }||         ||<   |S )a¦  
        Annotates the scene with a heatmap based on the provided detections.

        Args:
            scene: The image where the heatmap will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Note:
            When `detections` is empty or no heat has accumulated yet, the
            scene is returned unchanged without raising a ``RuntimeWarning``.

        Examples:
            ```python
            import supervision as sv
            from rfdetr import RFDETRMedium

            model = RFDETRMedium()

            heat_map_annotator = sv.HeatMapAnnotator()

            video_info = sv.VideoInfo.from_video_path(video_path='...')
            frames_generator = sv.get_video_frames_generator(source_path='...')

            with sv.VideoSink(target_path='...', video_info=video_info) as sink:
               for frame in frames_generator:
                   detections = model.predict(frame[:, :, ::-1])
                   annotated_frame = heat_map_annotator.annotate(
                       scene=frame.copy(),
                       detections=detections)
                   sink.write_frame(frame=annotated_frame)
            ```

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0]),
            ... )
            >>> heat_map_annotator = sv.HeatMapAnnotator()
            >>> annotated_frame = heat_map_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )
            >>> bool(heat_map_annotator.heat_mask.sum() > 0)
            True

            ```

        ![heatmap-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/heat-map-annotator-example-purple.png)
        Nr=   rv   r   ru   )ru   rô   r,  r<   ).r   )rY   rE   rž   rî  rÁ   rÀ   ry   r9  r2  r‡   r@   r.  r-  rw   rÅ   rì  rë  rL   rF   rû   r   rG   rH   rÿ   ÚfullrO   ÚCOLOR_HSV2BGRrá   rÜ   )ro   r”   r•   rµ   r:  r$  r%  rî  Úheat_valuesÚmax_valÚheat_hueÚhsvÚheat_bgrÚmask2dÚblendeds                  rT   r§   zHeatMapAnnotator.annotate�	  s  € õz ˜%¥¤Ñ,Ô,ð 	ØˆLØŒ>Ð! T¤^Ô%9¸U¼[ÈÈ!È¼_Ò%LÐ%LÝœX e¤k°"°1°"¤o½R¼ZÐHÑHÔHˆDŒNå(*¬°´¸R¸a¸R´ÍÌ
Ð(SÑ(SÔ(SˆØ×4Ò4°T´]ÑCÔCð 	ð 	ˆBÝ�r˜!”u‘:”:�s 2 a¤5™zœzˆqˆAÝŒJØØ˜1�vØ”{ØØðñ ô ð ð ð  ¤Ñ.ˆŒØ”Nˆ	Ø—n’nÑ&Ô&ˆØ—/’/Ñ#Ô#ˆØ�QŠ;ˆ;Øœ,¨°wÑ)>Ø”˜tœ|Ñ+ñ*ñ ˆKð ×%Ò%¥b¤hÑ/Ô/ˆØÔÐ'ÝÝ”�BœHÔ%Ý”˜ DÔ$4°dÔ6FÐ#GÑHÔHñô ˆHõ Œg�e”k 3­b¬hÐ7Ñ7Ô7ˆØˆˆF‰Ý”< ¥SÔ%6Ñ7Ô7ˆØ˜Q’ˆÝ”/ (¨D¬L¸%ÀÀTÄ\ÑAQÐSTÑUÔUˆØ œˆˆf‰ØˆrV   ræ  )r   r€   r�   r‚   r.   ÚBOTTOM_CENTERré   r‡   rp   rÊ  r0   r'   r    r§   r‹   rV   rT   rè  rè  ^	  sß   € € € € € ðð ð &Ô3ØØØ"$ØØð>ð >àð>ð ð>ð ð	>ð
 ˜4‘Zð>ð ð>ð ð>ð >ð >ð >ð8ð ð ð ð8 'ð_˜ið _°Zð _ÀIð _ð _ð _ñ 'Ô&ð_ð _ð _rV   rè  c                   óJ   — e Zd ZdZd	dedz  fd„Zedededefd„¦   «         Z	dS )
ÚPixelateAnnotatorzO
    A class for pixelating regions in an image using provided detections.
    NÚ
pixel_sizec                 óJ   — |�|dk     rt          d|› d�¦  «        ‚|| _        dS )aŽ  
        Args:
            pixel_size: The size of the pixelation. If not set, a dynamic size is
                computed as one-half of the shorter bounding-box dimension. When set
                and the detection area is smaller than `pixel_size`, the region is
                filled with its average colour instead to avoid an OpenCV crash.
                Must be >= 1 when provided.
        Nru   zpixel_size must be >= 1, got rº  )rM   rý  )ro   rý  s     rT   rp   zPixelateAnnotator.__init__
  s7   € ð Ð! j°1¢n nÝÐJ¸ZÐJÐJÐJÑKÔKÐKØ&0ˆŒˆˆrV   r”   r•   r9   c                 óD  — t          |t          j        ¦  «        s|S |j        dd…         \  }}t	          |j        ||f¬¦  «                             t          ¦  «        }|D �]=\  }}}}	||k    s|	|k    rŒ|||	…||…f         }
| j        �| j        nt          ||||	¦  «        }t          |	|z
  ||z
  ¦  «        |k     r~|
j        dk    s|
j        dk    r5|
j        d         dk    r$t          j        |
¦  «        d         |||	…||…f<   n2|j        d         }t          j        |
¦  «        d|…         |||	…||…f<   ŒÛt          j        |
dd|z  d|z  ¬¦  «        }t          j        ||
j        d         |
j        d         ft          j        ¬¦  «        }||||	…||…f<   �Œ?|S )	aÃ  
        Annotates the given scene by pixelating regions based on the provided
            detections.

        Args:
            scene: The image where pixelating will be applied.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0]),
            ... )
            >>> pixelate_annotator = sv.PixelateAnnotator()
            >>> annotated_frame = pixelate_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![pixelate-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/pixelate-annotator-example-10.png)
        Nr=   r¼  rÏ  ru   r   )ÚsrcÚdsizeÚfxÚfy)r   r  Úinterpolation)rY   rE   rž   rÁ   r!   r    rL   r‡   rý  r   rÆ   rN   r@   ÚmeanÚresizeÚINTER_NEAREST)ro   r”   r•   r½  r¾  r¿  r£   r¤   r¥   r¦   rä   rý  Únum_channelsÚscaled_up_roiÚscaled_down_rois                  rT   r§   zPixelateAnnotator.annotate
  sê  € õP ˜%¥¤Ñ,Ô,ð 	ØˆLØ$)¤K°°°¤OÑ!ˆ�kÝ.8Ø”Ø&¨Ð5ð/
ñ /
ô /
÷ Š&•‰+Œ+ð 	ð
 +ð 	2ñ 	2‰NˆB��B˜Ø�RŠxˆx˜2 š8˜8ØØ˜˜2˜˜r "˜u˜Ô%ˆCð ”?Ð.ð ”�å1°"°b¸"¸bÑAÔAð õ
 �2˜‘7˜B ™GÑ$Ô$ zÒ1Ð1Ø”8˜q’=�= S¤X°¢] ]°s´yÀ´|ÀqÒ7HÐ7HÝ*-¬(°3©-¬-¸Ô*:�E˜"˜R˜%  B ˜,Ñ'Ð'à#(¤;¨q¤>�LÝ*-¬(°3©-¬-¸¸¸Ô*F�E˜"˜R˜%  B ˜,Ñ'ØåœJØ˜t¨¨J©¸1¸z¹>ðñ ô ˆMõ "œjØ!Ø”y ”| S¤Y¨q¤\Ð2Ý!Ô/ðñ ô ˆOð #2ˆE�"�R�%˜˜B˜�,ÑÑàˆrV   r¨   rÀ  r‹   rV   rT   rü  rü   
  sˆ   € € € € € ðð ð1ð 1 3¨¡:ð 1ð 1ð 1ð 1ð 'ðLàðLð ðLð 
ð	Lð Lð Lñ 'Ô&ðLð Lð LrV   rü  c                   óØ   — e Zd ZdZej        ddej        ej	        de
j        fde
ez  ez  dedededed	ed
e
ez  ez  fd„Ze	 ddededej        ej                 dz  defd„¦   «         ZdS )ÚTriangleAnnotatorzt
    A class for drawing triangle markers on an image at specific coordinates based on
    provided detections.
    rc   r   rW   Úbaseru  r2  re   r3  r4  c                 óœ   — t          |¦  «        | _        || _        || _        || _        || _        || _        t          |¦  «        | _        dS )a•  
        Args:
            color: The color or color palette to use for
                annotating detections.
            base: The base width of the triangle.
            height: The height of the triangle.
            position: The anchor position for placing the triangle.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            outline_thickness: Thickness of the outline of the triangle.
            outline_color: The color or color palette to
                use for outline. It is activated by setting outline_thickness to a value
                greater than 0.
        N)r`   rW   r  ru  r2  re   r3  r4  )ro   rW   r  ru  r2  re   r3  r4  s           rT   rp   zTriangleAnnotator.__init__h
  sO   € õ0 ,BÀ%Ñ+HÔ+HˆŒ
ØˆŒ	Ø!ˆŒØ"*ˆŒØ)5ˆÔØ&7ˆÔÝ3IÈ-Ñ3XÔ3XˆÔÐÐrV   Nr”   r•   r–   r9   c                 óô  — t          |t          j        ¦  «        s|S |                     | j        ¬¦  «        }t          t          |¦  «        ¦  «        D �]"}t          | j        |||€| j	        n|¬¦  «        }t          ||df         ¦  «        t          ||df         ¦  «        }}t          j        || j        dz  z
  || j        z
  g|| j        dz  z   || j        z
  g||ggt          j        ¦  «        }	t          j        ||	g|                     ¦   «         ¦  «         | j        rRt          | j        |||€| j	        n|¬¦  «        }
t          j        ||	gd|
                     ¦   «         | j        ¬¦  «         �Œ$|S )	a-  
        Annotates the given scene with triangles based on the provided detections.

        Args:
            scene: The image where triangles will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> triangle_annotator = sv.TriangleAnnotator()
            >>> annotated_frame = triangle_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![triangle-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/triangle-annotator-example.png)
        r7  Nr˜   r   ru   r=   Tr!  )rY   rE   rž   r9  r2  rŸ   rx   r   rW   re   r‡   r°   r  ru  rÕ  r@   ÚfillPolyr¢   r3  r4  rÜ  )ro   r”   r•   r–   r:  r™   rW   Útip_xÚtip_yÚverticesr4  s              rT   r§   zTriangleAnnotator.annotateˆ
  s¯  € õT ˜%¥¤Ñ,Ô,ð 	ØˆLØ×/Ò/°t´}Ð/ÑEÔEˆÝ"¥3 z¡?¤?Ñ3Ô3ð #	ñ #	ˆMÝ!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ˜r -°Ð"2Ô3Ñ4Ô4µc¸"¸]ÈAÐ=MÔ:NÑ6OÔ6O�5ˆEÝ”xà˜TœY¨!™^Ñ+¨U°T´[Ñ-@ÐAØ˜TœY¨!™^Ñ+¨U°T´[Ñ-@ÐAØ˜E�Nðõ
 ”ñô ˆHõ ŒL˜  
¨E¯LªL©N¬NÑ;Ô;Ð;ØÔ%ð Ý -ØÔ,Ø)Ø"/à*Ð2ð "&Ô!2Ð!2à,ð!ñ !ô !�õ ”ØØ�JØØ!×(Ò(Ñ*Ô*Ø"Ô4ðñ ô ð ùð ˆrV   r¨   )r   r€   r�   r‚   r)   rƒ   r.   r¶  r   r„   r(   r<  rZ   r‡   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   r  r  b
  s)  € € € € € ðð ð -9Ô,@ØØØ%Ô0Ø$/Ô$5Ø!"Ø49´KðYð Yà�|Ñ# cÑ)ðYð ðYð ð	Yð
 ðYð "ðYð ðYð ˜|Ñ+¨cÑ1ðYð Yð Yð Yð@ 'ð
 <@ð	Pð PàðPð ðPð !œ[¨¬Ô1°DÑ8ð	Pð
 
ðPð Pð Pñ 'Ô&ðPð Pð PrV   r  c            
       ó¦   — e Zd ZdZej        dej        dfdeez  e	z  de
dedefd„Ze	 dd
ededej        ej                 d	z  defd„¦   «         Zd	S )ÚRoundBoxAnnotatorzh
    A class for drawing bounding boxes with round edges on an image
    using provided detections.
    r=   g333333ã?rW   rŽ   re   Ú	roundnessc                 ó”   — t          |¦  «        | _        || _        || _        d|cxk     rdk    sn t	          d¦  «        ‚|| _        dS )a+  
        Args:
            color: The color or color palette to use for
                annotating detections.
            thickness: Thickness of the bounding box lines.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            roundness: Percent of roundness for edges of bounding box.
                Value must be float 0 < roundness <= 1.0
                By default roundness percent is calculated based on smaller side
                length (width or height).
        r   ç      ð?z2roundness attribute must be float between (0, 1.0]N)r`   rW   rŽ   re   rM   r  )ro   rW   rŽ   re   r  s        rT   rp   zRoundBoxAnnotator.__init__â
  s\   € õ& ,BÀ%Ñ+HÔ+HˆŒ
Ø'ˆŒØ)5ˆÔØ�9Ð#Ð#Ò#Ð# Ò#Ð#Ð#Ð#ÝÐQÑRÔRÐRØ )ˆŒˆˆrV   Nr”   r•   r–   r9   c                 ó¬  — t          |t          j        ¦  «        s|S t          t	          |¦  «        ¦  «        D �]™}|j        |                              t          ¦  «        \  }}}}t          | j	        |||€| j
        n|¬¦  «        }	t          ||z
  ¦  «        t          ||z
  ¦  «        k     rt          ||z
  dz  | j        z  ¦  «        nt          ||z
  dz  | j        z  ¦  «        }
||
z   ||
z   f||
z
  ||
z   f||
z
  ||
z
  f||
z   ||
z
  fg}||
z   |f||
z
  |ff|||
z   f|||
z
  ff||
z   |f||
z
  |ff|||
z   f|||
z
  ffg}d}d}t          ||||¦  «        D ]x\  }}}}t          j        |||
|
fd|||	                     ¦   «         | j        ¬¦  «         t          j        ||d         |d         |	                     ¦   «         | j        ¬	¦  «         Œy�Œ›|S )
ae  
        Annotates the given scene with bounding boxes with rounded edges
        based on the provided detections.

        Args:
            scene: The image where rounded bounding boxes will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> round_box_annotator = sv.RoundBoxAnnotator()
            >>> annotated_frame = round_box_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![round-box-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/round-box-annotator-example-purple.png)
        Nr˜   r=   )é´   é  r   éZ   )r  ih  r  r  r   )r›   r  r  r  r  r  rW   rŽ   ru   rš   )rY   rE   rž   rŸ   rx   r    rL   r‡   r   rW   re   Úabsr  rQ  r@   r  r¢   rŽ   r"  )ro   r”   r•   r–   r™   r£   r¤   r¥   r¦   rW   r-  Úcircle_coordinatesÚline_coordinatesÚstart_anglesÚ
end_anglesrN  r"  r  r  s                      rT   r§   zRoundBoxAnnotator.annotateü
  su  € õV ˜%¥¤Ñ,Ô,ð 	ØˆLÝ"¥3 z¡?¤?Ñ3Ô3ð 6	ñ 6	ˆMØ'œ_¨]Ô;×BÒBÅ3ÑGÔG‰NˆB��B˜Ý!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ �r˜B‘w‘<”<¥# b¨2¡g¡,¤,Ò.Ð.õ �R˜"‘W ‘N T¤^Ñ3Ñ4Ô4Ð4å˜"˜r™' a™¨$¬.Ñ8Ñ9Ô9ð ð �v‘+  f¡Ð.Ø�v‘+  f¡Ð.Ø�v‘+  f¡Ð.Ø�v‘+  f¡Ð.ð	"Ðð �v‘+˜rÐ" R¨&¡[°"Ð$5Ð6Ø�b˜6‘kÐ" R¨¨f©Ð$5Ð6Ø�v‘+˜rÐ" R¨&¡[°"Ð$5Ð6Ø�b˜6‘kÐ" R¨¨f©Ð$5Ð6ð	 Ðð -ˆLØ,ˆJåDGØ"Ð$4°lÀJñEô Eð ð Ñ@Ð" D¨+°yõ ”ØØ-Ø  &Ð)ØØ*Ø&ØŸ,š,™.œ.Ø"œnð	ñ 	ô 	ð 	õ ”ØØ˜QœØ˜QœØŸ,š,™.œ.Ø"œnðñ ô ð ð ñð, ˆrV   r¨   )r   r€   r�   r‚   r)   rƒ   r   r„   r(   rZ   r‡   ré   rp   r0   r'   r    rG   rH   rE   rª   r§   r‹   rV   rT   r  r  Ü
  sæ   € € € € € ðð ð -9Ô,@ØØ$/Ô$5Øð*ð *à�|Ñ# cÑ)ð*ð ð*ð "ð	*ð
 ð*ð *ð *ð *ð4 'ð
 <@ð	dð dàðdð ðdð !œ[¨¬Ô1°DÑ8ð	dð
 
ðdð dð dñ 'Ô&ðdð dð drV   r  c                   óf  — e Zd ZdZddej        ej        ej	        e
j        dfdededeez  ez  deez  d	ed
e
dedz  fd„Ze	 	 ddededej        ej                 dz  dej        ej                 dz  def
d„¦   «         Zedeeef         deeef         d	edeeeef         eeef         f         fd„¦   «         Zedej        ej                 ee         z  dz  deddfd„¦   «         Ze eej        dd¬¦  «        dej        ej                 ee         z  dz  deddfd„¦   «         ¦   «         Z dS )ÚPercentageBarAnnotatorzT
    A class for drawing percentage bars on an image using provided detections.
    é   éP   Nru  r  rW   Úborder_colorr2  re   Úborder_thicknessc                 óô   — || _         || _        t          |¦  «        | _        t	          t
          t          |¦  «        ¦  «        | _        || _        || _        |�|nt          d| j         z  ¦  «        | _
        dS )a5  
        Args:
            height: The height in pixels of the percentage bar.
            width: The width in pixels of the percentage bar.
            color: The color or color palette to use for
                annotating detections.
            border_color: The color of the border lines.
            position: The anchor position of drawing the percentage bar.
            color_lookup: Strategy for mapping colors to annotations.
                Options are `INDEX`, `CLASS`, `TRACK`.
            border_thickness: The thickness of the border lines.
        Ng333333Ã?)ru  r  r`   rW   r   r(   r&  r2  re   r‡   r'  )ro   ru  r  rW   r&  r2  re   r'  s           rT   rp   zPercentageBarAnnotator.__init__i  s{   € ð, "ˆŒØˆŒ
Ý+AÀ%Ñ+HÔ+HˆŒ
Ý ¥Õ(>¸|Ñ(LÔ(LÑMÔMˆÔØ"*ˆŒØ)5ˆÔð  Ð+ð Ðå�T˜DœKÑ'Ñ(Ô(ð 	ÔÐÐrV   r”   r•   r–   Úcustom_valuesr9   c           
      ó’  — t          |t          j        ¦  «        s|S |                      ||¬¦  «         |                     | j        ¬¦  «        }t          t          |¦  «        ¦  «        D �]Z}||         }|                      t          |d         ¦  «        t          |d         ¦  «        f| j
        | j        f| j        ¬¦  «        }|d         d         |d         d         z
  }	|�	||         }
n|j        €J ‚|j        |         }
t          | j        |||€| j        n|¬¦  «        }t!          j        ||d         |d         d         t          |	|
z  ¦  «        z   |d         d         f|                     ¦   «         d¬	¦  «         t!          j        ||d         |d         | j                             ¦   «         | j        ¬	¦  «         �Œ\|S )
aR  
        Annotates the given scene with percentage bars based on the provided
        detections. The percentage bars visually represent the confidence or custom
        values associated with each detection.

        Args:
            scene: The image where percentage bars will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.
            custom_values: Custom values array to use instead
                of the default detection confidences. This array should have the
                same length as the number of detections and contain a value between
                0 and 1 (inclusive) for each detection, representing the percentage
                to be displayed.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     confidence=np.array([0.9]),
            ...     class_id=np.array([0])
            ... )
            >>> percentage_bar_annotator = sv.PercentageBarAnnotator()
            >>> annotated_frame = percentage_bar_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![percentage-bar-example](https://media.roboflow.com/
        supervision-annotator-examples/percentage-bar-annotator-example-purple.png)
        ©r)  r•   r7  r   ru   )Ú	anchor_xyÚ	border_whr2  Nr˜   rô   rš   )rY   rE   rž   Ú_validate_custom_valuesr9  r2  rŸ   rx   Úcalculate_border_coordinatesr‡   r  ru  Ú
confidencer   rW   re   r@   r¡   r¢   r&  r'  )ro   r”   r•   r–   r)  Úanchorsr™   r8  Úborder_coordinatesÚborder_widthÚvaluerW   s               rT   r§   zPercentageBarAnnotator.annotateŒ  sú  € õf ˜%¥¤Ñ,Ô,ð 	ØˆLØ×$Ò$°=ÈZÐ$ÑXÔXÐXà×4Ò4¸D¼MÐ4ÑJÔJˆÝ"¥3 z¡?¤?Ñ3Ô3ð '	ñ '	ˆMØ˜]Ô+ˆFØ!%×!BÒ!BÝ˜v aœy™>œ>­3¨v°a¬y©>¬>Ð:Øœ: t¤{Ð3Øœð "Cñ "ô "Ðð
 .¨aÔ0°Ô3Ð6HÈÔ6KÈAÔ6NÑNˆLàÐ(Ø% mÔ4��à!Ô,Ð8Ð8Ð8Ø"Ô-¨mÔ<�å!Ø”jØ%Ø+à&Ð.ð "Ô.Ð.à(ðñ ô ˆEõ ŒMØØ& qÔ)à& qÔ)¨!Ô,­s°<À%Ñ3GÑ/HÔ/HÑHØ& qÔ)¨!Ô,ðð —l’l‘n”nØð	ñ 	ô 	ð 	õ ŒMØØ& qÔ)Ø& qÔ)ØÔ'×.Ò.Ñ0Ô0ØÔ/ðñ ô ð ñ ð ˆrV   r,  r-  c                 óâ  — | \  }}|\  }}|t           j        k    r||z
  ||z
  f||ffS |t           j        k    r||dz  z
  |f||dz  z   ||z
  ffS |t           j        k    r||f||z   ||z
  ffS |t           j        k    r||z
  ||dz  z
  f|||dz  z   ffS |t           j        k    s|t           j        k    r ||dz  z
  ||dz  z
  f||dz  z   ||dz  z   ffS |t           j        k    r|||dz  z
  f||z   ||dz  z   ffS |t           j        k    r||z
  |f|||z   ffS |t           j	        k    r||dz  z
  |f||dz  z   ||z   ffS |t           j
        k    r||f||z   ||z   ffS t          d|› �¦  «        ‚)zBCompute the border corner coordinates for a given anchor position.r=   úUnsupported position: ©r.   r†   r¶  Ú	TOP_RIGHTÚCENTER_LEFTr;  ÚCENTER_OF_MASSÚCENTER_RIGHTÚBOTTOM_LEFTrú  ÚBOTTOM_RIGHTrM   )r,  r-  r2  ÚcxÚcyr  ru  s          rT   r/  z3PercentageBarAnnotator.calculate_border_coordinatesî  s  € ð
 ‰ˆˆBØ!‰ˆˆvà•xÔ(Ò(Ð(Ø˜‘J  V¡Ð,¨r°2¨hÐ6Ð6Ø�Ô,Ò,Ð,Ø˜ !™‘O RÐ(¨2°¸±
©?¸BÀ¹KÐ*HÐHÐHØ�Ô+Ò+Ð+Ø˜�8˜b 5™j¨"¨v©+Ð6Ð6Ð6Ø�Ô-Ò-Ð-Ø˜‘J  V¨q¡[Ñ 0Ð1°B¸¸VÀq¹[Ñ8HÐ3IÐIÐIØ�œÒ(Ð(¨H½Ô8OÒ,OÐ,Oà�e˜q‘j‘ " v°¡{Ñ"2Ð3Ø�e˜q‘j‘ " v°¡{Ñ"2Ð3ðð ð �Ô.Ò.Ð.Ø˜˜V q™[Ñ(Ð)¨B°©J¸¸VÀq¹[Ñ8HÐ+IÐIÐIØ�Ô-Ò-Ð-Ø˜‘J Ð# b¨"¨v©+Ð%6Ð6Ð6Ø�Ô/Ò/Ð/Ø˜ !™‘O RÐ(¨2°¸±
©?¸BÀ¹KÐ*HÐHÐHØ�Ô.Ò.Ð.Ø˜�8˜b 5™j¨"¨v©+Ð6Ð6Ð6ÝÐ<°(Ð<Ð<Ñ=Ô=Ð=rV   c                 óH  — | €|j         €t          d¦  «        ‚d S t          | t          j        t
          f¦  «        st          d¦  «        ‚t          | ¦  «        t          |¦  «        k    rt          d¦  «        ‚t          d„ | D ¦   «         ¦  «        st          d¦  «        ‚d S )Nz³The provided detections do not contain confidence values. Please provide `custom_values` or ensure that the detections contain confidence values (e.g. by using a different model).z?custom_values must be either a numpy array or a list of floats.z@The length of custom_values must match the number of detections.c              3   ó6   K  — | ]}d |cxk    odk    nc V — ŒdS )r   ru   Nr‹   )Ú.0r4  s     rT   ú	<genexpr>zAPercentageBarAnnotator._validate_custom_values.<locals>.<genexpr>%  s6   è è € ÐBÐB¨5�q˜E��’� Q’���ÐBÐBÐBÐBÐBÐBrV   z4All values in custom_values must be between 0 and 1.)	r0  rM   rY   rE   rž   rŠ   r¢  rx   Úallr+  s     rT   r.  z.PercentageBarAnnotator._validate_custom_values  sÐ   € ð
 Ð ØÔ$Ð,Ý ðSñô ð ð -Ð,õ ˜m­b¬j½$Ð-?Ñ@Ô@ð ÝØUñô ð õ �=Ñ!Ô!¥S¨¡_¤_Ò4Ð4Ý ØVñô ð õ ÐBÐB°MÐBÑBÔBÑBÔBð YÝ Ð!WÑXÔXÐXðYð YrV   z0.29.0z0.32.0)ÚtargetÚdeprecated_inÚ	remove_inc                 ó&   — t          | |¦  «         d S r¨   )r
   r+  s     rT   Úvalidate_custom_valuesz-PercentageBarAnnotator.validate_custom_values(  s   € õ 	ˆ]˜JÑ'Ô'Ð'Ð'Ð'rV   ry  )!r   r€   r�   r‚   r)   rƒ   r(   r<  r.   r¶  r   r„   r‡   rZ   rp   r0   r'   r    rG   rH   rE   rª   rÚ  r§   rz  rˆ   r/  rŠ   ré   r.  r	   Ú__func__rI  r‹   rV   rT   r#  r#  d  ss  € € € € € ðð ð ØØ,8Ô,@Ø$)¤KØ%Ô0Ø$/Ô$5Ø'+ð!
ð !
àð!
ð ð!
ð �|Ñ# cÑ)ð	!
ð
 ˜c‘kð!
ð ð!
ð "ð!
ð  ™*ð!
ð !
ð !
ð !
ðF 'ð
 <@Ø8<ð_ð _àð_ð ð_ð !œ[¨¬Ô1°DÑ8ð	_ð
 ”{ 2¤:Ô.°Ñ5ð_ð 
ð_ð _ð _ñ 'Ô&ð_ðB ð>Ø˜˜c˜”?ð>Ø/4°S¸#°X¬ð>ØJRð>à	ˆu�S˜#�XŒ  c¨3 h¤Ð/Ô	0ð>ð >ð >ñ „\ð>ð< ðYØ”{ 2¤:Ô.°°e´Ñ<¸tÑCðYàðYð 
ðYð Yð Yñ „\ðYð4 Ø€ZØ&Ô/ØØðñ ô ð
(Ø”{ 2¤:Ô.°°e´Ñ<¸tÑCð(àð(ð 
ð(ð (ð (ñô ñ „\ð(ð (ð (rV   r#  c                   ó.  — e Zd ZdZej        dej        dej	        fdede
deez  ez  dedef
d	„Ze	 ddededej        ej                 d
z  defd„¦   «         Zedeeef         deeef         dedeeeef         eeef         f         fd„¦   «         Zd
S )ÚCropAnnotatorzI
    A class for drawing scaled up crops of detections on the scene.
    g       @r=   r2  Úscale_factorr&  r'  Úborder_color_lookupc                 óf   — || _         || _        t          |¦  «        | _        || _        || _        dS )aÍ  
        Args:
            position: The anchor position for placing the cropped and scaled
                part of the detection in the scene.
            scale_factor: The factor by which to scale the cropped image part. A
                factor of 2, for example, would double the size of the cropped area,
                allowing for a closer view of the detection.
            border_color: The color or color palette to
                use for annotating border around the cropped area.
            border_thickness: The thickness of the border around the cropped area.
            border_color_lookup: Strategy for mapping colors to
                annotations. Options are `INDEX`, `CLASS`, `TRACK`.
        N)r2  rM  r`   r&  r'  rN  )ro   r2  rM  r&  r'  rN  s         rT   rp   zCropAnnotator.__init__:  s9   € ð* #+ˆŒØ#/ˆÔÝ2HÈÑ2VÔ2VˆÔØ%5ˆÔØ0CˆÔ Ð Ð rV   Nr”   r•   r–   r9   c                 óx  — t          |t          j        ¦  «        s|S |j        dd…         \  }}t	          |j        ||f¬¦  «                             t          j        ¦  «        }|                     | j	        ¬¦  «                             t          j        ¦  «        }| 
                    ¦   «         }t          t          ||¦  «        ¦  «        D ]ì\  }	\  }
}|
\  }}}}||k    s||k    rŒt          ||
¬¦  «        }t          || j        ¬¦  «        }|j        d         |j        d         f}|                      ||| j	        ¬	¦  «        \  \  }}\  }}t#          ||||f¬
¦  «        }t%          | j        ||	|€| j        n|¬¦  «        }t+          j        |||f||f|                     ¦   «         | j        ¬¦  «         Œí|S )aÏ  
        Annotates the provided scene with scaled and cropped parts of the image based
        on the provided detections. Each detection is cropped from the original scene
        and scaled according to the annotator's scale factor before being placed back
        onto the scene at the specified position.


        Args:
            scene: The image where cropped detection will be placed.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.
            custom_color_lookup: Custom color lookup array.
                Allows to override the default color mapping strategy.

        Returns:
            The annotated image.

        Note:
            Detections whose bounding boxes extend partially outside `scene` are
            clipped to scene bounds before cropping. Detections fully outside the
            scene collapse to zero area after clipping and are skipped without
            raising an error.

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> crop_annotator = sv.CropAnnotator()
            >>> annotated_frame = crop_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![crop-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/crop-annotator-example.png)
        Nr=   r¼  r7  )r>   r    )r>   rM  ru   r   )r8  Úcrop_whr2  )r>   Úoverlayr8  r˜   rš   )rY   rE   rž   rÁ   r!   r    rL   rÕ  r9  r2  rw   rj  rQ  r3   r5   rM  Úcalculate_crop_coordinatesr2   r   r&  rN  r@   r¡   r¢   r'  )ro   r”   r•   r–   r½  r¾  r¿  r1  Úsource_scenerm  r    r8  rÐ   rÑ   Úcrop_x2Úcrop_y2r·   Úresized_croprQ  r£   r¤   r¥   r¦   rW   s                           rT   r§   zCropAnnotator.annotateU  s  € õf ˜%¥¤Ñ,Ô,ð 	ØˆLØ$)¤K°°°¤OÑ!ˆ�kÝ.8Ø”Ø&¨Ð5ð/
ñ /
ô /
÷ Š&•”Ñ
Ô
ð 	ð *4×)KÒ)KØ”=ð *Lñ *
ô *
ç
Š&•”Ñ
Ô
ð 	ð
 —z’z‘|”|ˆå#,­S°¸wÑ-GÔ-GÑ#HÔ#Hð 	ð 	ÑˆC‘�$˜Ø15Ñ.ˆG�W˜g wØ˜'Ò!Ð! W°Ò%7Ð%7ØÝ L°tÐ<Ñ<Ô<ˆDÝ&¨TÀÔ@QÐRÑRÔRˆLØ"Ô(¨Ô+¨\Ô-?ÀÔ-BÐBˆGØ!%×!@Ò!@Ø w¸¼ð "Añ "ô "Ñ‰HˆR�‘h�r˜2õ #¨¸ÈbÐRTÈXÐVÑVÔVˆEÝ!ØÔ'Ø%Ø!à&Ð.ð "Ô5Ð5à(ðñ ô ˆEõ ŒMØØ˜�HØ˜�HØ—l’l‘n”nØÔ/ðñ ô ð ð ð ˆrV   r8  rQ  c                 óâ  — | \  }}|\  }}|t           j        k    r||z
  ||z
  f||ffS |t           j        k    r||dz  z
  ||z
  f||dz  z   |ffS |t           j        k    r|||z
  f||z   |ffS |t           j        k    r||z
  ||dz  z
  f|||dz  z   ffS |t           j        k    s|t           j        k    r ||dz  z
  ||dz  z
  f||dz  z   ||dz  z   ffS |t           j        k    r|||dz  z
  f||z   ||dz  z   ffS |t           j        k    r||z
  |f|||z   ffS |t           j	        k    r||dz  z
  |f||dz  z   ||z   ffS |t           j
        k    r||f||z   ||z   ffS t          d|› �¦  «        ‚)z9Compute the crop coordinates for a given anchor position.r=   r6  r7  )r8  rQ  r2  Úanchor_xÚanchor_yr  ru  s          rT   rS  z(CropAnnotator.calculate_crop_coordinates³  s@  € ð
 $Ñˆ�(Ø‰ˆˆvà•xÔ(Ò(Ð(Ø˜uÑ$ h°Ñ&7Ð8¸8ÀXÐ:NÐNÐNØ�Ô,Ò,Ð,à˜E Q™JÑ&¨°6Ñ(9Ð:Ø˜E Q™JÑ&¨Ð1ðð ð �Ô+Ò+Ð+Ø˜h¨Ñ/Ð0°8¸eÑ3CÀXÐ2NÐNÐNØ�Ô-Ò-Ð-à˜EÑ! 8¨f¸©kÑ#9Ð:Ø˜8 f°¡kÑ1Ð2ðð ð �œÒ(Ð(¨H½Ô8OÒ,OÐ,Oà˜E Q™JÑ&¨°6¸Q±;Ñ(>Ð?Ø˜E Q™JÑ&¨°6¸Q±;Ñ(>Ð?ðð ð �Ô.Ò.Ð.à˜8 f°¡kÑ1Ð2Ø˜EÑ! 8¨f¸©kÑ#9Ð:ðð ð �Ô-Ò-Ð-Ø˜uÑ$ hÐ/°(¸HÀvÑ<MÐ1NÐNÐNØ�Ô/Ò/Ð/à˜E Q™JÑ&¨Ð1Ø˜E Q™JÑ&¨°6Ñ(9Ð:ðð ð �Ô.Ò.Ð.Ø˜hÐ'¨(°UÑ*:¸HÀvÑ<MÐ)NÐNÐNÝÐ<°(Ð<Ð<Ñ=Ô=Ð=rV   r¨   )r   r€   r�   r‚   r.   r¶  r)   rƒ   r   r„   ré   r(   rZ   r‡   rp   r0   r'   r    rG   rH   rE   rª   r§   rz  rˆ   rS  r‹   rV   rT   rL  rL  5  si  € € € € € ðð ð &Ô0Ø!Ø3?Ô3GØ !Ø+6Ô+<ðDð DàðDð ðDð ˜lÑ*¨SÑ0ð	Dð
 ðDð )ðDð Dð Dð Dð6 'ð
 <@ð	[ð [àð[ð ð[ð !œ[¨¬Ô1°DÑ8ð	[ð
 
ð[ð [ð [ñ 'Ô&ð[ðz ð(>Ø�c˜3�h”ð(>Ø*/°°S°¬/ð(>ØEMð(>à	ˆu�S˜#�XŒ  c¨3 h¤Ð/Ô	0ð(>ð (>ð (>ñ „\ð(>ð (>ð (>rV   rL  c                   ó\   — e Zd ZdZej        ddfdededefd„Ze	de
d	ed
e
fd„¦   «         ZdS )ÚBackgroundOverlayAnnotatora®  
    A class for drawing a colored overlay on the background of an image outside
    the region of detections.

    If masks are provided, the background is colored outside the masks.
    If masks are not provided, the background is colored outside the bounding boxes.

    You can use the `force_box` parameter to force the annotator to use bounding boxes.

    !!! warning

        This annotator uses `sv.Detections.mask`.
    rÛ   FrW   rÜ   Ú	force_boxc                 ó0   — || _         || _        || _        dS )a9  
        Args:
            color: The color to use for annotating detections.
            opacity: Opacity of the overlay mask. Must be between `0` and `1`.
            force_box: If `True`, forces the annotator to use bounding boxes when
                masks are provided in the supplied sv.Detections.
        N)rW   rÜ   r]  )ro   rW   rÜ   r]  s       rT   rp   z#BackgroundOverlayAnnotator.__init__î  s   € ð "ˆŒ
ØˆŒØ"ˆŒˆˆrV   r”   r•   r9   c                 ót  — t          |t          j        ¦  «        s|S t          j        || j                             ¦   «         t          j        ¬¦  «        }t          j        |d| j	        z
  || j	        d|¬¦  «         |j
        �| j        ri|j        dd…         \  }}t          |j        ||f¬¦  «                             t          j        ¦  «        }|D ]\  }}}	}
|||
…||	…f         |||
…||	…f<   Œn0|j
        D ](}t          j        |t$          ¬¦  «        }||         ||<   Œ)t          j        ||¦  «         |S )aÙ  
        Applies a colored overlay to the scene outside of the detected regions.

        Args:
            scene: The image where masks will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections: Object detections to annotate.

        Returns:
            The annotated image, matching the type of `scene` (`numpy.ndarray`
                or `PIL.Image.Image`)

        Examples:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections = sv.Detections(
            ...     xyxy=np.array([[20, 20, 80, 80]]),
            ...     class_id=np.array([0])
            ... )
            >>> background_overlay_annotator = sv.BackgroundOverlayAnnotator()
            >>> annotated_frame = background_overlay_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections=detections
            ... )

            ```

        ![background-overlay-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/background-color-annotator-example-purple.png)
        rv   ru   r   )rö   Nr=   r¼  )rY   rE   rž   Ú	full_likerW   r¢   rF   r@   rá   rÜ   rµ   r]  rÁ   r!   r    rL   rÕ  rz   r‰   r  )ro   r”   r•   ræ   r½  r¾  r¿  r£   r¤   r¥   r¦   rµ   Ú	mask_bools                rT   r§   z#BackgroundOverlayAnnotator.annotateÿ  sh  € õF ˜%¥¤Ñ,Ô,ð 	ØˆLÝ”| E¨4¬:×+<Ò+<Ñ+>Ô+>ÅbÄhÐOÑOÔOˆåŒØ�1�t”|Ñ# \°4´<ÀÈð	
ñ 	
ô 	
ð 	
ð Œ?Ð" d¤nÐ"Ø(-¬°B°Q°B¬Ñ%ˆL˜+Ý2<Ø”_Ø*¨LÐ9ð3ñ 3ô 3÷ Šf•R”XÑÔð ð #/ð Að A‘��B˜˜BØ-2°2°b°5¸"¸R¸%°<Ô-@�˜R ˜U B r E˜\Ñ*Ð*ðAð #œð ;ð ;�ÝœJ tµ4Ð8Ñ8Ô8�	Ø*/°	Ô*:�˜YÑ'Ð'å
Œ	�%˜Ñ&Ô&Ð&ØˆrV   N)r   r€   r�   r‚   r(   r<  ré   r‰   rp   r0   r'   r    r§   r‹   rV   rT   r\  r\  ß  s–   € € € € € ðð ð  ”{ØØð	#ð #àð#ð ð#ð ð	#ð #ð #ð #ð" 'ð8˜ið 8°Zð 8ÀIð 8ð 8ð 8ñ 'Ô&ð8ð 8ð 8rV   r\  c                   óV  — e Zd ZU dZdZee         ed<   ej	        ej
        ej        fddddddœded	ed
edededededefd„Zededededefd„¦   «         Zedededefd„¦   «         Zedededefd„¦   «         Zedej        ej                 dedej        ej                 fd„¦   «         Zedej        ej                 dedej        ej                 fd„¦   «         Zedej        ej                 dedej        ej                 fd„¦   «         Zdej        ej                 ddfd„ZdS )ÚComparisonAnnotatoraH  
    Highlights the differences between two sets of detections.
    Useful for comparing results from two different models, or the difference
    between a ground truth and a prediction.

    If present, uses the oriented bounding box data.
    Otherwise, if present, uses a mask.
    Otherwise, uses the bounding box data.
    Frè   g      è?r¯  r  )rÜ   Úlabel_1Úlabel_2Úlabel_overlapÚlabel_scaleÚcolor_1Úcolor_2Úcolor_overlaprÜ   rd  re  rf  rg  c                ó®   — || _         || _        || _        || _        || _        || _        || _        || _        t          | j        dz   ¦  «        | _	        dS )a{  
        Args:
            color_1: Color of areas only present in the first set of
                detections.
            color_2: Color of areas only present in the second set of
                detections.
            color_overlap: Color of areas present in both sets of detections.
            opacity: Opacity of the overlay mask. Must be between `0` and `1`.
            label_1: Label for the first set of detections.
            label_2: Label for the second set of detections.
            label_overlap: Label for areas present in both sets of detections.
            label_scale: Controls how large the labels are.
        g333333ó?N)
rh  ri  rj  rÜ   rd  re  rf  rg  r‡   r@  )	ro   rh  ri  rj  rÜ   rd  re  rf  rg  s	            rT   rp   zComparisonAnnotator.__init__I  s]   € ð4 ˆŒØˆŒØ*ˆÔàˆŒØˆŒØˆŒØ*ˆÔØ&ˆÔÝ! $Ô"2°SÑ"8Ñ9Ô9ˆÔÐÐrV   r”   Údetections_1Údetections_2r9   c                 ó  — t          |t          j        ¦  «        s|S |                     ¦   «         r|                     ¦   «         r|S |                      ||¦  «        }|                      ||¦  «        }|r-|                      ||¦  «        }|                      ||¦  «        }n[|r-|                      ||¦  «        }|                      ||¦  «        }n,|                      ||¦  «        }|                      ||¦  «        }||z  }|| z  }|| z  }t          j	        |t          j
        ¬¦  «        }	| j                             ¦   «         |	|<   | j                             ¦   «         |	|<   | j                             ¦   «         |	|<   d| j        z
  ||         z  | j        |	|         z  z   ||<   d| j        z
  ||         z  | j        |	|         z  z   ||<   d| j        z
  ||         z  | j        |	|         z  z   ||<   |                      |¦  «         |S )a›  
        Highlights the differences between two sets of detections.

        Args:
            scene: The image where detections will be drawn.
                `ImageType` is a flexible type, accepting either `numpy.ndarray`
                or `PIL.Image.Image`.
            detections_1: The first set of detections or predictions.
            detections_2: The second set of detections to compare or
                ground truth.

        Returns:
            The annotated image.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((100, 100, 3), dtype=np.uint8)
            >>> detections_1 = sv.Detections(
            ...     xyxy=np.array([[10, 10, 50, 50]]),
            ...     class_id=np.array([0]),
            ... )
            >>> detections_2 = sv.Detections(
            ...     xyxy=np.array([[40, 40, 90, 90]]),
            ...     class_id=np.array([0]),
            ... )
            >>> comparison_annotator = sv.ComparisonAnnotator()
            >>> annotated_frame = comparison_annotator.annotate(
            ...     scene=image.copy(),
            ...     detections_1=detections_1,
            ...     detections_2=detections_2
            ... )

            ```

        ![comparison-annotator-example](https://media.roboflow.com/
        supervision-annotator-examples/comparison-annotator-example.png)
        rv   ru   )rY   rE   rž   Úis_emptyÚ_use_obbÚ	_use_maskÚ_mask_from_obbÚ_mask_from_maskÚ_mask_from_xyxyrþ   rF   rj  r¢   rh  ri  rÜ   rG  )
ro   r”   rl  rm  Úuse_obbÚuse_maskÚmask_1Úmask_2Úmask_overlapÚcolor_layers
             rT   r§   zComparisonAnnotator.annotaten  s;  € õV ˜%¥¤Ñ,Ô,ð 	ØˆLØ× Ò Ñ"Ô"ð 	 |×'<Ò'<Ñ'>Ô'>ð 	ØˆLà—-’- ¨lÑ;Ô;ˆØ—>’> ,°Ñ=Ô=ˆàð 
	?Ø×(Ò(¨°Ñ=Ô=ˆFØ×(Ò(¨°Ñ=Ô=ˆFˆFàð 	?Ø×)Ò)¨%°Ñ>Ô>ˆFØ×)Ò)¨%°Ñ>Ô>ˆFˆFð ×)Ò)¨%°Ñ>Ô>ˆFØ×)Ò)¨%°Ñ>Ô>ˆFà ‘ˆØ˜<˜-Ñ'ˆØ˜<˜-Ñ'ˆå”m Eµ´Ð:Ñ:Ô:ˆØ$(Ô$6×$=Ò$=Ñ$?Ô$?ˆ�LÑ!Ø"œl×1Ò1Ñ3Ô3ˆ�FÑØ"œl×1Ò1Ñ3Ô3ˆ�FÑà  4¤<Ñ/°5Øô4
ñ 
àŒL˜; |Ô4Ñ4ñ5ˆˆlÑð ˜Tœ\Ñ)¨U°6¬]Ñ:¸T¼\ÈKØôM
ñ >
ñ 
ˆˆf‰ð ˜Tœ\Ñ)¨U°6¬]Ñ:¸T¼\ÈKØôM
ñ >
ñ 
ˆˆf‰ð 	×Ò˜%Ñ Ô Ð àˆrV   c                 óî   — |                       ¦   «         r|                      ¦   «         rJ ‚t          | j        v }t          |j        v }|r|p+|o|                      ¦   «         p|                       ¦   «         o|S r¨   )ro  r   r¯   )rl  rm  Úis_obb_1Úis_obb_2s       rT   rp  zComparisonAnnotator._use_obbÄ  s„   € à×(Ò(Ñ*Ô*ÐI°,×2GÒ2GÑ2IÔ2IÐIÐIÐIÝ+¨|Ô/@Ð@ˆÝ+¨|Ô/@Ð@ˆàÐ"˜(ð 6ØÐ4˜\×2Ò2Ñ4Ô4ð6à×%Ò%Ñ'Ô'Ð4¨Hð	
rV   c                 óÚ   — |                       ¦   «         r|                      ¦   «         rJ ‚| j        d u}|j        d u}|r|p+|o|                      ¦   «         p|                       ¦   «         o|S r¨   )ro  rµ   )rl  rm  Ú	is_mask_1Ú	is_mask_2s       rT   rq  zComparisonAnnotator._use_maskÏ  s„   € à×(Ò(Ñ*Ô*ÐI°,×2GÒ2GÑ2IÔ2IÐIÐIÐIØ Ô%¨TÐ1ˆ	Ø Ô%¨TÐ1ˆ	àÐ$˜9ð 7ØÐ5˜l×3Ò3Ñ5Ô5ð7à×%Ò%Ñ'Ô'Ð5¨Ið	
rV   r•   c                 óX  — t          j        | j        d d…         t           j        ¬¦  «        }|                     ¦   «         r|S | j        d         | j        d         f}t          |j        ¦  «        }|D ]5}t          ||¬¦  «        }||                     t           j        ¦  «        z  }Œ6|S ©Nr=   rv   ru   r   )r?   )	rE   rÀ   rÁ   r¶   ro  r%   r    r$   rL   )r”   r•   rµ   r?   Úpolygonsrî   Úpolygon_masks          rT   rt  z#ComparisonAnnotator._mask_from_xyxyÚ  s¤   € õ Œx˜œ B Q Bœ­r¬xÐ8Ñ8Ô8ˆØ×ÒÑ Ô ð 	ØˆKàœ Aœ¨¬°A¬Ð6ˆÝ# J¤OÑ4Ô4ˆàð 	2ð 	2ˆGÝ*¨7À-ÐPÑPÔPˆLØ�L×'Ò'­¬Ñ1Ô1Ñ1ˆDˆDØˆrV   c                 óP  — t          j        | j        d d…         t           j        ¬¦  «        }|                     ¦   «         r|S | j        d         | j        d         f}|j        t                   D ]5}t          ||¬¦  «        }||                     t           j        ¦  «        z  }Œ6|S r‚  )	rE   rÀ   rÁ   r¶   ro  r¯   r   r$   rL   )r”   r•   rµ   r?   rî   r„  s         rT   rr  z"ComparisonAnnotator._mask_from_obbê  s�   € õ Œx˜œ B Q Bœ­r¬xÐ8Ñ8Ô8ˆØ×ÒÑ Ô ð 	ØˆKàœ Aœ¨¬°A¬Ð6ˆà!”Õ'?Ô@ð 	2ð 	2ˆGÝ*¨7À-ÐPÑPÔPˆLØ�L×'Ò'­¬Ñ1Ô1Ñ1ˆDˆDØˆrV   c                 óö   — t          j        | j        d d…         t           j        ¬¦  «        }|                     ¦   «         r|S |j        €J ‚|j        D ]$}||                     t           j        ¦  «        z  }Œ%|S )Nr=   rv   )rE   rÀ   rÁ   r¶   ro  rµ   rL   )r”   r•   rµ   Údetections_masks       rT   rs  z#ComparisonAnnotator._mask_from_maskù  s}   € õ Œx˜œ B Q Bœ­r¬xÐ8Ñ8Ô8ˆØ×ÒÑ Ô ð 	ØˆKØŒÐ*Ð*Ð*à)œð 	5ð 	5ˆOØ�O×*Ò*­2¬8Ñ4Ô4Ñ4ˆDˆDØˆrV   Nc           
      ó¢  — t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }t          d| j        z  ¦  «        }	| j        }
| j        | j        f| j        | j        f| j        | j        fg}|}|D ]á\  }}|sŒt          j	        |t          | j        | j        ¬¦  «        d         \  }}||z   |dz  z   }||dz  z   }||dz  z   }t          |t          ||||¬	¦  «        t          j        |¬
¦  «         t          |t          ||z   ||dz  z
  ||¬	¦  «        ||	¬
¦  «         t!          ||t#          ||z   |¬¦  «        |
| j        ¬¦  «         |||z   z  }ŒâdS )zÄ
        Draw the labels, explaining what each color represents, with automatically
        computed positions.

        Args:
            scene: The image where the labels will be drawn.
        é2   rú   rÐ  rc   rt   rI  r   r=   )r$  r%  r  ru  )r”   ÚrectrW   rj   )r$  r%  )rn   r?  r@  N)r‡   rg  rd  rh  re  ri  rf  rj  r@   rR  rS  r@  r+   r/   r(   r…   r,   r-   )ro   r”   ÚmarginÚgapÚy0ru  Úmarker_sizeÚpaddingÚtext_box_corner_radiusÚmarker_corner_radiusr?  Úlabel_color_pairsÚx0rJ  rW   r\  r_   r  Úcenter_xÚcenter_ys                       rT   rG  z ComparisonAnnotator._draw_labels  sP  € õ �R˜$Ô*Ñ*Ñ+Ô+ˆÝ�"�tÔ'Ñ'Ñ(Ô(ˆÝ��dÔ&Ñ&Ñ'Ô'ˆÝ�R˜$Ô*Ñ*Ñ+Ô+ˆå˜"˜tÔ/Ñ/Ñ0Ô0ˆÝ�b˜4Ô+Ñ+Ñ,Ô,ˆÝ!$ R¨$Ô*:Ñ%:Ñ!;Ô!;ÐÝ" 1 tÔ'7Ñ#7Ñ8Ô8ÐØÔ%ˆ
ð Œ\˜4œ<Ð(ØŒ\˜4œ<Ð(ØÔ Ô!3Ð4ð
Ðð ˆØ,ð *	ð *	‰KˆD�%Øð Øåœ/ØÝ!ØÔ*ØÔ-ð	ñ ô ð
 ô‰KˆV�Qð ˜[Ñ(¨7°Q©;Ñ6ˆEØ˜E Q™J‘ˆHØ˜F a™KÑ'ˆHå"ØÝ˜B "¨E¸&ÐAÑAÔAÝ”kØ4ð	ñ ô ð õ #ØÝØ˜7‘lØ ¨q¡Ñ0Ø%Ø&ð	ñ ô ð Ø2ð
ñ 
ô 
ð 
õ ØØÝ! H¨{Ñ$:¸hÐGÑGÔGØ%Ø#Ô2ðñ ô ð ð �%˜#‘+ÑˆBˆBðU*	ð *	rV   )r   r€   r�   r‚   rè   r   r‰   Ú__annotations__r(   ÚREDÚGREENÚBLUEré   rZ   rp   r0   r'   r    r§   rz  rp  rq  rG   rH   rE   rF   r¶   rt  rr  rs  rG  r‹   rV   rT   rc  rc  ;  s�  € € € € € € ðð ð %*€M�8˜D”>Ð)Ð)Ñ)ð œØœØ$œzð	#:ð ØØØØ ð#:ð #:ð #:àð#:ð ð#:ð ð	#:ð ð#:ð ð#:ð ð#:ð ð#:ð ð#:ð #:ð #:ð #:ðJ 'ðSØðSØ.8ðSØHRðSà	ðSð Sð Sñ 'Ô&ðSðj ð
˜zð 
¸ð 
Èð 
ð 
ð 
ñ „\ð
ð ð
 
ð 
¸*ð 
Èð 
ð 
ð 
ñ „\ð
ð ðØŒ{˜2œ8Ô$ðØ2<ðà	Œ�R”XÔ	ðð ð ñ „\ðð ðØŒ{˜2œ8Ô$ðØ2<ðà	Œ�R”XÔ	ðð ð ñ „\ðð ð
ØŒ{˜2œ8Ô$ð
Ø2<ð
à	Œ�R”XÔ	ð
ð 
ð 
ñ „\ð
ðD #¤+¨b¬hÔ"7ð D¸Dð Dð Dð Dð Dð Dð DrV   rc  )Frd   )yÚcollections.abcr   Ú	functoolsr   Úmathr   Útypingr   r   r   ÚnumpyrE   Únumpy.typingrG   Ú	deprecater	   r
   ÚPILr   r   r   Úscipy.interpolater   r   Úsupervisionr   r@   Úsupervision.annotators.baser   Úsupervision.annotators.utilsr   r   r   r   r   r   r   r   r   r   r   r   Úsupervision.configr   Ú"supervision.detection.compact_maskr   Úsupervision.detection.corer    Ú!supervision.detection.utils.boxesr!   r"   Ú&supervision.detection.utils.convertersr#   r$   r%   Ú!supervision.detection.utils.masksr&   Úsupervision.draw.baser'   Úsupervision.draw.colorr(   r)   Úsupervision.draw.utilsr*   r+   r,   Úsupervision.geometry.corer-   r.   r/   Úsupervision.utils.conversionr0   r1   Úsupervision.utils.imager2   r3   r4   r5   Úsupervision.utils.loggerr6   r   r§  rZ   rˆ   r‡   rH   rF   rU   r`   ÚFONT_HERSHEY_SIMPLEXrS  rb   r�   r¬   r¶   rÕ  r»   rª   r‰   rØ   rÚ   rë   rñ   rù   r
  r  r)  r1  r>  r~  rª  r¸  rÂ  rè  rü  r  r  r#  rL  r\  rc  r‹   rV   rT   ú<module>r´     s?	  ðØ $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ð &à Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø &Ð &Ð &Ð &Ð &Ð &Ð &Ð &Ø +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ð +Ø ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,à #Ð #Ð #Ð #Ð #Ð #Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5ðð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð ð 8Ð 7Ð 7Ð 7Ð 7Ð 7Ø :Ð :Ð :Ð :Ð :Ð :Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø JÐ JÐ JÐ JÐ JÐ JÐ JÐ Jðð ð ð ð ð ð ð ð ð ð
 <Ð ;Ð ;Ð ;Ð ;Ð ;Ø +Ð +Ð +Ð +Ð +Ð +Ø 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RÐ RØ ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;Ð ;ðð ð ð ð ð ð ð ðð ð ð ð ð ð ð ð ð ð ð ð 1Ð 0Ð 0Ð 0Ð 0Ð 0à	ˆ�XÑ	Ô	€ð ð Øð Ø(-¨c°3¨h¬ð à„[�”Ôð ð  ð  ñ „ð ðF
 %¨,Ñ"6¸Ñ"<ð 
ÀÈÑAUð 
ð 
ð 
ð 
ð Ô#€ðk
ð k
ð k
ð k
ð k
˜-ñ k
ô k
ð k
ð\Tð Tð Tð Tð T�=ñ Tô Tð Tðngð gð gð gð g˜=ñ gô gð gðV$Øð$àˆe�C˜œ R¤XÔ.°´¸B¼HÔ0EÈÑ0LÐLÔMÔNð$ð $ð $ð $ðX  Ø%+ðPð PØŒK˜œÔ!ðPàðPð �<ÑðPð  ¤¨B¬GÔ 4Ñ4ð	Pð
 ðPð ˜˜c˜”?ðPð 	„[�”Ô˜TÑ!ðPð Pð Pð Pðfjð jð jð jð j�Mñ jô jð jðZhð hð hð hð h�}ñ hô hð hðVYð Yð Yð Yð Y�]ñ Yô Yð Yðxnð nð nð nð n�Mñ nô nð nðb`ð `ð `ð `ð `�}ñ `ô `ð `ðF\ð \ð \ð \ð \˜ñ \ô \ð \ð~Yð Yð Yð Yð Y�mñ Yô Yð Yðxlð lð lð lð l�=ñ lô lð lð^]ð ]ð ]ð ]ð ]Ð(ñ ]ô ]ð ]ð@M0ð M0ð M0ð M0ð M0Ð,ñ M0ô M0ð M0ð`c
ð c
ð c
ð c
ð c
�Mñ c
ô c
ð c
ðLKð Kð Kð Kð K�Mñ Kô Kð Kð\nð nð nð nð n�]ñ nô nð nðb_ð _ð _ð _ð _�}ñ _ô _ð _ðD_ð _ð _ð _ð _˜ñ _ô _ð _ðDwð wð wð wð w˜ñ wô wð wðtEð Eð Eð Eð E˜ñ Eô Eð EðPN(ð N(ð N(ð N(ð N(˜]ñ N(ô N(ð N(ðbg>ð g>ð g>ð g>ð g>�Mñ g>ô g>ð g>ðTYð Yð Yð Yð Y ñ Yô Yð YðxOð Oð Oð Oð Oñ Oô Oð Oð Oð OrV   