§
    >²¸jH˜  ã                   ó  — d dl mZmZ d dlmZ d dlmZ d dlZd dl	mZ
 d dlmZ d dlmZmZ d dlmZ d dlmZ d d	lmZ d d
lmZ d dlmZ d dlmZ d dlmZ d dlm Z   e e!¦  «        Z"de#e$e$f         de$de#e$e$f         fd„Z%de
j&        de'fd„Z( G d„ de¦  «        Z) G d„ de)¦  «        Z* G d„ de)¦  «        Z+ G d„ de)¦  «        Z, G d„ de,¦  «        Z- G d„ d e,¦  «        Z. G d!„ d"e,¦  «        Z/e-Z0 G d#„ d$¦  «        Z1dS )%é    )ÚABCÚabstractmethod)ÚSequence)ÚcastN)Ú_cv2)Ú	pad_boxesÚspread_out_boxes)Ú	ImageType)ÚColor)Údraw_rounded_rectangle)ÚRect)Ú	KeyPoints)ÚSKELETONS_BY_VERTEX_COUNT)Ú!ensure_cv2_image_for_class_method)Ú_get_loggerÚedgeÚvertex_countÚreturnc                 óŠ   — | \  }}d|cxk    r|k    rn nd|cxk    r|k    sn t          d|› d| › d�¦  «        ‚|dz
  |dz
  fS )zEValidate 1-based skeleton edges and return zero-based vertex indexes.é   z\Edge indices must use the 1-based convention and be within the available keypoint range [1, z], got ú.)Ú
ValueError)r   r   Úvertex_aÚvertex_bs       úq/root/private/project/pallet_detection_v2/.venv/lib/python3.11/site-packages/supervision/key_points/annotators.pyÚ_validate_edge_indicesr      s�   € àÑ€HˆhØ�Ð)Ð)Ò)Ð)˜\Ò)Ð)Ð)Ð)Ð)¨a°8Ð.KÐ.KÒ.KÐ.K¸|Ò.KÐ.KÐ.KÐ.KÝðIØ,8ðIð IØAEðIð Ið Iñ
ô 
ð 	
ð
 �a‰<˜ A™Ð%Ð%ó    Úpointc                 óh   — t          t          j        | ¦  «                             ¦   «         ¦  «        S )a6  Report whether a keypoint carries coordinates that can be rasterized.

    Pose estimators mark an undetected or occluded keypoint with `NaN` rather than
    dropping it, and `KeyPoints` accepts those values, so annotators receive them
    routinely. Every drawing helper below converts a coordinate to `int`, which
    raises on `NaN` and on an infinity, and `np.allclose(point, 0)` does not catch
    either. `KeyPoints.as_detections` already excludes non-finite coordinates; this
    keeps the annotators on the same rule instead of aborting the whole frame.
    )ÚboolÚnpÚisfiniteÚall)r   s    r   Ú_has_finite_coordinatesr$   "   s(   € õ •”˜EÑ"Ô"×&Ò&Ñ(Ô(Ñ)Ô)Ð)r   c                   ó2   — e Zd Zedededefd„¦   «         ZdS )ÚBaseKeyPointAnnotatorÚsceneÚ
key_pointsr   c                 ó   — d S ©N© )Úselfr'   r(   s      r   ÚannotatezBaseKeyPointAnnotator.annotate0   s   € àˆr   N)Ú__name__Ú
__module__Ú__qualname__r   r
   r   r-   r+   r   r   r&   r&   /   sG   € € € € € Øð˜ið °Yð À9ð ð ð ñ „^ðð ð r   r&   c                   óZ   — e Zd ZdZej        dfdededdfd„Zede	d	e
de	fd
„¦   «         ZdS )ÚVertexAnnotatorz®
    A class that specializes in drawing skeleton vertices on images. It uses
    specified key points to determine the locations where the vertices should be
    drawn.
    é   ÚcolorÚradiusr   Nc                 ó"   — || _         || _        dS )z¦
        Args:
            color: The color to use for annotating key points.
            radius: The radius of the circles used to represent the key points.
        N)r4   r5   )r,   r4   r5   s      r   Ú__init__zVertexAnnotator.__init__<   s   € ð ˆŒ
ØˆŒˆˆr   r'   r(   c           	      ó¶  — t          |¦  «        dk    r|S t          |j        ¦  «        D ]®\  }}t          |¦  «        D ]™\  }\  }}t          j        ||fd¦  «        st          ||f¦  «        sŒ1|j        �|j        ||f         sŒHt          j        |t          |¦  «        t          |¦  «        f| j
        | j                             ¦   «         d¬¦  «         ŒšŒ¯|S )aû  Annotates the given scene with skeleton vertices based on the provided key
        points. It draws circles at each key point location. Anchors marked as not
        visible via ``key_points.visible``, and anchors whose coordinates are not
        finite, are skipped.

        Args:
            scene: The image where skeleton vertices will be drawn. `ImageType` is a
                flexible type, accepting either `numpy.ndarray` or `PIL.Image.Image`.
            key_points: A collection of key points where each key point consists of x
                and y coordinates.

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

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ... )
            >>> annotator = sv.VertexAnnotator(
            ...     color=sv.Color.ROBOFLOW, radius=10
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```
        r   Néÿÿÿÿ)ÚimgÚcenterr5   r4   Ú	thickness)ÚlenÚ	enumerateÚxyr!   Úallcloser$   ÚvisibleÚcv2ÚcircleÚintr5   r4   Úas_bgr)r,   r'   r(   Údetection_indexr?   Úpoint_indexÚxÚys           r   r-   zVertexAnnotator.annotateI   s  € õP ˆz‰?Œ?˜aÒÐØˆLå#,¨Z¬]Ñ#;Ô#;ð 	ð 	ÑˆO˜RÝ'0°¡}¤}ð ð Ñ#�™V˜a Ý”;  1˜v qÑ)Ô)ð Õ1HÈ!ÈQÈÑ1PÔ1Pð ØàÔ&Ð2Ø&Ô.¨ÀÐ/KÔLð 3ð Ý”
ØÝ ™FœF¥C¨¡F¤FÐ+Øœ;Øœ*×+Ò+Ñ-Ô-Ø ðñ ô ð ð ðð  ˆr   )r.   r/   r0   Ú__doc__r   ÚROBOFLOWrD   r7   r   r
   r   r-   r+   r   r   r2   r2   5   s“   € € € € € ðð ð ”~Øðð àðð ðð 
ð	ð ð ð ð 'ð;˜ið ;°Yð ;À9ð ;ð ;ð ;ñ 'Ô&ð;ð ;ð ;r   r2   c                   ó´   — e Zd ZdZej        ddfdededeeeef                  e	eeeeef                  f         z  dz  ddfd„Z
ed	ed
edefd„¦   «         ZdS )ÚEdgeAnnotatorz¨
    A class that specializes in drawing skeleton edges on images using specified key
    points. It connects key points with lines to form the skeleton structure.
    é   Nr4   r<   Úedgesr   c                 ó0   — || _         || _        || _        dS )a$  
        Args:
            color: The color to use for the edges.
            thickness: The thickness of the edges.
            edges: The edges to draw. If set to ``None``, will attempt to
                auto-detect the skeleton by vertex count. A
                ``Sequence[tuple[int, int]]`` applies a single skeleton to
                every instance. A ``dict[int, Sequence[tuple[int, int]]]``
                maps ``class_id`` to skeleton edges, enabling correct
                rendering for datasets with multiple skeleton types.
        N)r4   r<   rO   )r,   r4   r<   rO   s       r   r7   zEdgeAnnotator.__init__Ž   s   € ð& ˆŒ
Ø"ˆŒØˆŒ
ˆ
ˆ
r   r'   r(   c                 ól  — t          |¦  «        dk    r|S t          |j        ¦  «        D �]\  }}t          | j        t
          ¦  «        r^|j        �t          |j        |         ¦  «        nd}|€t          d¦  «        ‚|| j        vrt          d|› d�¦  «        ‚| j        |         }n]| j        r| j        }nNt          j
        t          |¦  «        ¦  «        }|s)t                               dt          |¦  «        ¦  «         ŒÙ|}|D �])}t          |t          |¦  «        ¬¦  «        \  }	}
||	         }||
         }t          j        |d¦  «        st          j        |d¦  «        rŒ_t!          |¦  «        rt!          |¦  «        sŒ~|j        �|j        ||	f         r|j        ||
f         sŒ¤t%          j        |t          |d         ¦  «        t          |d         ¦  «        ft          |d         ¦  «        t          |d         ¦  «        f| j                             ¦   «         | j        ¬	¦  «         �Œ+�Œ
|S )
a6
  Annotates the given scene by drawing lines between specified key points to
        form edges. Edges where either endpoint is marked as not visible via
        ``key_points.visible``, or where either endpoint has a non-finite coordinate,
        are skipped.

        Args:
            scene: The image where skeleton edges will be drawn. `ImageType` is a
                flexible type, accepting either `numpy.ndarray` or `PIL.Image.Image`.
            key_points: A collection of key points where each key point consists of x
                and y coordinates.

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

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            Single-skeleton example:

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ... )
            >>> annotator = sv.EdgeAnnotator(
            ...     color=sv.Color.ROBOFLOW,
            ...     thickness=3,
            ...     edges=[(1, 2), (1, 3)],
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```

            Multi-skeleton example with per-class edges:

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]],
            ...          [[700, 300], [650, 500], [0, 0]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0, 1]),
            ...     visible=np.array(
            ...         [[True, True, True],
            ...          [True, True, False]],
            ...     ),
            ... )
            >>> annotator = sv.EdgeAnnotator(
            ...     color=sv.Color.ROBOFLOW,
            ...     thickness=3,
            ...     edges={0: [(1, 2), (1, 3)], 1: [(1, 2)]},
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```
        r   NzGedges is a dict but class_id is None; KeyPoints must have class_id set.zNo edges defined for class_id=r   z"No skeleton found with %d vertices)r   r   r   )r:   Úpt1Úpt2r4   r<   )r=   r>   r?   Ú
isinstancerO   ÚdictÚclass_idrD   r   r   ÚgetÚloggerÚwarningr   r!   r@   r$   rA   rB   Úliner4   rE   r<   )r,   r'   r(   rF   r?   rV   rO   Ú
_looked_upr   Úidx_aÚidx_bÚxy_aÚxy_bs                r   r-   zEdgeAnnotator.annotate¥   sg  € õN ˆz‰?Œ?˜aÒÐØˆLå#,¨Z¬]Ñ#;Ô#;ð /	ñ /	ÑˆO˜RÝ˜$œ*¥dÑ+Ô+ð #ð "Ô*Ð6õ ˜
Ô+¨OÔ<Ñ=Ô=Ð=àð ð
 Ð#Ý$ð<ñô ð ð  4¤:Ð-Ð-Ý$Ð%QÀhÐ%QÐ%QÐ%QÑRÔRÐRØœ
 8Ô,��Ø”ð #Øœ
��å6Ô:½3¸r¹7¼7ÑCÔC�
Ø!ð Ý—N’NÐ#GÍÈRÉÌÑQÔQÐQØØ"�àð ñ �Ý5¸4ÍcÐRTÉgÌgÐVÑVÔV‘��uØ˜%”y�Ø˜%”y�Ý”;˜t QÑ'Ô'ð ­2¬;°t¸QÑ+?Ô+?ð ØÝ.¨tÑ4Ô4ð Õ<SØñ=ô =ð ð ØÔ%Ð1à&Ô.¨ÀÐ/EÔFð!à)Ô1°/À5Ð2HÔIð!ð !å”ØÝ˜T !œW™œ¥s¨4°¬7¡|¤|Ð4Ý˜T !œW™œ¥s¨4°¬7¡|¤|Ð4Øœ*×+Ò+Ñ-Ô-Ø"œnðñ ô ð ñ ñ#ð2 ˆr   )r.   r/   r0   rJ   r   rK   rD   r   ÚtuplerU   r7   r   r
   r   r-   r+   r   r   rM   rM   ˆ   sÙ   € € € € € ðð ð ”~Øð ðð àðð ðð
 �U˜3 ˜8”_Ô%¨¨S°(¸5ÀÀcÀ¼?Ô2KÐ-KÔ(LÑLÈtÑSðð 
ðð ð ð ð. 'ðz˜ið z°Yð zÀ9ð zð zð zñ 'Ô&ðzð zð zr   rM   c                   ó”  — e Zd ZdZdej        ej        ej        fdfdee	e         z  dee	e         z  dedz  ddfd„Z
d	edej        ej                 fd
„Zdej        ej                 deej        ej                 ej        ej                 f         dz  fd„Zd	edeeeeeef         eeef         eeef                           fd„ZdS )Ú_BaseVertexEllipseAnnotatorz¾Private base for ellipse-based keypoint annotators.

    Handles sigma/color validation, sorting, covariance extraction and
    eigendecomposition shared by all VertexEllipse* variants.
    ©ç      ð?ç       @g      @NÚsigmar4   Úmax_axisr   c                 óš  ‡‡— t          |t          t          f¦  «        r|fn|Št          |t          ¦  «        r|fn|Št	          ‰¦  «        dk    rt          d¦  «        ‚t          d„ ‰D ¦   «         ¦  «        rt          d¦  «        ‚|�|dk    rt          d¦  «        ‚t	          ‰¦  «        t	          ‰¦  «        k    r0t          dt	          ‰¦  «        › dt	          ‰¦  «        › d�¦  «        ‚t          t          t	          ‰¦  «        ¦  «        ˆfd	„d
¬¦  «        }ˆfd„|D ¦   «         | _	        ˆfd„|D ¦   «         | _
        || _        d S )Nr   z%sigma must contain at least one valuec              3   ó"   K  — | ]
}|d k    V — ŒdS )r   Nr+   )Ú.0Úss     r   ú	<genexpr>z7_BaseVertexEllipseAnnotator.__init__.<locals>.<genexpr>7  s&   è è € Ð)Ð)˜!ˆq�AŠvÐ)Ð)Ð)Ð)Ð)Ð)r   z!All sigma values must be positivez'max_axis must be positive when providedzcolor length (z) must match sigma length (ú)c                 ó   •— ‰|          S r*   r+   )ÚiÚ	sigma_seqs    €r   ú<lambda>z6_BaseVertexEllipseAnnotator.__init__.<locals>.<lambda>B  s   ø€ °¸1´€ r   T)ÚkeyÚreversec                 ó    •— g | ]
}‰|         ‘ŒS r+   r+   )rj   ro   rp   s     €r   ú
<listcomp>z8_BaseVertexEllipseAnnotator.__init__.<locals>.<listcomp>D  ó   ø€ Ð;Ð;Ð; q�i ”lÐ;Ð;Ð;r   c                 ó    •— g | ]
}‰|         ‘ŒS r+   r+   )rj   ro   Ú	color_seqs     €r   ru   z8_BaseVertexEllipseAnnotator.__init__.<locals>.<listcomp>E  rv   r   )rT   rD   Úfloatr   r=   r   ÚanyÚsortedÚrangerf   r4   rg   )r,   rf   r4   rg   Úsorted_indicesrx   rp   s        @@r   r7   z$_BaseVertexEllipseAnnotator.__init__*  s  øø€ õ # 5­3µ¨,Ñ7Ô7ÐBˆUˆHˆH¸Uð 	õ 2<¸EÅ5Ñ1IÔ1IÐ%T e X XÈuˆ	åˆy‰>Œ>˜QÒÐÝÐDÑEÔEÐEÝÐ)Ð)˜yÐ)Ñ)Ô)Ñ)Ô)ð 	BÝÐ@ÑAÔAÐAØÐ H°¢M MÝÐFÑGÔGÐGÝˆy‰>Œ>�S ™^œ^Ò+Ð+Ýð3¥ Y¡¤ð 3ð 3Ý!$ Y¡¤ð3ð 3ð 3ñô ð õ
  Ý•#�i‘.”.Ñ!Ô!Ð'=Ð'=Ð'=Ð'=Àtð
ñ 
ô 
ˆð <Ð;Ð;Ð;¨NÐ;Ñ;Ô;ˆŒ
Ø;Ð;Ð;Ð;¨NÐ;Ñ;Ô;ˆŒ
Ø ˆŒˆˆr   r(   c                 ón  — |j                              d¦  «        }|€t          d¦  «        ‚t          t          j        t          j                 t          j        |t          j        ¬¦  «        ¦  «        }g |j	        j
        d d…         ¢d‘d‘R }|j
        |k    rt          d|› d|j
        › d�¦  «        ‚|S )NÚ
covariancezBkey_points.data must contain 'covariance' with shape (N, K, 2, 2).©ÚdtyperN   zExpected covariance shape z, got r   )ÚdatarW   r   r   ÚnptÚNDArrayr!   Úfloat32Úasarrayr?   Úshape)r,   r(   ÚcovariancesÚcovariances_arrayÚexpected_shapes        r   Ú_get_covariancesz,_BaseVertexEllipseAnnotator._get_covariancesH  sØ   € Ø ”o×)Ò)¨,Ñ7Ô7ˆØÐÝØTñô ð õ !ÝŒK�œ
Ô#¥R¤Z°Å2Ä:Ð%NÑ%NÔ%Nñ
ô 
Ðð :˜:œ=Ô.¨r°¨rÔ2Ð9°AÐ9°qÐ9Ð9ˆØÔ" nÒ4Ð4Ýð2¨^ð 2ð 2Ø(Ô.ð2ð 2ð 2ñô ð ð !Ð r   r   c                 óì  — t          j        |¦  «                             ¦   «         sdS 	 t           j                             |                     t           j        ¦  «        ¦  «        \  }}n# t           j        j        $ r Y dS w xY wt          j        |¦  «                             ¦   «         rt          j        |dk    ¦  «        rdS t          j	        |¦  «        ddd…         }||         |dd…|f         fS )zIEigendecompose a 2x2 covariance, returning sorted (eigenvalues, vectors).Nr   r9   )
r!   r"   r#   ÚlinalgÚeighÚastypeÚfloat64ÚLinAlgErrorrz   Úargsort)r,   r   ÚeigenvaluesÚeigenvectorsÚorders        r   Ú_decompose_covariancez1_BaseVertexEllipseAnnotator._decompose_covarianceY  sí   € õ Œ{˜:Ñ&Ô&×*Ò*Ñ,Ô,ð 	Ø�4ð	Ý(*¬	¯ª°z×7HÒ7HÍÌÑ7TÔ7TÑ(UÔ(UÑ%ˆK˜˜øÝŒyÔ$ð 	ð 	ð 	Ø�4�4ð	øøøåŒ{˜;Ñ'Ô'×+Ò+Ñ-Ô-ð 	µ´¸ÀqÒ8HÑ1IÔ1Ið 	Ø�4Ý”
˜;Ñ'Ô'¨¨¨"¨Ô-ˆØ˜5Ô! <°°°°5°Ô#9Ð9Ð9s   ª?A* Á*BÂBc                 óä  — |                       |¦  «        }d„ | j        D ¦   «         }t          |j        ¦  «        D �]³\  }}t          |¦  «        D �]œ\  }\  }}t	          j        ||fd¦  «        st          ||f¦  «        sŒ2|j        �|j        ||f         sŒI|||f         }	|                      |	¦  «        }
|
€Œk|
\  }}t          t	          j
        t	          j        |d         |d         ¦  «        ¦  «        ¦  «        }t          |¦  «        t          |¦  «        f}t          t          | j        | j        ¦  «        ¦  «        D ]¦\  }\  }}|t	          j        |¦  «        z  }| j        �t	          j        || j        ¦  «        }t%          dt          |d         ¦  «        ¦  «        t%          dt          |d         ¦  «        ¦  «        f}||                              |||||f¦  «         Œ§�Œž�Œµ|S )z?Return ellipse params grouped by sigma level (outermost first).c                 ó   — g | ]}g ‘ŒS r+   r+   )rj   Ú_s     r   ru   zD_BaseVertexEllipseAnnotator._iter_ellipse_params.<locals>.<listcomp>o  s   € Ð$Ð$Ð$�AˆRÐ$Ð$Ð$r   r   N)r   r   )r   r   r   )r‹   rf   r>   r?   r!   r@   r$   rA   r–   ry   ÚdegreesÚarctan2ÚroundÚzipr4   Úsqrtrg   ÚminimumÚmaxÚappend)r,   r(   rˆ   ÚlevelsrF   r?   rG   rH   rI   r   Údecompositionr“   r”   Úangler;   Ú	level_idxrf   r4   ÚaxesÚaxis_lengthss                       r   Ú_iter_ellipse_paramsz0_BaseVertexEllipseAnnotator._iter_ellipse_paramsh  s  € ð ×+Ò+¨JÑ7Ô7ˆð %Ð$˜œÐ$Ñ$Ô$ð 	õ $-¨Z¬]Ñ#;Ô#;ð 	ñ 	ÑˆO˜RÝ'0°¡}¤}ð ñ Ñ#�™V˜a Ý”;  1˜v qÑ)Ô)ð Õ1HÈ!ÈQÈÑ1PÔ1Pð ØàÔ&Ð2Ø&Ô.¨ÀÐ/KÔLð 3ð Ø(¨¸+Ð)EÔF�
Ø $× :Ò :¸:Ñ FÔ F�Ø Ð(ØØ,9Ñ)�˜\ÝÝ”J�rœz¨,°tÔ*<¸lÈ4Ô>PÑQÔQÑRÔRñô �õ   ™(œ(¥E¨!¡H¤HÐ-�Ý1:½3¸t¼zÈ4Ì:Ñ;VÔ;VÑ1WÔ1Wð 
ð 
Ñ-�I™~  uØ ¥2¤7¨;Ñ#7Ô#7Ñ7�DØ”}Ð0Ý!œz¨$°´Ñ>Ô>˜å˜A�u T¨!¤W™~œ~Ñ.Ô.Ý˜A�u T¨!¤W™~œ~Ñ.Ô.ð$�Lð ˜9Ô%×,Ò,Ø ¨u°e¸UÐCñô ð ð ñ
ñ#ð8 ˆr   )r.   r/   r0   rJ   r   ÚGREENÚYELLOWÚREDry   r   r7   r   rƒ   r„   r!   r…   r‹   r`   r�   r–   ÚlistrD   r¨   r+   r   r   rb   rb   #  sR  € € € € € ðð ð *9Ø*/¬+°u´|ÀUÄYÐ)OØ!%ð	!ð !à�x ”Ñ&ð!ð �x ”Ñ&ð!ð ˜$‘,ð	!ð
 
ð!ð !ð !ð !ð<!¨9ð !¸¼ÀRÄZÔ9Pð !ð !ð !ð !ð":Øœ+ b¤jÔ1ð:à	ˆsŒ{˜2œ:Ô&¨¬°B´JÔ(?Ð?Ô	@À4Ñ	Gð:ð :ð :ð :ð%Ø#ð%à	ˆd�5˜˜s C˜xœ¨%°°S°¬/¸5À%ÈÐNÔOÔPÔ	Qð%ð %ð %ð %ð %ð %r   rb   c                   ó´   ‡ — e Zd ZdZdej        ej        ej        fddfdee	e         z  dee	e         z  dededz  d	df
ˆ fd
„Z
ededed	efd„¦   «         Zˆ xZS )ÚVertexEllipseAreaAnnotatora�  
    Draws filled semi-transparent covariance ellipses at multiple sigma levels
    around each keypoint, each ring in a different color.  This produces a
    bullseye-like uncertainty visualization where inner rings represent higher
    probability density.

    !!! warning

        This annotator uses `key_points.data["covariance"]` with shape
        `(N, K, 2, 2)` in pixel coordinates.
    rc   gš™™™™™Ù?Nrf   r4   Úopacityrg   r   c                 ó^   •— t          ¦   «                              |||¬¦  «         || _        dS )ae  
        Args:
            sigma: Sigma multipliers for each ring, drawn from outermost to
                innermost.  Accepts a single float or a sequence of floats.
                Defaults to ``(1.0, 2.0, 3.0)``.
            color: The color for each sigma level.  Accepts a single
                ``Color`` or a sequence of colors (one per sigma level).
                Defaults to ``(Color.GREEN, Color.YELLOW, Color.RED)``.
            opacity: Opacity of the overlay mask. Must be between ``0`` and
                ``1``.
            max_axis: Optional cap for ellipse semi-axis lengths in pixels.
        ©rf   r4   rg   N©Úsuperr7   r¯   ©r,   rf   r4   r¯   rg   Ú	__class__s        €r   r7   z#VertexEllipseAreaAnnotator.__init__�  ó/   ø€ õ& 	‰Œ×Ò˜u¨E¸HÐÑEÔEÐEØˆŒˆˆr   r'   r(   c                 ó^  — t          |¦  «        dk    r|S |                     ¦   «         }|                      |¦  «        D ]F}|D ]A\  }}}}}	t          j        ||||dd|	                     ¦   «         dt          j        ¬¦	  «	         ŒBŒGt          j        || j        |d| j        z
  d|¬¦  «         |S )aÒ  Draws filled semi-transparent covariance ellipses around each keypoint.
        Keypoints marked as not visible via ``key_points.visible``, and keypoints whose
        coordinates are not finite, are skipped.

        Args:
            scene: The image to annotate. ``ImageType`` accepts either
                ``numpy.ndarray`` or ``PIL.Image.Image``.
            key_points: Key points with covariance data in
                ``key_points.data["covariance"]``.

        Returns:
            The annotated image, matching the type of ``scene``.

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ...     data={
            ...         "covariance": np.array(
            ...             [[[[800, 0], [0, 400]],
            ...               [[400, 0], [0, 800]],
            ...               [[600, 0], [0, 600]]]],
            ...             dtype=np.float32,
            ...         )
            ...     },
            ... )
            >>> annotator = sv.VertexEllipseAreaAnnotator(
            ...     sigma=[1.0, 2.0],
            ...     color=[sv.Color.GREEN, sv.Color.RED],
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```
        r   éh  r9   ©	r:   r;   r¦   r¤   Ú
startAngleÚendAngler4   r<   ÚlineTyper   )Údst)	r=   Úcopyr¨   rB   ÚellipserE   ÚLINE_AAÚaddWeightedr¯   )
r,   r'   r(   ÚoverlayÚlevelr;   r§   r¤   Ú_sigmar4   s
             r   r-   z#VertexEllipseAreaAnnotator.annotate³  sÔ   € õ^ ˆz‰?Œ?˜aÒÐØˆLà—*’*‘,”,ˆØ×.Ò.¨zÑ:Ô:ð 	ð 	ˆEØ>Cð ð Ñ:�˜ e¨V°UÝ”ØØ!Ø%ØØ Ø ØŸ,š,™.œ.Ø Ý œ[ð
ñ 
ô 
ð 
ð 
ðõ 	Œ˜ ¤¨u°a¸$¼,Ñ6FÈÈuÐUÑUÔUÐUØˆr   )r.   r/   r0   rJ   r   r©   rª   r«   ry   r   r7   r   r
   r   r-   Ú__classcell__©rµ   s   @r   r®   r®   �  sî   ø€ € € € € ð
ð 
ð *9Ø*/¬+°u´|ÀUÄYÐ)OØØ!%ðð à�x ”Ñ&ðð �x ”Ñ&ðð ð	ð
 ˜$‘,ðð 
ðð ð ð ð ð ð, 'ðA˜ið A°Yð AÀ9ð Að Að Añ 'Ô&ðAð Að Að Að Ar   r®   c                   ó´   ‡ — e Zd ZdZdej        ej        ej        fddfdee	e         z  dee	e         z  de
dedz  d	df
ˆ fd
„Zededed	efd„¦   «         Zˆ xZS )ÚVertexEllipseOutlineAnnotatorzø
    Draws stroke-only concentric covariance ellipse rings at multiple sigma
    levels around each keypoint.

    !!! warning

        This annotator uses `key_points.data["covariance"]` with shape
        `(N, K, 2, 2)` in pixel coordinates.
    rc   rN   Nrf   r4   r<   rg   r   c                 ó^   •— t          ¦   «                              |||¬¦  «         || _        dS )aA  
        Args:
            sigma: Sigma multipliers for each ring, drawn from outermost to
                innermost.  Accepts a single float or a sequence of floats.
                Defaults to ``(1.0, 2.0, 3.0)``.
            color: The color for each sigma level.  Accepts a single
                ``Color`` or a sequence of colors (one per sigma level).
                Defaults to ``(Color.GREEN, Color.YELLOW, Color.RED)``.
            thickness: Line thickness of the ellipse outlines.
            max_axis: Optional cap for ellipse semi-axis lengths in pixels.
        r±   N)r³   r7   r<   )r,   rf   r4   r<   rg   rµ   s        €r   r7   z&VertexEllipseOutlineAnnotator.__init__  s/   ø€ õ$ 	‰Œ×Ò˜u¨E¸HÐÑEÔEÐEØ"ˆŒˆˆr   r'   r(   c                 óò   — t          |¦  «        dk    r|S |                      |¦  «        D ]K}|D ]F\  }}}}}t          j        ||||dd|                     ¦   «         | j        t          j        ¬¦	  «	         ŒGŒL|S )aò  Draws stroke-only covariance ellipse outlines around each keypoint. Keypoints
        marked as not visible via ``key_points.visible``, and keypoints whose
        coordinates are not finite, are skipped.

        Args:
            scene: The image to annotate. ``ImageType`` accepts either
                ``numpy.ndarray`` or ``PIL.Image.Image``.
            key_points: Key points with covariance data in
                ``key_points.data["covariance"]``.

        Returns:
            The annotated image, matching the type of ``scene``.

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ...     data={
            ...         "covariance": np.array(
            ...             [[[[800, 0], [0, 400]],
            ...               [[400, 0], [0, 800]],
            ...               [[600, 0], [0, 600]]]],
            ...             dtype=np.float32,
            ...         )
            ...     },
            ... )
            >>> annotator = sv.VertexEllipseOutlineAnnotator(
            ...     sigma=[1.0, 2.0],
            ...     color=[sv.Color.GREEN, sv.Color.RED],
            ...     thickness=2,
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```
        r   r¸   r¹   )r=   r¨   rB   r¿   rE   r<   rÀ   )	r,   r'   r(   rÃ   r;   r§   r¤   rÄ   r4   s	            r   r-   z&VertexEllipseOutlineAnnotator.annotate  s£   € õ` ˆz‰?Œ?˜aÒÐØˆLà×.Ò.¨zÑ:Ô:ð 	ð 	ˆEØ>Cð ð Ñ:�˜ e¨V°UÝ”ØØ!Ø%ØØ Ø ØŸ,š,™.œ.Ø"œnÝ œ[ð
ñ 
ô 
ð 
ð 
ðð ˆr   )r.   r/   r0   rJ   r   r©   rª   r«   ry   r   rD   r7   r   r
   r   r-   rÅ   rÆ   s   @r   rÈ   rÈ   ø  sî   ø€ € € € € ðð ð *9Ø*/¬+°u´|ÀUÄYÐ)OØØ!%ð#ð #à�x ”Ñ&ð#ð �x ”Ñ&ð#ð ð	#ð
 ˜$‘,ð#ð 
ð#ð #ð #ð #ð #ð #ð* 'ð@˜ið @°Yð @À9ð @ð @ð @ñ 'Ô&ð@ð @ð @ð @ð @r   rÈ   c                   óÄ   ‡ — e Zd ZU dZdZeed<   dej        ej	        ej
        fddfdeee         z  deee         z  d	ed
edz  ddf
ˆ fd„Zedededefd„¦   «         Zˆ xZS )ÚVertexEllipseHaloAnnotatora™  
    Draws filled covariance ellipses with a radial fade: full opacity at the
    center, smoothly falling off to zero at the ellipse boundary.  The falloff
    follows a power curve controlled by ``decay``, producing a soft glow that
    is strongest near the keypoint.

    !!! warning

        This annotator uses `key_points.data["covariance"]` with shape
        `(N, K, 2, 2)` in pixel coordinates.
    re   Ú_DECAYrc   g333333ã?Nrf   r4   r¯   rg   r   c                 ó^   •— t          ¦   «                              |||¬¦  «         || _        dS )al  
        Args:
            sigma: Sigma multipliers for each ring, drawn from outermost to
                innermost.  Accepts a single float or a sequence of floats.
                Defaults to ``(1.0, 2.0, 3.0)``.
            color: The color for each sigma level.  Accepts a single
                ``Color`` or a sequence of colors (one per sigma level).
                Defaults to ``(Color.GREEN, Color.YELLOW, Color.RED)``.
            opacity: Peak opacity at the ellipse center. Must be between ``0``
                and ``1``.
            max_axis: Optional cap for ellipse semi-axis lengths in pixels.
        r±   Nr²   r´   s        €r   r7   z#VertexEllipseHaloAnnotator.__init__k  r¶   r   r'   r(   c                 ó  — t          |¦  «        dk    r|S |j        dd…         \  }}|                     t          j        ¦  «        }|                      |¦  «        D �]ö}|D �]ï\  }}}	}
}|\  }}|dk    s|dk    rŒd}||z   }||z   }|\  }}t          ||z
  d¦  «        }t          ||z   |¦  «        }t          ||z
  d¦  «        }t          ||z   |¦  «        }||k    s||k    rŒ…t          j        ||t          j        ¬¦  «        |z
  }t          j        ||t          j        ¬¦  «        |z
  }t          j	        ||¦  «        \  }}t          j
        |	 ¦  «        }t          j        |¦  «        }t          j        |¦  «        }||z  ||z  z
  }||z  ||z  z   }||z  dz  ||z  dz  z   } | dk    }!t          j        | ¦  «        }"d| |!         z
  | j        z  |"|!<   |"| j        z  }#t          j        |                     ¦   «         t          j        ¬¦  «        }$|||…||…f         }%|#dd…dd…t          j        f         }&|%d|&z
  z  |$|&z  z   |%dd…<   �Œñ�Œøt          j        ||                     t          j        ¦  «        ¦  «         |S )aÊ  Draws radially-fading covariance ellipses around each keypoint. Keypoints
        marked as not visible via ``key_points.visible``, and keypoints whose
        coordinates are not finite, are skipped.

        Args:
            scene: The image to annotate. ``ImageType`` accepts either
                ``numpy.ndarray`` or ``PIL.Image.Image``.
            key_points: Key points with covariance data in
                ``key_points.data["covariance"]``.

        Returns:
            The annotated image, matching the type of ``scene``.

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ...     data={
            ...         "covariance": np.array(
            ...             [[[[800, 0], [0, 400]],
            ...               [[400, 0], [0, 800]],
            ...               [[600, 0], [0, 600]]]],
            ...             dtype=np.float32,
            ...         )
            ...     },
            ... )
            >>> annotator = sv.VertexEllipseHaloAnnotator(
            ...     sigma=[1.0, 2.0],
            ...     color=[sv.Color.GREEN, sv.Color.RED],
            ... )
            >>> result = annotator.annotate(image.copy(), key_points)

            ```
        r   NrN   r€   rd   r   )r=   r‡   r�   r!   r…   r¨   r    ÚminÚarangeÚmeshgridÚradiansÚcosÚsinÚ
zeros_likerÍ   r¯   ÚarrayrE   ÚnewaxisÚcopytoÚuint8)'r,   r'   r(   ÚhÚwÚ	compositerÃ   r;   r§   r¤   rÄ   r4   ÚaxÚayÚpadÚ
roi_half_wÚ
roi_half_hÚcxÚcyÚx_minÚx_maxÚy_minÚy_maxÚysÚxsÚgrid_xÚgrid_yÚ	angle_radÚcos_aÚsin_aÚrxÚryÚdist_sqÚinsideÚfalloffÚscaled_alphaÚbgrÚroiÚalpha_3s'                                          r   r-   z#VertexEllipseHaloAnnotator.annotate�  s¯  € õ^ ˆz‰?Œ?˜aÒÐØˆLàŒ{˜2˜A˜2Œ‰ˆˆ1Ø-2¯\ª\½"¼*Ñ-EÔ-Eˆ	à×.Ò.¨zÑ:Ô:ð '	=ñ '	=ˆEØ>Cð &=ñ &=Ñ:�˜ e¨V°UØ%‘��BØ˜’7�7˜b Ašg˜gØà�Ø #™X�
Ø #™X�
Ø‘��Bå˜B ™O¨QÑ/Ô/�Ý˜B ™O¨QÑ/Ô/�Ý˜B ™O¨QÑ/Ô/�Ý˜B ™O¨QÑ/Ô/�Ø˜E’>�> U¨e¢^ ^Øå”Y˜u eµ2´:Ð>Ñ>Ô>ÀÑC�Ý”Y˜u eµ2´:Ð>Ñ>Ô>ÀÑC�Ý!#¤¨R°Ñ!4Ô!4‘�˜åœJ¨ vÑ.Ô.�	Ýœ˜yÑ)Ô)�Ýœ˜yÑ)Ô)�Ø˜e‘^ f¨u¡nÑ4�Ø˜e‘^ f¨u¡nÑ4�à ™7 q™.¨B°©G¸©>Ñ9�Ø  Cš�åœ-¨Ñ0Ô0�Ø#&¨°¬Ñ#8¸T¼[Ñ"H�˜‘à&¨¬Ñ5�å”h˜uŸ|š|™~œ~µR´ZÐ@Ñ@Ô@�Ø  e ¨U°5¨[Ð 8Ô9�Ø& q q q¨!¨!¨!­R¬ZÐ'7Ô8�Ø  G¡Ñ,¨s°W©}Ñ<��A�A�A‘‘ñM&=õP 	Œ	�%˜×)Ò)­"¬(Ñ3Ô3Ñ4Ô4Ð4Øˆr   )r.   r/   r0   rJ   rÍ   ry   Ú__annotations__r   r©   rª   r«   r   r7   r   r
   r   r-   rÅ   rÆ   s   @r   rÌ   rÌ   \  s  ø€ € € € € € ð
ð 
ð €FˆEÐÐÑð *9Ø*/¬+°u´|ÀUÄYÐ)OØØ!%ðð à�x ”Ñ&ðð �x ”Ñ&ðð ð	ð
 ˜$‘,ðð 
ðð ð ð ð ð ð, 'ð^˜ið ^°Yð ^À9ð ^ð ^ð ^ñ 'Ô&ð^ð ^ð ^ð ^ð ^r   rÌ   c                   óæ  — e Zd ZdZej        ej        dddddfdeee         z  deee         z  d	ed
e	de	de	de
fd„Ze	 ddededee         ee	ee         f         z  dz  defd„¦   «         Zedede	d	ed
e	dee	e	f         dee	e	e	e	f         fd„¦   «         Ze	 ddee         ee	ee         f         z  dz  de	de	dz  dee         fd„¦   «         Zedeee         z  de	dee         fd„¦   «         ZdS )ÚVertexLabelAnnotatorz£
    A class that draws labels of skeleton vertices on images. It uses specified key
    points to determine the locations where the vertices should be drawn.
    g      à?r   é
   r   Fr4   Ú
text_colorÚ
text_scaleÚtext_thicknessÚtext_paddingÚborder_radiusÚsmart_positionc                 óh   — || _         || _        || _        || _        || _        || _        || _        dS )a§  
        Args:
            color: The color to use for each keypoint label. If a list is
                provided, the colors will be used in order for each keypoint.
            text_color: The color to use for the labels. If a list is
                provided, the colors will be used in order for each keypoint.
            text_scale: The scale of the text.
            text_thickness: The thickness of the text.
            text_padding: The padding around the text.
            border_radius: The radius of the rounded corners of the boxes.
                Set to a high value to produce circles.
            smart_position: Spread out the labels to avoid overlap.
        N)r  r4   rý   rþ   rÿ   r   r  )r,   r4   rý   rþ   rÿ   r   r  r  s           r   r7   zVertexLabelAnnotator.__init__ì  s?   € ð. #0ˆÔØ*/ˆŒ
Ø/9ˆŒØ!+ˆŒØ#1ˆÔØ!-ˆÔØ,ˆÔÐÐr   Nr'   r(   Úlabelsr   c                 óŒ  ‡ ‡— t           j        Š|j        j        \  }}}|dk    r|S g }g }g }	g }
t	          |¦  «        D �]x}|j        |         }|j        �t          |j        |         ¦  «        nd}‰                      |||¦  «        }‰                      ‰ j	        |¦  «        }‰                      ‰ j
        |¦  «        }t	          |¦  «        D ]è}t          ||         ¦  «        sŒ|j        �|j        ||f         sŒ/nt          j        ||         d¦  «        rŒLt          ||         d         ¦  «        t          ||         d         ¦  «        f}|                     |¦  «         |                     ||         ¦  «         |	                     ||         ¦  «         |
                     ||         ¦  «         Œé�Œz|s|S t          j        ˆˆ fd„t#          ||¦  «        D ¦   «         ¦  «        }t%          |‰ j        ¬¦  «        }‰ j        r&t+          |¦  «        }t%          |‰ j         ¬¦  «        }t#          ||	|
||¦  «        D ]‚\  }}}}}t-          |t/          j        |¦  «        |‰ j        ¬¦  «         t          j        |||d         |d         f‰‰ j        |                     ¦   «         ‰ j        t           j        ¬¦  «         Œƒ|S )	aÓ  Draws labels at skeleton vertex positions on the image. Vertices marked not
        visible via ``key_points.visible``, and vertices whose coordinates are not
        finite, are skipped.

        Args:
            scene: The image where vertex labels will be drawn. `ImageType` is a
                flexible type, accepting either `numpy.ndarray` or `PIL.Image.Image`.
            key_points: A collection of key points where each key point consists of x
                and y coordinates.
            labels: Labels to display at each keypoint. If ``None``, keypoint
                indices are used. A ``list[str]`` applies the same labels to
                every instance. A ``dict[int, list[str]]`` maps ``class_id``
                to per-class label lists, enabling correct labeling for
                datasets with multiple skeleton types.

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

        Raises:
            TypeError: If `scene` is not a `numpy.ndarray` or `PIL.Image.Image`.

        Example:
            Single-skeleton example:

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0]),
            ...     visible=np.array([[True, True, True]]),
            ... )
            >>> annotator = sv.VertexLabelAnnotator(
            ...     color=sv.Color.ROBOFLOW,
            ...     text_color=sv.Color.WHITE,
            ...     border_radius=5,
            ... )
            >>> result = annotator.annotate(
            ...     scene=image.copy(),
            ...     key_points=key_points,
            ...     labels=["head", "L-foot", "R-foot"],
            ... )

            ```

            Multi-skeleton example with per-class labels:

            ```pycon
            >>> import numpy as np
            >>> import supervision as sv
            >>> image = np.zeros((800, 800, 3), dtype=np.uint8)
            >>> key_points = sv.KeyPoints(
            ...     xy=np.array(
            ...         [[[400, 200], [300, 500], [500, 500]],
            ...          [[700, 300], [650, 500], [0, 0]]],
            ...         dtype=np.float32,
            ...     ),
            ...     class_id=np.array([0, 1]),
            ...     visible=np.array(
            ...         [[True, True, True],
            ...          [True, True, False]],
            ...     ),
            ... )
            >>> annotator = sv.VertexLabelAnnotator(
            ...     color=sv.Color.ROBOFLOW,
            ...     text_color=sv.Color.WHITE,
            ...     border_radius=5,
            ... )
            >>> result = annotator.annotate(
            ...     scene=image.copy(),
            ...     key_points=key_points,
            ...     labels={
            ...         0: ["head", "L-foot", "R-foot"],
            ...         1: ["top", "bottom", "pad"],
            ...     },
            ... )

            ```
        r   Nr   c           	      ó^   •— g | ])\  }}‰                      |‰‰j        ‰j        |¬ ¦  «        ‘Œ*S ))ÚtextÚfontrþ   rÿ   Úcenter_coordinates)Úget_text_bounding_boxrþ   rÿ   )rj   ÚanchorÚlabelr  r,   s      €€r   ru   z1VertexLabelAnnotator.annotate.<locals>.<listcomp>�  sX   ø€ ð 	ð 	ð 	ñ "�F˜Eð ×*Ò*ØØØ#œØ#'Ô#6Ø'-ð +ñ ô ð	ð 	ð 	r   )ÚxyxyÚpx)r'   Úrectr4   r  é   )r:   r  ÚorgÚfontFaceÚ	fontScaler4   r<   r¼   )rB   ÚFONT_HERSHEY_SIMPLEXr?   r‡   r|   rV   rD   Ú_resolve_labelsÚ_resolve_color_listr4   rý   r$   rA   r!   r@   r¡   r×   r�   r   r   r  r	   r   r   Ú	from_xyxyr  ÚputTextrþ   rE   rÿ   rÀ   )r,   r'   r(   r  Úskeletons_countÚpoints_countr™   Úall_anchorsÚ
all_labelsÚ
all_colorsÚall_text_colorsro   r?   rV   Úinstance_labelsÚinstance_colorsÚinstance_text_colorsÚjr  r  Úxyxy_paddedr  r4   rý   ÚboxÚ
box_paddedr  s   `                         @r   r-   zVertexLabelAnnotator.annotate  s>  øø€ õv Ô'ˆà+5¬=Ô+>Ñ(ˆ˜ qØ˜aÒÐØˆLà-/ˆØ "ˆ
Ø"$ˆ
Ø')ˆå�Ñ'Ô'ð 	@ñ 	@ˆAØ”˜qÔ!ˆBð 0:Ô/BÐ/N•�JÔ'¨Ô*Ñ+Ô+Ð+ÐTXð ð #×2Ò2°6¸<ÈÑRÔRˆOØ"×6Ò6°t´zÀ<ÑPÔPˆOØ#'×#;Ò#;Ø” ñ$ô $Ð õ ˜<Ñ(Ô(ð @ð @�Ý.¨r°!¬uÑ5Ô5ð ØØÔ%Ð1Ø%Ô-¨a°¨dÔ3ð !Ø ð!å”[  A¤¨Ñ*Ô*ð Øå˜b œe Aœh™-œ-­¨R°¬U°1¬X©¬Ð7�Ø×"Ò" 6Ñ*Ô*Ð*Ø×!Ò! /°!Ô"4Ñ5Ô5Ð5Ø×!Ò! /°!Ô"4Ñ5Ô5Ð5Ø×&Ò&Ð';¸AÔ'>Ñ?Ô?Ð?Ð?ñ@ð ð 	ØˆLåŒxð	ð 	ð 	ð 	ð 	õ &)¨°jÑ%AÔ%Að	ñ 	ô 	ñ
ô 
ˆõ   T¨dÔ.?Ð@Ñ@Ô@ˆàÔð 	FÝ*¨;Ñ7Ô7ˆKÝ +°4Ô3DÐ2DÐEÑEÔEˆDå8;Ø˜
 O°T¸;ñ9
ô 9
ð 	ð 	Ñ4ˆD�%˜ S¨*õ #ØÝ”^ JÑ/Ô/ØØ"Ô0ð	ñ ô ð õ ŒKØØØ˜”V˜S œVÐ$ØØœ/Ø ×'Ò'Ñ)Ô)ØÔ-Ýœð	ñ 	ô 	ð 	ð 	ð ˆr   r  r  r	  c                 óŠ   — t          j        | |||¬¦  «        d         \  }}|\  }}||dz  z
  ||dz  z
  ||dz  z   ||dz  z   fS )N)r  r  r  r<   r   rN   )rB   ÚgetTextSize)	r  r  rþ   rÿ   r	  Útext_wÚtext_hÚcenter_xÚcenter_ys	            r   r
  z*VertexLabelAnnotator.get_text_bounding_box·  sz   € õ œØØØ Ø$ð	
ñ 
ô 
ð
 ô‰ˆ�ð 0Ñˆ�(à�v ‘{Ñ"Ø�v ‘{Ñ"Ø�v ‘{Ñ"Ø�v ‘{Ñ"ð	
ð 	
r   r  rV   c                 ó8  — | €d„ t          |¦  «        D ¦   «         S t          | t          ¦  «        r1|€t          d¦  «        ‚|| vrt          d|› d�¦  «        ‚| |         }n| }t	          |¦  «        |k    r#t          dt	          |¦  «        › d|› d�¦  «        ‚|S )	z,Return the label list for a single instance.Nc                 ó,   — g | ]}t          |¦  «        ‘ŒS r+   )Ústr)rj   r"  s     r   ru   z8VertexLabelAnnotator._resolve_labels.<locals>.<listcomp>Õ  s   € Ð8Ð8Ð8˜q•C˜‘F”FÐ8Ð8Ð8r   zHlabels is a dict but class_id is None; KeyPoints must have class_id set.zNo labels defined for class_id=r   zNumber of labels (ú#) must match number of key points (ú).)r|   rT   rU   r   r=   )r  r  rV   Úresolveds       r   r  z$VertexLabelAnnotator._resolve_labelsÍ  sá   € ð ˆ>Ø8Ð8¥E¨,Ñ$7Ô$7Ð8Ñ8Ô8Ð8õ �f�dÑ#Ô#ð 
	ØÐÝ ð8ñô ð ð ˜vÐ%Ð%Ý Ð!NÀ8Ð!NÐ!NÐ!NÑOÔOÐOØ˜hÔ'ˆHˆHàˆHåˆx‰=Œ=˜LÒ(Ð(Ýð:¥S¨¡]¤]ð :ð :Ø)5ð:ð :ð :ñô ð ð ˆr   Úcolorsc                 ó¨   — t          | t          ¦  «        r8t          | ¦  «        |k    r#t          dt          | ¦  «        › d|› d�¦  «        ‚| S | g|z  S )z7Return a per-keypoint color list for a single instance.zNumber of colors (r/  r0  )rT   r¬   r=   r   )r2  r  s     r   r  z(VertexLabelAnnotator._resolve_color_listë  sv   € õ �f�dÑ#Ô#ð 	Ý�6‰{Œ{˜lÒ*Ð*Ý ð>­¨V©¬ð >ð >Ø-9ð>ð >ð >ñô ð ð ˆMØˆx˜,Ñ&Ð&r   r*   )r.   r/   r0   rJ   r   rK   ÚWHITEr¬   ry   rD   r    r7   r   r
   r   r.  rU   r-   Ústaticmethodr`   r
  r  r  r+   r   r   rû   rû   æ  sD  € € € € € ðð ð &+¤^Ø*/¬+ØØØØØ$ð-ð -à�t˜E”{Ñ"ð-ð ˜D œKÑ'ð-ð ð	-ð
 ð-ð ð-ð ð-ð ð-ð -ð -ð -ð> 'ð
 ;?ð	ið iàðið ðið �S”	˜D  d¨3¤i Ô0Ñ0°4Ñ7ð	ið
 
ðið ið iñ 'Ô&ðiðV ð
Øð
àð
ð ð
ð ð	
ð
 " # s (œOð
ð 
ˆs�C˜˜cÐ!Ô	"ð
ð 
ð 
ñ „\ð
ð* ð  $ðð Ø�S”	˜D  d¨3¤i Ô0Ñ0°4Ñ7ðàðð ˜‘*ðð 
ˆcŒð	ð ð ñ „\ðð: ð'Ø˜˜UœÑ#ð'àð'ð 
ˆeŒð'ð 'ð 'ñ „\ð'ð 'ð 'r   rû   )2Úabcr   r   Úcollections.abcr   Útypingr   Únumpyr!   Únumpy.typingrƒ   Úsupervisionr   rB   Ú!supervision.detection.utils.boxesr   r	   Úsupervision.draw.baser
   Úsupervision.draw.colorr   Úsupervision.draw.utilsr   Úsupervision.geometry.corer   Úsupervision.key_points.corer   Ú supervision.key_points.skeletonsr   Úsupervision.utils.conversionr   Úsupervision.utils.loggerr   r.   rX   r`   rD   r   Ú	ArrayLiker    r$   r&   r2   rM   rb   r®   rÈ   rÌ   ÚVertexEllipseAnnotatorrû   r+   r   r   ú<module>rG     s,  ðØ #Ð #Ð #Ð #Ð #Ð #Ð #Ð #Ø $Ð $Ð $Ð $Ð $Ð $Ø Ð Ð Ð Ð Ð à Ð Ð Ð Ø Ð Ð Ð Ð Ð à #Ð #Ð #Ð #Ð #Ð #Ø IÐ IÐ IÐ IÐ IÐ IÐ IÐ IØ +Ð +Ð +Ð +Ð +Ð +Ø (Ð (Ð (Ð (Ð (Ð (Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ø *Ð *Ð *Ð *Ð *Ð *Ø 1Ð 1Ð 1Ð 1Ð 1Ð 1Ø FÐ FÐ FÐ FÐ FÐ FØ JÐ JÐ JÐ JÐ JÐ JØ 0Ð 0Ð 0Ð 0Ð 0Ð 0à	ˆ�XÑ	Ô	€ð	&  s¨C x¤ð 	&Àð 	&ÈÈcÐSVÈhÌð 	&ð 	&ð 	&ð 	&ð
* 3¤=ð 
*°Tð 
*ð 
*ð 
*ð 
*ðð ð ð ð ˜Cñ ô ð ðPð Pð Pð Pð PÐ+ñ Pô Pð PðfXð Xð Xð Xð XÐ)ñ Xô Xð Xðvjð jð jð jð jÐ"7ñ jô jð jðZeð eð eð eð eÐ!<ñ eô eð eðPað að að að aÐ$?ñ aô að aðHDð Dð Dð Dð DÐ!<ñ Dô Dð DðN 4Ð ðR'ð R'ð R'ð R'ð R'ñ R'ô R'ð R'ð R'ð R'r   