+
    åûjK8  ã                  ó˜   € R t ^ RIHt ^ RIHt ^ RIt^ RIHt R.tR R lt	R R	 lt
R
 R ltR R ltR R ltRR R lltRR R lltR# )zQFit 2D affine transformations to point correspondences by weighted least squares.)Úannotations)ÚOptionalN)Ú_autocast_disabledÚfind_affinec          
     ó,   € V ^8„  d   QhRRRRRRRRRR	/# )
é   Úpoints1útorch.TensorÚpoints2Ú
min_pointsÚintÚbatchedÚboolÚreturnÚNone© )Úformats   "ÚZC:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\solvers\affine.pyÚ__annotate__r      s8   € ÷ Iñ I˜<ð I°,ð IÈCð IÐZ^ð IÐcgñ Ió    c                óÚ  € V P                   VP                   8w  d'   \        R V P                    RVP                    R24      hV'       d   V P                  ^8w  g+   MV P                  ^8  g   V P                   R,          ^8w  d)   V'       d   RMRp\        RV RV P                    R24      hV P                   R,          V8  d$   \        RV RV P                   R,           R24      hV P                  VP                  8w  d   \        R	4      hV P	                  4       '       d   VP	                  4       '       g   \        R
4      hV P                  VP                  8w  d   \        R4      hR# )z2points1 and points2 must have the same shape. Got z and Ú.z	(B, N, 2)z(..., N, 2)zpoints must have shape ú. Got z	At least z# correspondences are required. Got z/points1 and points2 must be on the same device.z3points1 and points2 must be floating point tensors.z-points1 and points2 must have the same dtype.Néÿÿÿÿéþÿÿÿ)ÚshapeÚ
ValueErrorÚndimÚdeviceÚis_floating_pointÚ	TypeErrorÚdtype)r   r
   r   r   Úprefixs   &&&& r   Ú_check_pointsr#      s.  € Ø‡}�}˜Ÿ™Ô%ÜÐMÈgÏmÉmÈ_Ð\aÐbi×boÑboÐapÐpqÐrÓsÐsß$ˆ�‰˜Õ¨'¯,©,¸Ô*:¸w¿}¹}ÈRÕ?PÐTUÔ?Uß '‘¨]ˆÜÐ2°6°(¸&ÀÇÁÀÈqÐQÓRÐRØ‡}�}�RÕ˜:Ô%Ü˜9 Z LÐ0SÐT[×TaÑTaÐbdÕTeÐSfÐfgÐhÓiÐiØ‡~�~˜Ÿ™Ô'ÜÐJÓKÐKØ×$Ñ$×&Ò&¨g×.GÑ.G×.IÒ.IÜÐMÓNÐNØ‡}�}˜Ÿ™Ô%ÜÐGÓHÐHñ &r   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   ÚweightsúOptional[torch.Tensor]Úpointsr	   Úbatch_shapez
torch.Sizer   r   )r   s   "r   r   r   /   s+   € ÷ ñ Ð4ð ¸lð ÐYcð Ðhtñ r   c                óÔ  € V fD   \         P                  ! . VOVP                  R,          N5VP                  VP                  R7      # V P                  . VOVP                  R,          N58w  d3   \        R. VOVP                  R,          N5 RV P                   R24      hV P                  VP                  8w  d   \        R4      hV P                  4       '       g   \        R4      hV # )N©r   r!   zweights must have shape r   r   z.weights and points must be on the same device.z(weights must be a floating point tensor.r   )ÚtorchÚonesr   r   r!   r   r   r    )r%   r'   r(   s   &&&r   Ú_prepare_weightsr-   /   sÒ   € Ø‚Ü�zŠzÐ:˜KÐ:¨¯©°bÕ)9Ñ:À6Ç=Á=ÐX^×XdÑXdÔeÐeØ‡}�}Ð8˜+Ð8 v§|¡|°BÕ'7Ñ8Ô8ÜÐ3Ð4T°kÐ4TÀ6Ç<Á<ÐPRÕCSÑ4TÐ3UÐU[Ð\c×\iÑ\iÐ[jÐjkÐlÓmÐmØ‡~�~˜Ÿ™Ô&ÜÐIÓJÐJØ×$Ñ$×&Ò&ÜÐBÓCÐCð €Nr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )r   r   r	   r
   r%   r   z!tuple[torch.Tensor, torch.Tensor]r   )r   s   "r   r   r   =   s,   € ÷ 9
ñ 9
Øð9
Ø$0ð9
Ø;Gð9
à&ñ9
r   c           
     óì  € \        V P                  P                  4      ;_uu_ 4        V P                  \        P
                  \        P                  39   d   \        P                  MV P                  pV P                  V4      VP                  V4      rT\        P                  ! W2P                  4      pVP                  V4      pVP                  RRR7      pV\        P                  ! V^ 8„  V\        P                  ! V4      4      ,          p	V	P                  V4      p
V
P                  RRR7      p\        P                  ! V^ 8„  V\        P                  ! V4      4      pWJR,          ,          P                  R	R7      V,          pWZR,          ,          P                  R	R7      V,          pWMR
,          ,
          W^R
,          ,
          ppV
^ 8„  R,          p\        P                  ! VVP                  4       \        P                  ! V4      4      P                  RRR7      p\        P                  ! VVP                  4       \        P                  ! V4      4      P                  RRR7      p\        P                  ! V4      p\        P                  ! V^ 8„  VV4      p\        P                  ! V^ 8„  VV4      pVV,          VV,          ppVV
R,          ,          P!                  RR	4      V,          P#                  4       pR\        P$                  ! ^VR,          ,          VR,          VR,          ,
          4      ,          p\        P&                  ! VP)                  4       VP+                  4       VP+                  4       ) VP)                  4       3RR7      P-                  V4      pVVP!                  RR	4      ,          pVV
R,          ,          P!                  RR	4      V,          pVV
R,          ,          P!                  RR	4      V,          pVR,          VR,          VR,          VR,          3w  ppppVV,          VV,          ,
          p VV,           p!\        P.                  ! V4      P0                  p"VR,          ^ 8„  V V"V!P3                  4       ,          8„  ,          p#\        P                  ! V#V \        P                  ! V 4      4      p$\        P&                  ! VV) V) V3RR7      P-                  V4      V$R,          ,          p%VV%,          V,          p&V&VV,          ,          p'V\        P4                  ! V'VR,          4      P7                  R4      ,
          p(\        P8                  ! V'\;        R4      4      p)\        P8                  ! V(\;        R4      4      p*\        P                  ! V#R,          V'V)4      \        P                  ! V#R,          V(V*4      3uuRRR4       #   + '       g   i     R# ; i)zKFit ``points2 = A @ points1 + t`` using a guarded weighted normal equation.T)ÚdimÚkeepdimN©r0   ç      à?Únanr   ).Nr   ).NºNNN©r   r   ©.é    é   ©.r8   r8   ©.r9   r9   ©.r9   r8   ).r8   ©.NN)r   r   Útyper!   r+   Úfloat16Úbfloat16Úfloat32ÚtoÚpromote_typesÚamaxÚwhereÚ	ones_likeÚsumÚabsÚ
zeros_likeÚ	transposeÚdetachÚatan2ÚstackÚcosÚsinÚ
reshape_asÚfinfoÚepsÚsquareÚmatmulÚsqueezeÚ	full_likeÚfloat)+r   r
   r%   Ú
work_dtypeÚxÚyÚweight_dtypeÚweights_for_scalingÚ
max_weightÚnormalized_weightsÚwÚsupportÚsafe_supportÚx_meanÚy_meanÚxcÚycÚnonzero_weightÚx_scaleÚy_scaleÚoneÚxnÚynÚscatterÚangleÚrotationÚnormalÚcrossÚaÚbÚcÚdÚdetÚtracerR   ÚvalidÚsafe_detÚinverseÚlinear_normalizedÚlinearÚtranslationÚ
nan_linearÚnan_translations+   &&&                                        r   Ú_fit_affine_componentsr   =   sƒ  € ô
 
˜GŸN™N×/Ñ/×	0Õ	0Ø&-§m¡m¼¿¹ÄuÇ~Á~Ð7VÔ&V”U—]’]Ð\c×\iÑ\iˆ
Ø�z‰z˜*Ó% w§z¡z°*Ó'=ˆ1ô
 ×*Ò*¨:·}±}ÓEˆØ%Ÿj™j¨Ó6ÐØ(×-Ñ-°"¸dÐ-ÓCˆ
Ø0´5·;²;¸zÈA¹~ÈzÔ[`×[jÒ[jÐkuÓ[vÓ3wÕwÐØ×!Ñ! *Ó-ˆØ—%‘%˜B¨�%Ó-ˆÜ—{’{ 7¨Q¡;°¼¿ºÈÓ9QÓRˆØ˜	•lÕ"×'Ñ'¨BÐ'Ó/°,Õ>ˆØ˜	•lÕ"×'Ñ'¨BÐ'Ó/°,Õ>ˆà˜LÕ)Õ)¨1°lÕ/CÕ+CˆBˆð ˜a™% Õ+ˆÜ—+’+˜n¨b¯f©f«h¼×8HÒ8HÈÓ8LÓM×RÑRÐW_ÐimÐRÓnˆÜ—+’+˜n¨b¯f©f«h¼×8HÒ8HÈÓ8LÓM×RÑRÐW_ÐimÐRÓnˆÜ�oŠo˜gÓ&ˆÜ—+’+˜g¨™k¨7°CÓ8ˆÜ—+’+˜g¨™k¨7°CÓ8ˆØ�g•˜r G�|ˆBˆð
 ˜˜9�Õ%×0Ñ0°°RÓ8¸2Õ=×EÑEÓGˆØ”e—k’k ! g¨iÕ&8Õ"8¸'À)Õ:LÈwÐW`ÕOaÕ:aÓbÕbˆÜ—;’; §	¡	£¨U¯Y©Y«[¸5¿9¹9»;¸,ÈÏ	É	ËÐTÐZ\Ô]×hÑhÐipÓqˆØ�(×$Ñ$ R¨Ó,Õ,ˆà�q˜•|Õ#×.Ñ.¨r°2Ó6¸Õ;ˆØ�a˜	•lÕ"×-Ñ-¨b°"Ó5¸Õ:ˆØ˜IÕ&¨¨yÕ(9¸6À)Õ;LÈfÐU^ÕN_Ð_‰
ˆˆ1ˆa�Ø�!�e�a˜!•e�mˆØ�A•ˆÜ�kŠk˜*Ó%×)Ñ)ˆØ˜• 1Ñ$¨¨s°U·\±\³^Õ/CÑ)CÕDˆÜ—;’;˜u c¬5¯?ª?¸3Ó+?Ó@ˆÜ—+’+˜q 1 " q b¨!˜n°"Ô5×@Ñ@ÀÓHÈ8ÐTcÕKdÕdˆØ! G�O¨hÕ6ÐØ" g°Õ&7Õ8ˆØœuŸ|š|¨F°F¸9Õ4EÓF×NÑNÈrÓRÕRˆÜ—_’_ V¬U°5«\Ó:ˆ
ÜŸ/š/¨+´u¸U³|ÓDˆÜ�{Š{˜5 Õ1°6¸:ÓFÌÏÊØ�)Õ˜k¨?óI
ð 
÷e 
1×	0×	0Ó	0ús   ¨V/W"×"W3	c               ó$   € V ^8„  d   QhRRRRRR/# ©r   r   r	   r
   r   r   )r   s   "r   r   r   y   s&   € ÷ tñ t ð t¸ð tÈñ tr   c                óZ  € \        W^RR7       \        V P                  P                  4      ;_uu_ 4        V P                  \
        P                  \
        P                  39   d   \
        P                  MV P                  pV P                  V4      VP                  V4      rCVP                  RR4      V,          pVR,          VR	,          VR
,          VR,          3w  rgr‰Wi,          Wx,          ,
          p
V
\
        P                  ! V4      P                  Wi,           P                  4       ,          8„  p\
        P                  ! Wº\
        P                  ! V
4      4      p\
        P                   ! W—) V) V3RR7      P#                  V4      VR,          ,          pVP                  RR4      V,          V,          p\
        P                  ! VR,          V\
        P$                  ! V\'        R4      4      4      P                  V P                  4      uuRRR4       #   + '       g   i     R# ; i)aK  Estimate origin-fixed 2D linear maps ``points2 = points1 @ A^T`` by least squares.

Solves the 2x2 normal equation ``A (X^T X) = Y^T X`` directly for points of shape ``(..., N, 2)``. Unlike
:func:`find_affine`, it neither centers, scales nor rotates the points, so it suits well-scaled, well-spread
points: AdaLAM refits its local affinities with it, on coordinates relative to the seed correspondence and
normalized by the neighborhood radius, where zero padding rows contribute nothing. Rank-deficient fits are
NaN under the relative criterion ``det(X^T X) <= eps * trace(X^T X)**2``.
F©r   r2   Nr4   r   r   r:   r7   r<   r;   r=   )r#   r   r   r>   r!   r+   r?   r@   rA   rB   rJ   rQ   rR   rS   rE   rF   rM   rP   rV   rW   )r   r
   rX   rY   rZ   ro   rq   rr   rs   rt   ru   rw   rx   ry   r{   s   &&             r   Ú_find_affine_linearr„   y   sƒ  € ô �' A¨uÕ5Ü	˜GŸN™N×/Ñ/×	0Õ	0Ø&-§m¡m¼¿¹ÄuÇ~Á~Ð7VÔ&V”U—]’]Ð\c×\iÑ\iˆ
Ø�z‰z˜*Ó% w§z¡z°*Ó'=ˆ1Ø—‘˜R Ó$ qÕ(ˆØ˜IÕ&¨¨yÕ(9¸6À)Õ;LÈfÐU^ÕN_Ð_‰
ˆˆaØ�e�a•e�mˆØ”e—k’k *Ó-×1Ñ1°QµU·N±NÓ4DÕDÑDˆÜ—;’;˜u¬5¯?ª?¸3Ó+?Ó@ˆÜ—+’+˜q " q b¨!˜n°"Ô5×@Ñ@ÀÓHÈ8ÐTcÕKdÕdˆØ—+‘+˜b "Ó%¨Õ)¨WÕ4ˆÜ�{Š{˜5 Õ1°6¼5¿?º?È6ÔSXÐY^ÓS_Ó;`Óa×dÑdÐel×erÑerÓs÷ 
1×	0×	0Ó	0ús   ¶GHÈH*	c               ó$   € V ^8„  d   QhRRRRRR/# r�   r   )r   s   "r   r   r   �   s&   € ÷ tñ t lð t¸\ð tÈlñ tr   c                óÆ  € \        W^RR7       V P                  R	,          ^8w  d!   \        RV P                  R	,           R24      h\        V P                  P
                  4      ;_uu_ 4        V P                  \        P                  \        P                  39   d   \        P                  MV P                  pV P                  V4      VP                  V4      rCVR
,          VR,          VR,          VR,          3w  rVrxWX,          Wg,          ,
          p	V	P                  4       \        P                  ! V4      P                  R,          VP                  4       P!                  RR7      ,          8„  p
\        P"                  ! W©\        P$                  ! V	4      4      p\        P&                  ! W†) V) V3RR7      P)                  V4      pWÄ,          P+                  RR	4      VR,          ,          p\        P"                  ! V
R,          V\        P,                  ! V\/        R4      4      4      P                  V P                  4      uuRRR4       #   + '       g   i     R# ; i)aá  Solve origin-fixed 2D linear maps exactly from two correspondences.

The minimal case of :func:`_find_affine_linear` for points of shape ``(..., 2, 2)``: two correspondences
determine the map, so the 2x2 system is solved directly rather than through the normal equation, which
squares its condition number. Rank-deficient samples are NaN under the same relative criterion,
``det(X^T X) <= eps * trace(X^T X)**2``, written without squaring as ``|det X| <= sqrt(eps) * ||X||_F**2``.
Frƒ   z,Exactly 2 correspondences are required. Got r   r3   r2   Nr4   r   r:   r7   r<   r;   r   r6   r=   )r#   r   r   r   r   r>   r!   r+   r?   r@   rA   rB   rH   rQ   rR   rS   rG   rE   rF   rM   rP   rJ   rV   rW   )r   r
   rX   rY   rZ   rq   rr   rs   rt   ru   rw   rx   Úadjugater{   s   &&            r   Ú_find_affine_linear_pairrˆ   �   s¨  € ô �' A¨uÕ5Ø‡}�}�RÕ˜AÔÜÐGÈÏÉÐVXÕHYÐGZÐZ[Ð\Ó]Ð]Ü	˜GŸN™N×/Ñ/×	0Õ	0Ø&-§m¡m¼¿¹ÄuÇ~Á~Ð7VÔ&V”U—]’]Ð\c×\iÑ\iˆ
Ø�z‰z˜*Ó% w§z¡z°*Ó'=ˆ1Ø�y•\ 1 Y¥<°°9µ¸qÀ½|ÐK‰
ˆˆaØ�e�a•e�mˆØ—‘“	œEŸKšK¨
Ó3×7Ñ7¸3Õ>ÀÇÁÃÇÁÐT\ÀÓA]Õ]Ñ]ˆÜ—;’;˜u¬5¯?ª?¸3Ó+?Ó@ˆä—;’;  2¨ r¨1˜~°2Ô6×AÑAÀ!ÓDˆØ•,×)Ñ)¨"¨bÓ1°H¸_Õ4MÕMˆÜ�{Š{˜5 Õ1°6¼5¿?º?È6ÔSXÐY^ÓS_Ó;`Óa×dÑdÐel×erÑerÓs÷ 
1×	0×	0Ó	0ús   Á.GIÉI 	c               ó(   € V ^8„  d   QhRRRRRRRR/# ©r   r   r	   r
   r%   r&   r   r   )r   s   "r   r   r   ¨   s2   € ÷ gñ gØðgØ$0ðgØ;Qðgàñgr   c           	     óä  € \        W^RR7       V P                  R,          ^8w  d!   \        RV P                  R,           R24      h\        V P                  P
                  4      ;_uu_ 4        V P                  \        P                  \        P                  39   d   \        P                  MV P                  pV P                  V4      VP                  V4      rTVR	,          VR	,          rv\        VR
,          V,
          VR
,          V,
          4      pVP                  RR4      W†P                  RR4      ,          ,
          p	\        P                  ! . ROVP                  VR7      P                  VP                  ^ ,          ^^4      p
\        P                   ! \        P                   ! W‰3RR7      V
3RR7      P                  V P                  4      uuRRR4       #   + '       g   i     R# ; i)a  Solve 2D affine transformations exactly from three correspondences, RANSAC's minimal samples.

Points have shape ``(B, 3, 2)`` and the result is homogeneous ``(B, 3, 3)``, like :func:`find_affine`. The linear
part maps the differences to the first correspondence, by :func:`_find_affine_linear_pair`, and the translation
follows from the first correspondence; collinear samples are NaN under that function's rank criterion. Positive
weights do not change an exact fit, so ``weights``, part of RANSAC's solver interface, are not used.
Trƒ   z,Exactly 3 correspondences are required. Got r   r*   r2   Nr   )r5   :Nr9   N)r5   :r9   NNr   )ç        rŒ   g      ð?)r#   r   r   r   r   r>   r!   r+   r?   r@   rA   rB   rˆ   rJ   ÚtensorÚexpandÚcat)r   r
   r%   rX   rY   rZ   Úorigin1Úorigin2r{   r|   Úbottoms   &&&        r   Ú_find_affine_tripletr“   ¨   sf  € ô �' A¨tÕ4Ø‡}�}�RÕ˜AÔÜÐGÈÏÉÐVXÕHYÐGZÐZ[Ð\Ó]Ð]Ü	˜GŸN™N×/Ñ/×	0Õ	0Ø&-§m¡m¼¿¹ÄuÇ~Á~Ð7VÔ&V”U—]’]Ð\c×\iÑ\iˆ
Ø�z‰z˜*Ó% w§z¡z°*Ó'=ˆ1Ø˜U�8 Q u¥X�Ü)¨!¨E­(°WÕ*<¸aÀ½hÈÕ>PÓQˆØ×'Ñ'¨¨BÓ/°&×;LÑ;LÈRÐQSÓ;TÕ2TÕTˆÜ—’šo°a·h±hÀjÔQ×XÑXÐYZ×Y`ÑY`ÐabÕYcÐefÐhiÓjˆÜ�yŠyœ%Ÿ)š) VÐ$9¸rÔBÀFÐKÐQSÔT×WÑWÐX_×XeÑXeÓf÷ 
1×	0×	0Ó	0ús   Á.E%GÇG/	c               ó(   € V ^8„  d   QhRRRRRRRR/# rŠ   r   )r   s   "r   r   r   ¿   s*   € ÷ -$ñ -$˜ð -$°ð -$ÐG]ð -$Ðiuñ -$r   c                ó>  € \        W^RR7       \        W V P                  RR 4      p\        WV4      w  r4\        P
                  ! . V P                  RR O^N^N5V P                  VP                  R7      pW5R&   WER&   ^VR&   VP                  V P                  4      # )	a8	  Fit a 2D affine transformation to point correspondences by weighted least squares.

``M = find_affine(points1, points2)`` takes source and destination points ``(B, N, 2)``, ``N >= 3``, and
optional weights ``(B, N)``, and returns the homogeneous source-to-destination matrices ``(B, 3, 3)``, with bottom
row ``[0, 0, 1]``, of the least-squares fit :math:`\mathbf{y}=A\mathbf{x}+\mathbf{t}`, independently for each
batch element. ``M[:, :2]`` is the ``(B, 2, 3)`` matrix that :func:`~kornia.geometry.transform.warp_affine`
takes. With outliers, use :class:`~kornia.geometry.ransac.RANSAC` with ``model_type="affine"``; for a perspective
map, :func:`~kornia.geometry.homography.find_homography_dlt`; to build an affine matrix from an angle, a scale and
a translation instead, :func:`~kornia.geometry.transform.get_affine_matrix2d`.

The calculation centers and isotropically normalizes each point set before solving its 2-by-2 normal equation.
Inputs must have the same floating-point dtype and device; half inputs are accumulated in float32. Ambient
autocast is disabled during fitting to preserve this arithmetic precision.

Args:
    points1: Source points with shape ``(B, N, 2)``, where :math:`N \geq 3`.
    points2: Destination points with shape ``(B, N, 2)``.
    weights: Optional correspondence weights with shape ``(B, N)``. They must be
        finite and non-negative; other values are not detected and give undefined
        results. Only relative weights matter.

Returns:
    Homogeneous affine transformations with shape ``(B, 3, 3)``. Degenerate
    batches without three non-collinear, positive-weight source points contain
    NaNs, allowing robust estimators to reject singular fits as invalid models.

Raises:
    ValueError: if the points are not ``(B, N, 2)`` with ``N >= 3``, if their shapes or devices differ, or if
        ``weights`` is not ``(B, N)`` on the points' device.
    TypeError: if the points or ``weights`` are not floating point, or the dtypes of the points differ.

See Also:
    - :func:`~kornia.geometry.homography.find_homography_dlt`: a perspective map, the general case with eight
      degrees of freedom.
    - :func:`~kornia.geometry.transform.get_affine_matrix2d`: an affine matrix built from parameters, not fitted.
    - :class:`~kornia.geometry.ransac.RANSAC`: an affine map robust to wrong correspondences.
Trƒ   Nr*   r   ).ºNr   Nr–   ).r–   r   ).r   r   )	r#   r-   r   r   r+   Úzerosr   r!   rB   )r   r
   r%   r{   r|   Úresults   &&&   r   r   r   ¿   sœ   € ôL �' A¨tÕ4Ü˜w°·±¸sÀÐ1CÓD€GÜ0°À7ÓKÑ€FÜ�[Š[Ð4˜7Ÿ=™=¨¨"Ð-Ð4¨qÐ4°!Ñ4¸W¿^¹^ÐSY×S_ÑS_Ô`€FØ ˆ;ÑØ$ˆ:ÑØ€Fˆ9ÑØ�9‰9�W—]‘]Ó#Ð#r   )N)Ú__doc__Ú
__future__r   Útypingr   r+   Úkornia.core.utilsr   Ú__all__r#   r-   r   r„   rˆ   r“   r   r   r   r   Ú<module>rž      sK   ðñ$ Xå "å ã å 0àˆ/€õIõ õ9
õxtõ.t÷0g÷.-$ñ -$r   