
    3j                       S SK Jr  S SKJrJrJr  S SKrS SKJr  S SKJ	r	  S SK
Jr  S SKJr  SS	/rSS
 jrSSS jjrSS jr          SS jrSSS jjr              SS jr " S S5      r " S S\5      r " S S	5      rg)    )annotations)OptionalTuplecastN)Size)eye_like)validate_bbox)transform_pointsBoxesBoxes3Dc                    U [         R                  [         R                  [         R                  [         R                  [         R
                  4;   $ N)torchfloat16float32float64bfloat16half)dtypes    O/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/geometry/boxes.py_is_floating_point_dtyper       s/    U]]EMM5==%..RWR\R\]]]    c                   [        S U  5       5      (       d)  [        SU  Vs/ s H  o"R                  PM     sn S35      eUS:X  ah  [        S U  5       5      nU  Vs/ s H  o#UR                  S   -
  PM     nn[        R
                  R                  R                  R                  U SS9nXT4$ [        S	U S
35      es  snf s  snf )z&Merge a list of boxes into one tensor.c              3     #    U  HF  oR                   S S [        R                  " SS/5      :H  =(       a    UR                  5       S:H  v   MH     g7f)N         )shaper   r   dim.0boxs     r   	<genexpr>"_merge_box_list.<locals>.<genexpr>&   s>     XRW3yy~QF!33F	QFRWs   AAz5Input boxes must be a list of (N, 4, 2) shaped. Got: .padc              3  >   #    U  H  oR                   S    v   M     g7f)r   N)r   r!   s     r   r$   r%   *   s     2ESIIaLEs   r   T)batch_first`z` is not implemented.)
all	TypeErrorr   maxr   nnutilsrnnpad_sequenceNotImplementedError)boxesmethodr#   max_Nstatsoutputs         r   _merge_box_listr8   $   s    XRWXXXOfkPlfk_bQZQZfkPlOmmnopp2E22167#1%7##00D0I = "AfX-B"CDD Qm 8s   B>
Cc                   UR                  5       (       a  UOUR                  5       nU R                  SS u  p#nUS:X  a  U $ U R                  SX2-  U5      nUR                  S:X  a  UOUR                  S5      nUR                  S   UR                  S   :w  a,  [        SUR                  S    SUR                  S    S35      e[        X5      nUR                  U 5      nU$ )	am  Transform 3D and 2D in kornia format by applying the transformation matrix M.

Boxes and the transformation matrix could be batched or not.

Args:
    boxes: 2D quadrilaterals or 3D hexahedrons in kornia format.
    M: the transformation matrix of shape :math:`(3, 3)` or :math:`(B, 3, 3)` for 2D and :math:`(4, 4)` or
        :math:`(B, 4, 4)` for 3D hexahedron.

Nr   r   zBatch size mismatch. Got z for boxes and z for the transformation matrix.)	is_floating_pointfloatr   viewndim	unsqueeze
ValueErrorr
   view_as)r3   Mboxes_per_batchn_points_per_boxcoordinates_dimensionpointstransformed_boxess          r   _transform_boxesrI   3   s       ""	A @E{{23?O<O'<!ZZ,>@UVFVVq[akk!nA||A!''!*$'Q'8PQ
|Srs
 	
 '7q&A)11%8r   c                   U R                   UR                   s=:X  a(  UR                   s=:X  a  UR                   s=:X  a  S:X  d  O  [        S5      e[        R                  " U R                  S   U R                  S   SS4U R
                  U R                  S9nU R                  S5      US'   UR                  S5      US	'   US
==   US-
  -  ss'   US==   US-
  -  ss'   US==   US-
  -  ss'   US==   US-
  -  ss'   U$ )Nr   zXWe expect to create a batch of 2D boxes (quadrilaterals) in vertices format (B, N, 4, 2)r      r   devicer   r;   .r   .rK   .rK   r   .r   r   .r   rK   .r   rK   )r?   rA   r   zerosr   rM   r   r@   )xminyminwidthheightpolygonss        r   _boxes_to_polygonsrZ   Q   s     99		CUZZC6;;C!Cstt {{DJJqM4::a=!Q?[_[e[efH~~b)HV~~b)HVY519$Y519$Y6A:%Y6A:%Or   c                   UR                  5       nUR                  S5      (       ao  U R                  S:H  nSU R                  s=::  a  S::  a,  O  O)U R                  SS [        R
                  " SS/5      :X  d  [        SU SU R                   S	35      eO}UR                  S
5      (       aY  U R                  S:H  nSU R                  s=::  a  S::  a  O  OU R                  S   S:X  d  [        SU SU R                   S	35      eO[        SU 35      eU R                  5       (       a  U OU R                  5       n U(       a  U OU R                  S5      n UR                  S5      (       a  US:X  a;  U R                  5       nUSSS2S4   S-
  USSS2S4'   USSS2S4   S-
  USSS2S4'   O%US:X  a  U R                  5       nO[        SU 35      eU(       + =(       d    [        U5        OUR                  S
5      (       a  US:X  a  U S   U S   -
  U S   U S   -
  peO@US:X  a  U S   U S   -
  S-   U S   U S   -
  S-   peOUS:X  a
  U S   U S   peO[        SU 35      eU(       aF  US:*  R                  5       (       a  [        S5      eUS:*  R                  5       (       a  [        S5      eU S   U S   p[        XxXe5      nO[        SU 35      eU(       a  UnU$ UR                  S5      nU$ )z%Convert from boxes to quadrilaterals.verticesr   r   r   Nr   z3Boxes shape must be (N, 4, 2) or (B, N, 4, 2) when z mode. Got r&   xyr;   z-Boxes shape must be (N, 4) or (B, N, 4) when Unknown mode r   .rK   vertices_plusxyxy.r   rO   .r   rN   	xyxy_plusxywh%Some boxes have negative widths or 0.&Some boxes have negative heights or 0.)lower
startswithr?   r   r   r   rA   r<   r=   r@   cloner	   anyrZ   squeeze)	r3   modevalidate_boxesbatchedquadrilateralsrX   rW   rU   rV   s	            r   _boxes_to_quadrilateralsrp   c   s   ::<Dz""**/UZZ$1$RS)9UZZA=O)ORSWRXXcdidodocppqrss *P			**/UZZ$1$RA)=LTFR]^c^i^i]jjklmm *> =/00,,..EEKKMEE%//!"4Ez"":"[[]N +9ac1*E*IN3!Q;')7QR
)Ca)GN3A:&_$"[[]N}TF344;mN;			6>!&ME&M95=5QW=;XE[ !&ME&M9A=uV}uU[}?\_`?`EV^!&M5=E}TF344
!! !HII!  "" !IJJ6]E&Md+DF=/00'.^N 5C4J4J14MNr   c                   U R                   UR                   s=:X  aJ  UR                   s=:X  a9  UR                   s=:X  a(  UR                   s=:X  a  UR                   s=:X  a  S:X  d  O  [        S5      e[        R                  " U R                  S   U R                  S   SS4U R
                  U R                  S9nU R                  S5      US	'   UR                  S5      US
'   UR                  S5      US'   US==   US-
  -  ss'   US==   US-
  -  ss'   US==   US-
  -  ss'   US==   US-
  -  ss'   UR                  5       nUS==   UR                  S5      S-
  -  ss'   [        R                  " Xg/SS9nU$ )Nr   zUWe expect to create a batch of 3D boxes (hexahedrons) in vertices format (B, N, 8, 3)r   rK   r   r   rL   r;   rN   rO   rb   rP   rQ   rR   rS   r   r    )
r?   rA   r   rT   r   rM   r   r@   ri   cat)	rU   rV   zminrW   rX   depthfront_verticesback_vertices
polygons3ds	            r   _boxes3d_to_polygons3dry      sR    99		^TYY^%**^^uzz^]^^pqq [[$**Q-A1!EdkkaeakaklN!^^B/N6!^^B/N6!^^B/N69*9*9!+9!+ #((*M&U__R0144N:CJr   c                     \ rS rSrSr  S       S S jjrS!S jrS"S jr\S#S j5       r	S$S jr
S%S&S jjr S%       S'S	 jjrS(S
 jrS(S jr   S)       S*S jjrS+S,S jjr S)       S-S jjrS.S jr\ S/       S0S jj5       r S1     S2S jjrS3S jrS%S4S jjrS5S jrS6S7S jjr\S.S j5       r\S8S j5       r\S9S j5       r\S:S j5       rS;S<S jjrS=S jrS>S jr Sr!g)?r      a  2D boxes containing N or BxN boxes.

Args:
    boxes: 2D boxes, shape of :math:`(N, 4, 2)`, :math:`(B, N, 4, 2)` or a list of :math:`(N, 4, 2)`.
        See below for more details.
    raise_if_not_floating_point: flag to control floating point casting behaviour when `boxes` is not a
        floating point tensor. True to raise an error when `boxes` isn't a floating point tensor, False
        to cast to float.
    mode: the box format of the input boxes.

Note:
    **2D boxes format** is defined as a floating data type tensor of shape ``Nx4x2`` or ``BxNx4x2``
    where each box is a `quadrilateral <https://en.wikipedia.org/wiki/Quadrilateral>`_ defined by it's
    4 vertices coordinates (A, B, C, D). Coordinates must be in ``x, y`` order. The height and width of
    a box is defined as ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``. Examples of
    `quadrilaterals <https://en.wikipedia.org/wiki/Quadrilateral>`_ are rectangles, rhombus and trapezoids.

c                   S U l         [        U[        5      (       a  [        U5      u  ol         [        U[        R
                  5      (       d  [        S[        U5       S35      eUR                  5       (       d/  U(       a  [        SUR                   35      eUR                  5       n[        UR                  5      S:X  a  UR                  S5      nSUR                  s=::  a  S::  a  O  OUR                  SS  S	:X  d  [        S
UR                   S35      eUR                  S:X  a  SOSU l        Xl        X0l        g )N"Input boxes is not a Tensor. Got: r&   +Coordinates must be in floating point. Got r   )r;   r   r   r   r   )r   r   z3Boxes shape must be (N, 4, 2) or (B, N, 4, 2). Got FT)_N
isinstancelistr8   r   Tensorr,   typer<   rA   r   r=   lenr   reshaper?   _is_batched_data_modeselfr3   raise_if_not_floating_pointrl   s       r   __init__Boxes.__init__   s    (,eT"",U3NE7%..@eQOPP&&((* #Nu{{m!\]]KKMEu{{q MM'*EUZZ$1$RS)9V)CRSXS^S^R__`abb$)JJ!O5

r   c                f    [        U 5      " U R                  U   S5      nU R                  Ul        U$ NF)r   r   r   r   keynew_boxs      r   __getitem__Boxes.__getitem__   s*    t*TZZ_e4

r   c                8    UR                   U R                   U'   U $ r   r   r   r   values      r   __setitem__Boxes.__setitem__       ++

3r   c                .    U R                   R                  $ r   datar   r   s    r   r   Boxes.shape       yyr   c                j    [        [        R                  U R                  SSS95      nUS   US   p2X24$ )af  Compute boxes heights and widths.

Returns:
    - Boxes heights, shape of :math:`(N,)` or :math:`(B,N)`.
    - Boxes widths, shape of :math:`(N,)` or :math:`(B,N)`.

Example:
    >>> boxes_xyxy = torch.tensor([[[1,1,2,2],[1,1,3,2]]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy)
    >>> boxes.get_boxes_shape()
    (tensor([[1., 1.]]), tensor([[1., 2.]]))

rd   Tas_padded_sequencerb   ra   )r   r   r   	to_tensor)r   
boxes_xywhwidthsheightss       r   get_boxes_shapeBoxes.get_boxes_shape   s;     %,,vRV(WX
$V,j.@r   c                    [         R                  " U R                  UR                  /SS9nU(       a  X0l        U $ U R	                  5       nX4l        U$ )zMerge boxes.

Say, current instance holds :math:`(B, N, 4, 2)` and the incoming boxes holds :math:`(B, M, 4, 2)`,
the merge results in :math:`(B, N + M, 4, 2)`.

Args:
    boxes: 2D boxes.
    inplace: do transform in-place and return self.

rK   rr   )r   rs   r   r   ri   )r   r3   inplacer   objs        r   mergeBoxes.merge  sC     yy$**ejj1q9JKjjl	
r   c                $   U(       a  U R                   nOU R                   R                  5       n[        U[        5      (       a  UR	                  XR
                  5        OUR	                  X5        U(       a  U $ U R                  5       nXEl         U$ r   )r   ri   r   r   
index_put_r   )r   indicesvaluesr   r   r   s         r   	index_putBoxes.index_put"  sl     JJEJJ$$&Efe$$Wkk2W-Kjjl	
r   c                   [        UR                  5      S:X  a  UR                  S5      S:X  d  [        SUR                   S35      eU R                  S==   USSSS24   R                  U R                  R                  S	9-  ss'   U R                  S
==   USSSS24   R                  U R                  R                  S	9-  ss'   U $ z5Pad a bounding box.

Args:
    padding_size: (B, 4)

r   rK   r   z%Expected padding_size as (B, 4). Got r&   rN   .NrM   rO   r   r   r   sizeRuntimeErrorr   torM   r   padding_sizes     r   r'   	Boxes.pad9       L&&'1,1B1B11E1J!F|GYGYFZZ[\]]

6l3bqb=9<<DJJDUDU<VV

6l3ac>:==TZZEVEV=WWr   c                   [        UR                  5      S:X  a  UR                  S5      S:X  d  [        SUR                   S35      eU R                  S==   USSSS24   R                  U R                  R                  S	9-  ss'   U R                  S
==   USSSS24   R                  U R                  R                  S	9-  ss'   U $ r   r   r   s     r   unpadBoxes.unpadF  r   r   Nc                8   [        U[        R                  5      (       a  [        U[        R                  5      (       d  [        eU(       a  U R                  nOU R                  R                  5       nUS S 2S S S24   R                  SUR                  S5      S5      nXTS   U:     US   US   U:  '   US S 2S SS 24   R                  SUR                  S5      S5      nXdS   U:     US   US   U:  '   US S 2S S S24   R                  SUR                  S5      S5      nXtS   U:     US   US   U:  '   US S 2S SS 24   R                  SUR                  S5      S5      nXS   U:     US   US   U:  '   U(       a  U $ U R                  5       n	XIl        U	$ )NrK   r   rN   rO   )r   r   r   r2   r   ri   repeatr   )
r   topleftbotrightr   r   	topleft_x	topleft_y
botright_x
botright_yr   s
             r   clampBoxes.clampS  s    7ELL11j5<<6X6X%%JJEJJ$$&EAtRaRK(//5::a=!D	3<6]Y=V3WfeFmi/0AtQRK(//5::a=!D	3<6]Y=V3WfeFmi/0arrk*11!UZZ]AF
4>V}z?Y4ZfeFmj01aqrk*11!UZZ]AF
4>V}z?Y4ZfeFmj01Kjjl	
r   c                    [         e)a  Trim out zero padded boxes.

Given box arrangements of shape :math:`(4, 4, Box)`:

    == === == === == === == === ==
    -- Box -- Box -- Box -- Box --
    --  0  --  0  -- Box -- Box --
    --  0  -- Box --  0  --  0  --
    --  0  --  0  --  0  --  0  --
    == === == === == === == === ==

Nothing will change if correspondence_preserve is True. Only pure zero layers will be removed, resulting in
shape :math:`(4, 3, Box)`:

    == === == === == === == === ==
    -- Box -- Box -- Box -- Box --
    --  0  --  0  -- Box -- Box --
    --  0  -- Box --  0  --  0  --
    == === == === == === == === ==

Otherwise, you will get :math:`(4, 2, Box)`:

    == === == === == === == === ==
    -- Box -- Box -- Box -- Box --
    --  0  -- Box -- Box -- Box --
    == === == === == === == === ==
)r2   )r   correspondence_preserver   s      r   trim
Boxes.trimq  s
    8 "!r   c                    U R                  5       nU(       a  U R                  nOU R                  R                  5       nUb  SXTU:  '   Ub  SXTU:  '   U(       a  U $ U R                  5       nXVl        U$ )Ng        )compute_arear   ri   )r   min_areamax_arear   arear   r   s          r   filter_boxes_by_areaBoxes.filter_boxes_by_area  sq       "JJEJJ$$&E%(E/"%(E/"Kjjl	
r   c                   U R                   R                  S:X  a  U R                   R                  S5      OU R                   nUR                  SSS9n[        R
                  " US   US   -
  US   US   -
  5      n[        R                  " USSS9u  pE[        R                  " USUR                  S	5      R                  S	S	S
5      5      nUS   US   pS[        R                  " [        R                  " U[        R                  " USS5      -  U[        R                  " USS5      -  -
  SS95      -  n	U R                   R                  S:X  a(  U	R                  U R                   R                  SS
 5      $ U	$ )zReturn :math:`(B, N)`.r   )r;   r   r   rK   T)r    keepdimrO   rN   )r    
descendingr;   r   g      ?rr   N)r   r?   r>   meanr   atan2sortgatherr@   expandabssumrollr   )
r   coordscentroidangles_clockwise_indicesordered_cornersxyr   s
             r   r   Boxes.compute_area  s>   04

10D,$**;;1d;3VF^hv.>>vQYZ`Qa@ab$zz&aDI,,vq2C2M2Mb2Q2X2XY[]_ab2cdv&(?1UYYuyy!ejjAq.A*Aa%**UVXY[\J]F])^defgg26**//Q2Ftyy))"1-.PDPr   c                    [        U[        R                  5      (       a  [        XUS9nOU Vs/ s H  n[        XRU5      PM     nnU " USU5      $ s  snf )a  Create :class:`Boxes` from boxes stored in another format.

Args:
    boxes: 2D boxes, shape of :math:`(N, 4)`, :math:`(B, N, 4)`, :math:`(N, 4, 2)` or :math:`(B, N, 4, 2)`.
    mode: The format in which the boxes are provided.
    validate_boxes: Check if boxes are valid. Default is True.

        * 'xyxy': boxes are assumed to be in the format ``xmin, ymin, xmax, ymax`` where ``width = xmax - xmin``
          and ``height = ymax - ymin``. With shape :math:`(N, 4)`, :math:`(B, N, 4)`.
        * 'xyxy_plus': similar to 'xyxy' mode but where box width and length are defined as
          ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``.
          With shape :math:`(N, 4)`, :math:`(B, N, 4)`.
        * 'xywh': boxes are assumed to be in the format ``xmin, ymin, width, height`` where
          ``width = xmax - xmin`` and ``height = ymax - ymin``. With shape :math:`(N, 4)`, :math:`(B, N, 4)`.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *top-left, top-right, bottom-right, bottom-left*. Vertices coordinates are in (x,y) order. Finally,
          box width and height are defined as ``width = xmax - xmin`` and ``height = ymax - ymin``.
          With shape :math:`(N, 4, 2)` or :math:`(B, N, 4, 2)`.
        * 'vertices_plus': similar to 'vertices' mode but where box width and length are defined as
          ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``. ymin + 1``.
          With shape :math:`(N, 4, 2)` or :math:`(B, N, 4, 2)`.

    validate_boxes: check if boxes are valid rectangles or not. Valid rectangles are those with width
        and height >= 1 (>= 2 when mode ends with '_plus' suffix).

Returns:
    :class:`Boxes` class containing the original `boxes` in the format specified by ``mode``.

Examples:
    >>> boxes_xyxy = torch.as_tensor([[0, 3, 1, 4], [5, 1, 8, 4]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy, mode='xyxy')
    >>> boxes.data  # (2, 4, 2)
    tensor([[[0., 3.],
             [0., 3.],
             [0., 3.],
             [0., 3.]],
    <BLANKLINE>
            [[5., 1.],
             [7., 1.],
             [7., 3.],
             [5., 3.]]])

rl   rm   F)r   r   r   rp   )clsr3   rl   rm   ro   r#   s         r   from_tensorBoxes.from_tensor  sW    ` eU\\**5eWefN]bc]bVY6s.Q]bNc>5$// ds   Ac           
        U R                   (       a  U R                  OU R                  R                  S5      n[        R                  " UR                  SS9UR                  SS9/SS9R                  UR                  S   UR                  S   S5      nUc  U R                  nUR                  5       nUS;   a  O8US;   a$  US   US	   -
  S-   US
   US   -
  S-   peXdS
'   XTS'   O[        SU 35      eUS;   a0  [        R                  " / SQUR                  UR                  S9nXG-   nUR                  S5      (       a  [!        US   US	   US
   US   5      nU R"                  b{  U(       dt  [%        X@R"                  5       VV	s/ s HP  u  p[        R&                  R(                  R+                  U[-        UR                  5      S-
  SS/-  SU	* /-   5      PMR     nnn	U$ U R                   (       a  UOUR/                  S5      nU$ s  sn	nf )a  Cast :class:`Boxes` to a tensor.

``mode`` controls which 2D boxes format should be use to represent boxes in the tensor.

Args:
    mode: the output box format. It could be:

        * 'xyxy': boxes are defined as ``xmin, ymin, xmax, ymax`` where ``width = xmax - xmin`` and
          ``height = ymax - ymin``.
        * 'xyxy_plus': similar to 'xyxy' mode but where box width and length are defined as
          ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``.
        * 'xywh': boxes are defined as ``xmin, ymin, width, height`` where ``width = xmax - xmin``
          and ``height = ymax - ymin``.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *top-left, top-right, bottom-right, bottom-left*. Vertices coordinates are in (x,y) order. Finally,
          box width and height are defined as ``width = xmax - xmin`` and ``height = ymax - ymin``.
        * 'vertices_plus': similar to 'vertices' mode but where box width and length are defined as
          ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``. ymin + 1``.
    as_padded_sequence: whether to keep the pads for a list of boxes. This parameter is only valid
        if the boxes are from a box list whilst `from_tensor`.

Returns:
    Boxes tensor in the ``mode`` format. The shape depends with the ``mode`` value:

        * 'vertices' or 'verticies_plus': :math:`(N, 4, 2)` or :math:`(B, N, 4, 2)`.
        * Any other value: :math:`(N, 4)` or :math:`(B, N, 4)`.

Examples:
    >>> boxes_xyxy = torch.as_tensor([[0, 3, 1, 4], [5, 1, 8, 4]])
    >>> boxes = Boxes.from_tensor(boxes_xyxy)
    >>> assert (boxes_xyxy == boxes.to_tensor(mode='xyxy')).all()

r   r   rr   rK   r   )r`   rc   )rd   r\   r_   ra   rO   rb   rN   r^   )r`   r\   )r   r   rK   rK   rL   r\   )r   r   r@   r   stackaminamaxr>   r   rl   rg   rA   	as_tensorrM   r   rh   rZ   r   zipr.   
functionalr'   r   rk   )
r   rl   r   batched_boxesr3   rX   rW   offsetons
             r   r   Boxes.to_tensor  s   H '+&6&6

DJJ<P<PQR<S
 ]//B/79K9KPR9K9STZ\]bb"M$7$7$:A
 <99Dzz|((::!&ME&M9A=uV}uU[}?\_`?`E!&M"&M}TF344''__\%,,ekkZFNE??:&&&uV}eFmU6]TYZ`TabE77'9cfglnunucvwcv[_[\UXX((,,QQWW1AaV0KqSTRTg0UVcvEw  "--E5==3CE xs   AHc                n   U R                   R                  (       a  [        S5      eU R                  nU R                  nU R
                  nUR                  S:w  Gau  U R                  (       a\  [        R                  " U R                   R                  S   U R                   R                  S   X4U R                  U R
                  S9nOC[        R                  " U R                   R                  S   X4U R                  U R
                  S9n[        [        R                  U R                  SSS95      nUS	S
S
S24   R                  SU5        US	SS
S24   R                  SU5        [        UR                  SX5      UR                  SS5      R!                  5       R#                  5       5       H  u  pSXS   U	S   2U	S   U	S   24'   M     U$ U(       a   U R                  S   U R                  S   X4n
OU R                  S   X4n
[        [        R                  U R                  SSS95      nUS	S
S
S24   R                  SU5        US	SS
S24   R                  SU5        UR                  SS5      R!                  5       R%                  5       nUS
S
2S4   US
S
2S4   US
S
2S4   US
S
2S4   4u  ppUR'                  SU5      nUR'                  SU5      nUR'                  SU5      nUR'                  SU5      n[        R(                  " XS9n[        R(                  " X%S9nUS
S
S
24   US
S
2S
4   :  US
S
S
24   US
S
2S
4   :  -  nUS
S
S
24   US
S
2S
4   :  US
S
S
24   US
S
2S
4   :  -  nUR+                  S5      UR+                  S5      -  R-                  U5      nUR                  " U
6 $ )a?  Convert 2D boxes to masks. Covered area is 1 and the remaining is 0.

Args:
    height: height of the masked image/images.
    width: width of the masked image/images.

Returns:
    the output mask tensor, shape of :math:`(N, width, height)` or :math:`(B,N, width, height)` and dtype of
    :func:`Boxes.dtype` (it can be any floating point dtype).

Note:
    It is currently non-differentiable.

Examples:
    >>> boxes = Boxes(torch.tensor([[  # Equivalent to boxes = Boxes.from_tensor([[1,1,4,3]])
    ...        [1., 1.],
    ...        [4., 1.],
    ...        [4., 3.],
    ...        [1., 3.],
    ...   ]]))  # 1x4x2
    >>> boxes.to_mask(5, 5)
    tensor([[[0., 0., 0., 0., 0.],
             [0., 1., 1., 1., 1.],
             [0., 1., 1., 1., 1.],
             [0., 1., 1., 1., 1.],
             [0., 0., 0., 0., 0.]]])

cBoxes.to_tensor isn't differentiable. Please, create boxes from tensors with `requires_grad=False`.cudar   rK   r   rM   r`   Tr   .Nr   r;   r   r   r   )r   requires_gradr   r   r   rM   r   r   rT   r   r   r   r   clamp_r   r>   roundintlongr   aranger@   r   )r   rX   rW   
is_batchedr   rM   maskclipped_boxes_xyxymask_channelbox_xyxy	out_shaper`   x1y1x2y2ysxsy_maskx_maskmaskss                        r   to_maskBoxes.to_mask1  s   : ::##u  %%



 ;;& {{ZZ%%a($***:*:1*=vMUYU_U_hlhshs {{DJJ$4$4Q$7#Gtzzbfbmbmn "&ellDNN6^bN4c!dsCaCx(//59sADqDy)00F; +.		"f,.@.E.Eb!.L.R.R.T.X.X.Z+& VWa[8A;6hqk8QQR	+ K A

1vEIA6I!%,,vZ^0_`3!8$++Au5319%,,Q7!&&r1-335::<adT!Q$ZadT!Q$ZGXXaXXaXXa XXa \\&0\\%/T1W+AtG,D!Gr!T'{1JKT1W+AtG,D!Gr!T'{1JK!!!$v'7'7'::>>uEzz9%%r   c                   SUR                   s=::  a  S::  a  O  OUR                  SS S:w  a  [        SUR                   S35      e[        U R                  U5      nU(       a  X0l        U $ U R                  5       nX4l        U$ )zApply a transformation matrix to the 2D boxes.

Args:
    M: The transformation matrix to be applied, shape of :math:`(3, 3)` or :math:`(B, 3, 3)`.
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes.

r   r   r   N)r   r   zAThe transformation matrix shape must be (3, 3) or (B, 3, 3). Got r&   )r?   r   rA   rI   r   ri   )r   rC   r   rH   r   s        r   transform_boxesBoxes.transform_boxes  sw     AFFa17723<6#9`abahah`iijkll,TZZ;*JKjjl%	
r   c                "    U R                  USS9$ )z1Inplace version of :func:`Boxes.transform_boxes`.Tr   r  r   rC   s     r   transform_boxes_Boxes.transform_boxes_      ##At#44r   c                    US:X  a  [         eUS:X  a  O[         e[        SU5      nXSS2SS2S4'   U R                  XCS9$ )zTranslate boxes by the provided size.

Args:
    size: translate size for x, y direction, shape of :math:`(B, 2)`.
    method: "warp" or "fast".
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes.

fastwarpr   Nr   r  )r2   r   r  )r   r   r4   r   rC   s        r   	translateBoxes.translate  sT     V%%v%%"1d+!RaR(##A#77r   c                    U R                   $ r   r   r   s    r   r   
Boxes.data      zzr   c                    U R                   $ r   r   r   s    r   rl   
Boxes.mode  r*  r   c                .    U R                   R                  $ zReturns boxes device.r   rM   r   s    r   rM   Boxes.device       zz   r   c                .    U R                   R                  $ zReturns boxes dtype.r   r   r   s    r   r   Boxes.dtype       zzr   c                ~    Ub  [        U5      (       d  [        S5      eU R                  R                  XS9U l        U $ z)Like :func:`torch.nn.Module.to()` method.zBoxes must be in floating pointrL   r   rA   r   r   r   rM   r   s      r   r   Boxes.to  <     %=e%D%D>??ZZ]]&]>
r   c                    [        U 5      " U R                  R                  5       S5      nU R                  Ul        U R                  Ul        U R
                  Ul        U$ r   )r   r   ri   r   r   r   r   r   s     r   ri   Boxes.clone  sG    4j))+U3JJ	**
r   c                F    U R                   R                  U5      U l         U $ r   )r   r   )r   r   s     r   r   
Boxes.type  s    ZZ__U+
r   )r   r   r   r   )Tr_   )r3   !torch.Tensor | list[torch.Tensor]r   boolrl   strreturnNone)r   slice | int | torch.TensorrF  r   )r   rH  r   r   rF  r   rF  ztuple[int, ...] | Size)rF  z!tuple[torch.Tensor, torch.Tensor]F)r3   r   r   rD  rF  r   )r   z-tuple[torch.Tensor, ...] | list[torch.Tensor]r   ztorch.Tensor | Boxesr   rD  rF  r   )r   torch.TensorrF  r   )NNF)r   (Optional[torch.Tensor | tuple[int, int]]r   rL  r   rD  rF  r   )FF)r   rD  r   rD  rF  r   )r   Optional[float]r   rM  r   rD  rF  r   rF  rK  r`   T)r3   rC  rl   rE  rm   rD  rF  r   r   )rl   Optional[str]r   rD  rF  rC  )rX   r  rW   r  rF  rK  )rC   rK  r   rD  rF  r   )rC   rK  rF  r   )r%  F)r   rK  r4   rE  r   rD  rF  r   rF  rE  rF  ztorch.devicerF  torch.dtypeNN)rM   Optional[torch.device]r   Optional[torch.dtype]rF  r   )rF  r   )r   rT  rF  r   )"__name__
__module____qualname____firstlineno____doc__r   r   r   propertyr   r   r   r   r'   r   r   r   r   r   classmethodr   r   r  r  r   r&  r   rl   rM   r   r   ri   r   __static_attributes__ r   r   r   r      s   , -1#	0 &* 	
 
>
  $0 	> % 	
 
. =A=A	9 ; 	
 
<"> ch':I[_	&Q  bf40540=@40[_40	40 40n FKF!F>BF	*FP\&|.58.     ! !    r   c                  j   ^  \ rS rSr% S\S'   \ S     S	S jj5       rS
SU 4S jjjrSS jrSr	U =r
$ )
VideoBoxesi  r  temporal_channel_sizec           
        [        U[        45      (       d=  UR                  5       S:w  d)  UR                  SS  [        R
                  " SS/5      :w  a  [        S5      eUR                  S5      n[        UR                  UR                  S5      UR                  S5      -  SUR                  S	5      UR                  S5      5      S
US9nU " USS
5      nX5l
        U$ )N   r   r   r   zQInput box type is not yet supported. Please input an `BxTxNx4x2` tensor directly.rK   r   r;   r   r_   r   F)r   r   r    r   r   r   rA   r   rp   r>   rc  )r   r3   rm   rc  ro   outs         r   r   VideoBoxes.from_tensor  s     edW%%%))+*:ekk"#>NRWR\R\^_ab]cRd>dpqq %

11JJuzz!}uzz!}4b%**Q-TUW )

 .%9$9!
r   c           	     4  > [         TU ]  USS9n[        U[        R                  5      (       a+  UR
                  " SU R                  /UR                  SS  Q76 $ U Vs/ s H-  o3R
                  " SU R                  /UR                  SS  Q76 PM/     sn$ s  snf )NFr   r;   rK   )superr   r   r   r   r>   rc  r   )r   rl   rf  _out	__class__s       r   r   VideoBoxes.to_tensor  s    g?c5<<((88B : :KSYYqr]KKWZ[WZt		"d88J4::ab>JWZ[[[s   4Bc                    [        U 5      " U R                  R                  5       S5      nU R                  Ul        U R                  Ul        U R
                  Ul        U R                  Ul        U$ r   )r   r   ri   r   r   r   rc  r?  s     r   ri   VideoBoxes.clone  sU    4j))+U3JJ	**$($>$>!
r   r`  )T)r3   rC  rm   rD  rF  rb  r   )rl   rP  rF  rC  )rF  rb  )rX  rY  rZ  r[  __annotations__r^  r   r   ri   r_  __classcell__)rk  s   @r   rb  rb    sL    NR5GK	 "\ \ r   rb  c                     \ rS rSrSr S       SS jjrSS jrSS jr\SS j5       r	SS jr
\SSS jj5       rSSS	 jjrSS
 jrSS S jjrS!S jr\S"S j5       r\S#S j5       r\S$S j5       r\S%S j5       rS&S'S jjrSrg)(r   i  ay  3D boxes containing N or BxN boxes.

Args:
    boxes: 3D boxes, shape of :math:`(N,8,3)` or :math:`(B,N,8,3)`. See below for more details.
    raise_if_not_floating_point: flag to control floating point casting behaviour when `boxes` is not a floating
        point tensor. True to raise an error when `boxes` isn't a floating point tensor, False to cast to float.

Note:
    **3D boxes format** is defined as a floating data type tensor of shape ``Nx8x3`` or ``BxNx8x3`` where each box
    is a `hexahedron <https://en.wikipedia.org/wiki/Hexahedron>`_ defined by it's 8 vertices coordinates.
    Coordinates must be in ``x, y, z`` order. The height, width and depth of a box is defined as
    ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``. Examples of
    `hexahedrons <https://en.wikipedia.org/wiki/Hexahedron>`_ are cubes and rhombohedrons.

c                &   [        U[        R                  5      (       d  [        S[	        U5       S35      eUR                  5       (       d0  U(       a  [        SUR                   S35      eUR                  5       n[        UR                  5      S:X  a  UR                  S5      nSUR                  s=::  a  S::  a  O  OUR                  SS  S	:X  d  [        S
UR                   S35      eUR                  S:X  a  SOSU l        Xl        X0l        g )Nr}   r&   r~   r   )r;      r   r   r   )   r   z53D bbox shape must be (N, 8, 3) or (B, N, 8, 3). Got FT)r   r   r   r,   r   r<   rA   r   r=   r   r   r   r?   r   r   r   r   s       r   r   Boxes3D.__init__  s     %..@eQOPP&&((* #Nu{{m[\!]^^KKMEu{{q MM'*EUZZ$1$RS)9V)CTUZU`U`Taabcdd$)JJ!O5

r   c                X    [        U R                  U   SSS9nU R                  Ul        U$ )NFxyzxyz_plusrl   )r   r   r   r   s      r   r   Boxes3D.__getitem__4  s(    $**S/5}E

r   c                8    UR                   U R                   U'   U $ r   r   r   s      r   r   Boxes3D.__setitem__9  r   r   c                .    U R                   R                  $ r   r   r   s    r   r   Boxes3D.shape=  r   r   c                D    U R                  SS9nUS   US   US   pCnXCU4$ )a  Compute boxes heights and widths.

Returns:
    - Boxes depths, shape of :math:`(N,)` or :math:`(B,N)`.
    - Boxes heights, shape of :math:`(N,)` or :math:`(B,N)`.
    - Boxes widths, shape of :math:`(N,)` or :math:`(B,N)`.

Example:
    >>> boxes_xyzxyz = torch.tensor([[ 0,  1,  2, 10, 21, 32], [3, 4, 5, 43, 54, 65]])
    >>> boxes3d = Boxes3D.from_tensor(boxes_xyzxyz)
    >>> boxes3d.get_boxes_shape()
    (tensor([30., 60.]), tensor([20., 50.]), tensor([10., 40.]))

xyzwhdrx  ra   .r   .re  )r   )r   boxes_xyzwhdr   r   depthss        r   r   Boxes3D.get_boxes_shapeA  s:     ~~8~4".v"6V8Ll[aNb&&r   c                   SUR                   s=::  a  S::  a  O  OUR                  S   S:X  d  [        SUR                   S35      eUR                   S:H  nU(       a  UOUR                  S5      nUR	                  5       (       a  UOUR                  5       nUS   US	   US
   pvnUR                  5       nUS:X  a"  US   US   -
  nUS   US	   -
  n	US   US
   -
  n
OTUS:X  a+  US   US   -
  S-   nUS   US	   -
  S-   n	US   US
   -
  S-   n
O#US:X  a  US   US   US   pn
O[        SU 35      eU(       ai  US:*  R                  5       (       a  [        S5      eU	S:*  R                  5       (       a  [        S5      eU
S:*  R                  5       (       a  [        S5      e[        XVXxX5      nU(       a  UOUR                  S5      nU " USUS9$ )a  Create :class:`Boxes3D` from 3D boxes stored in another format.

Args:
    boxes: 3D boxes, shape of :math:`(N,6)` or :math:`(B,N,6)`.
    mode: The format in which the 3D boxes are provided.

        * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
          ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
        * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.

    validate_boxes: check if boxes are valid rectangles or not. Valid rectangles are those with width, height
        and depth >= 1 (>= 2 when mode ends with '_plus' suffix).

Returns:
    :class:`Boxes3D` class containing the original `boxes` in the format specified by ``mode``.

Examples:
    >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
    >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
    >>> boxes.data  # (2, 8, 3)
    tensor([[[0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 6.],
             [0., 3., 7.],
             [0., 3., 7.],
             [0., 3., 7.],
             [0., 3., 7.]],
    <BLANKLINE>
            [[5., 1., 3.],
             [7., 1., 3.],
             [7., 3., 3.],
             [5., 3., 3.],
             [5., 1., 8.],
             [7., 1., 8.],
             [7., 3., 8.],
             [5., 3., 8.]]])

r   r   r;   rs  z,BBox shape must be (N, 6) or (B, N, 6). Got r&   r   rN   rO   rb   xyzxyzra   r  r  rw  rK   r  r^   re   rf   z%Some boxes have negative depths or 0.F)r   rl   )
r?   r   rA   r@   r<   r=   rg   rj   ry   rk   )r   r3   rl   rm   rn   rU   rV   rt   rW   rX   ru   hexahedronss               r   r   Boxes3D.from_tensorT  s   X UZZ$1$RA)=KEKK=XYZ[[**/ eooa&80022 =%-vDzz|8&ME&M1E6]U6]2F&ME&M1E]"&ME&M1A5E6]U6]2Q6F&ME&M1A5EX#(=%-v5E5}TF344
!! !HII!  "" !IJJ
!! !HII,TfT%,k+2E2Ea2H;EMMr   c                t   U R                   R                  (       a  [        S5      eU R                  (       a  U R                   OU R                   R	                  S5      n[
        R                  " UR                  SS9UR                  SS9/SS9R                  UR                  S   UR                  S   S5      nUR                  5       nUS;   a  OKUS;   a7  US	   US
   -
  S-   nUS   US   -
  S-   nUS   US   -
  S-   nXCS	'   XSS'   XcS'   O[        SU 35      eUS;   a0  [
        R                  " / SQUR                  UR                  S9nX7-   nUR!                  S5      (       a)  US
   US   US   pnUS	   US   US   pen[#        XXXV5      nU R                  (       a  UnU$ UR%                  S5      nU$ )a  Cast :class:`Boxes3D` to a tensor.

``mode`` controls which 3D boxes format should be use to represent boxes in the tensor.

Args:
    mode: The format in which the boxes are provided.

        * 'xyzxyz': boxes are assumed to be in the format ``xmin, ymin, zmin, xmax, ymax, zmax`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'xyzxyz_plus': similar to 'xyzxyz' mode but where box width, length and depth are defined as
           ``width = xmax - xmin + 1``, ``height = ymax - ymin + 1`` and ``depth = zmax - zmin + 1``.
        * 'xyzwhd': boxes are assumed to be in the format ``xmin, ymin, zmin, width, height, depth`` where
          ``width = xmax - xmin``, ``height = ymax - ymin`` and ``depth = zmax - zmin``.
        * 'vertices': boxes are defined by their vertices points in the following ``clockwise`` order:
          *front-top-left, front-top-right, front-bottom-right, front-bottom-left, back-top-left,
          back-top-right, back-bottom-right,  back-bottom-left*. Vertices coordinates are in (x,y, z) order.
          Finally, box width, height and depth are defined as ``width = xmax - xmin``, ``height = ymax - ymin``
          and ``depth = zmax - zmin``.
        * 'vertices_plus': similar to 'vertices' mode but where box width, length and depth are defined as
          ``width = xmax - xmin + 1`` and ``height = ymax - ymin + 1``.

Returns:
    3D Boxes tensor in the ``mode`` format. The shape depends with the ``mode`` value:

        * 'vertices' or 'verticies_plus': :math:`(N, 8, 3)` or :math:`(B, N, 8, 3)`.
        * Any other value: :math:`(N, 6)` or :math:`(B, N, 6)`.

Note:
    It is currently non-differentiable due to a bug. See github issue
    `#1304 <https://github.com/kornia/kornia/issues/1396>`_.

Examples:
    >>> boxes_xyzxyz = torch.as_tensor([[0, 3, 6, 1, 4, 8], [5, 1, 3, 8, 4, 9]])
    >>> boxes = Boxes3D.from_tensor(boxes_xyzxyz, mode='xyzxyz')
    >>> assert (boxes.to_tensor(mode='xyzxyz') == boxes_xyzxyz).all()

a  Boxes3D.to_tensor doesn't support computing gradients since they aren't accurate. Please, create boxes from tensors with `requires_grad=False`. This is a known bug. Help is needed to fix it. For more information, see https://github.com/kornia/kornia/issues/1396.r   r   rr   rK   rs  )r  rw  )r  r\   r_   ra   rN   r  rO   r  rb   r^   )r  r\   )r   r   r   rK   rK   rK   rL   r\   )r   r  r   r   r@   r   r   r   r   r>   r   rg   rA   r   rM   r   rh   ry   rk   )r   rl   r   r3   rW   rX   ru   r   rU   rV   rt   s              r   r   Boxes3D.to_tensor  s   L ::##D  '+&6&6

DJJ<P<PQR<S ]//B/79K9KPR9K9STZ\]bb"M$7$7$:A
 zz|,,<<&ME&M1A5E6]U6]2Q6F&ME&M1A5E!&M"&M!&M}TF344))__%7TYT_T_`FNE??:&&$V}eFmU6]D#(=%-v5E*4tFRE)) 05}}Q/?r   c                   U R                   R                  (       a  [        S5      eU R                  (       aq  [        R
                  " U R                   R                  S   U R                   R                  S   XU4U R                   R                  U R                   R                  S9nOX[        R
                  " U R                   R                  S   XU4U R                   R                  U R                   R                  S9nU R                  S5      nUSSSS24   R                  SU5        USSSS24   R                  SU5        USS	SS24   R                  SU5        [        UR                  S
XU5      UR                  S
S5      R                  5       R                  5       5       H%  u  pgSUUS	   US   2US   US   2US   US   24'   M'     U$ )uH  Convert ·D boxes to masks. Covered area is 1 and the remaining is 0.

Args:
    depth: depth of the masked image/images.
    height: height of the masked image/images.
    width: width of the masked image/images.

Returns:
    the output mask tensor, shape of :math:`(N, depth, width, height)` or :math:`(B,N, depth, width, height)`
     and dtype of :func:`Boxes3D.dtype` (it can be any floating point dtype).

Note:
    It is currently non-differentiable.

Examples:
    >>> boxes = Boxes3D(torch.tensor([[  # Equivalent to boxes = Boxes.3Dfrom_tensor([[1,1,1,3,3,2]])
    ...     [1., 1., 1.],
    ...     [3., 1., 1.],
    ...     [3., 3., 1.],
    ...     [1., 3., 1.],
    ...     [1., 1., 2.],
    ...     [3., 1., 2.],
    ...     [3., 3., 2.],
    ...     [1., 3., 2.],
    ... ]]))  # 1x8x3
    >>> boxes.to_mask(4, 5, 5)
    tensor([[[[0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 1., 1., 1., 0.],
              [0., 0., 0., 0., 0.]],
    <BLANKLINE>
             [[0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.],
              [0., 0., 0., 0., 0.]]]])

r   r   rK   r  r  .Nr   r   r;   rs  re  r   )r   r  r   r   r   rT   r   r   rM   r   r  r   r>   r  r  )r   ru   rX   rW   r	  clipped_boxes_xyzxyzr  
box_xyzxyzs           r   r  Boxes3D.to_mask  s   h ::##u  ;;!!!$djj&6&6q&95%Pjj&&zz((D ;;!!!$eU;4::CSCS\`\f\f\m\mD
  $~~h7S#A#X&--a7S!$Q$Y'..q&9S!$Q$Y'..q%8 ),IIb%/1E1J1J2q1Q1W1W1Y1]1]1_)
$L  1
1-z!}z!}/LjYZm^hij^kNkk	)
 r   c                    SUR                   s=::  a  S::  a  O  OUR                  SS S:w  a  [        SUR                   S35      e[        U R                  U5      nU(       a  X0l        U $ [        USS	5      $ )
zApply a transformation matrix to the 3D boxes.

Args:
    M: The transformation matrix to be applied, shape of :math:`(4, 4)` or :math:`(B, 4, 4)`.
    inplace: do transform in-place and return self.

Returns:
    The transformed boxes.

r   r   r   N)r   r   zAThe transformation matrix shape must be (4, 4) or (B, 4, 4). Got r&   Frw  )r?   r   rA   rI   r   r   )r   rC   r   rH   s       r   r  Boxes3D.transform_boxesG  sr     AFFa17723<6#9`abahah`iijkll,TZZ;*JK(%??r   c                "    U R                  USS9$ )z3Inplace version of :func:`Boxes3D.transform_boxes`.Tr  r  r  s     r   r   Boxes3D.transform_boxes_\  r"  r   c                    U R                   $ r   r   r   s    r   r   Boxes3D.data`  r*  r   c                    U R                   $ r   r,  r   s    r   rl   Boxes3D.moded  r*  r   c                .    U R                   R                  $ r/  r0  r   s    r   rM   Boxes3D.deviceh  r2  r   c                .    U R                   R                  $ r4  r5  r   s    r   r   Boxes3D.dtypem  r7  r   Nc                ~    Ub  [        U5      (       d  [        S5      eU R                  R                  XS9U l        U $ r9  r:  r;  s      r   r   
Boxes3D.tor  r=  r   )r   r   r   )Trw  )r3   rK  r   rD  rl   rE  rF  rG  )r   rH  rF  r   )r   rH  r   r   rF  r   rI  )rF  z/tuple[torch.Tensor, torch.Tensor, torch.Tensor])r  T)r3   rK  rl   rE  rm   rD  rF  r   )r  )rl   rE  rF  rK  )ru   r  rX   r  rW   r  rF  rK  rJ  )rC   rK  r   rD  rF  r   )rC   rK  rF  r   rN  rQ  rR  rS  rU  )rM   rV  r   rW  rF  r   )rX  rY  rZ  r[  r\  r   r   r   r]  r   r   r^  r   r   r  r  r   r   rl   rM   r   r   r_  r`  r   r   r   r     s    " Zg!@DSV	.
  '& KN KNZM^Tl@*5     ! !     r   )r   rT  rF  rD  )r'   )r3   zlist[torch.Tensor]r4   rE  rF  ztuple[torch.Tensor, list[int]])r3   rK  rC   rK  rF  rK  )
rU   rK  rV   rK  rW   rK  rX   rK  rF  rK  rO  )r3   rK  rl   rE  rm   rD  rF  rK  )rU   rK  rV   rK  rt   rK  rW   rK  rX   rK  ru   rK  rF  rK  )
__future__r   typingr   r   r   r   r   kornia.core.opsr   kornia.geometry.bboxr	   kornia.geometry.linalgr
   __all__r   r8   rI   rZ   rp   ry   r   rb  r   r`  r   r   <module>r     s   $ # ( (   $ . 3I
^<
*3?IU$7t

  	
   >h hV" "Jl lr   