
    3j                         S SK Jr  S SKrS SKJr  S SKrS SKJr   S         SS jjr              SS jr	                  SS jr
          SS jrSS	 jrSS
 jrSS jrg)    )annotationsN)Union)PinholeCamerac           	        [         R                  " [         R                  " S/U-  XS9[         R                  " S/U-  XS945      n[         R                  " [         R                  " S/U-  XS9[         R                  " S/U-  XS945      n[         R                  " [         R                  " S/U-  XS9[         R                  " S/U-  XS945      nXEU4$ )a@  Create camera dimensions for ray sampling.

Args:
    device: Union[str, torch.device, None] for tensors
    dtype: Data type for tensors
    n_cams1: Number of cameras in first group (default: 3)
    n_cams2: Number of cameras in second group (default: 2)

Returns:
    Tuple of (heights, widths, num_img_rays) tensors
   devicedtyped   i,  i  
      )torchcattensor)r	   r
   n_cams1n_cams2heightswidthsnum_img_rayss          V/home/wildlama/miniconda3/lib/python3.13/site-packages/kornia/geometry/camera/utils.pycreate_camera_dimensionsr      s     "IILL#ELL#E	
G !99LL#ELL#E	
F "'LL"DLL"D	
"L L((    c                   / n[        U[        R                  5      (       a  UR                  5       OUn[        U[        R                  5      (       a  UR                  5       OUn[	        XXx5       H<  u  pp[        R
                  " SXES9nXS'   XS'   XS'   XS'   UR                  U5        M>     [        R                  " U5      $ )a{  Create intrinsic camera matrices from focal lengths and principal points.

Args:
    fxs: Focal length in x direction
    fys: Focal length in y direction
    cxs: Principal point x coordinate
    cys: Principal point y coordinate
    device: Union[str, torch.device, None] for tensors
    dtype: Data type for tensors

Returns:
    Stacked intrinsic matrices of shape (N, 4, 4)
   r   r   r      r   r      r   r   )
isinstancer   Tensortolistzipeyeappendstack)fxsfyscxscysr	   r
   intrinsics_batchcxs_listcys_listfxfycxcy
intrinsicss                 r   create_intrinsicsr4   @   s    * ,.)#u||<<szz|#H)#u||<<szz|#Hc;YYq=
4444
+ < ;;'((r   c                T   / n[        XX#XE5       GH  u  ppp[        R                  " SXgS9n[        R                  " U	5      US'   [        R                  " U	5      US'   US   * US'   US   US'   [        R                  " SXgS9n[        R                  " U
5      US'   [        R                  " U
5      * US'   US   * US	'   US   US'   [        R                  " SXgS9n[        R                  " U5      US'   [        R                  " U5      US
'   US
   * US'   US   US'   [        R
                  " UU5      n[        R
                  " UU5      n[        R                  " SXgS9nUUS'   UUS'   UUS'   UUSS2SS24'   UR                  U5        GM     [        R                  " U5      $ )a  Create extrinsic camera matrices with rotation and translation.

Args:
    alphas: Rotation angles around x-axis
    betas: Rotation angles around y-axis
    gammas: Rotation angles around z-axis
    txs: Translation in x direction
    tys: Translation in y direction
    tzs: Translation in z direction
    device: Union[str, torch.device, None] for tensors
    dtype: Data type for tensors

Returns:
    Stacked extrinsic matrices of shape (N, 4, 4)
   r   r   r    )r   r   )r   r   r   r   )r   r   )r   r   )r   r   r   ).r   ).r   r7   ).r   r7   N)r$   r   r%   cossinmatmulr&   r'   )alphasbetasgammastxstystzsr	   r
   extrinsics_batchalphabetagammatxtytzRxRyRzRyzR
extrinsicss                        r   create_extrinsics_with_rotationrN   c   s   2 ,.*-fV#*S&UYYq599U#499U#4tH94d84YYq599T?4IIdO#4tH94d84YYq599U#499U#4tH94d84ll2r"LLS!YYq=
!#
:!#
:!#
:
2A2rr6
+9 +T: ;;'((r   c                @   UnU nUS-
  S-  nU S-
  S-  nSnSn	Sn
[         R                  S-  nSn[         R                  * S-  n[        U/U/U/U/X#S9n[        U/U/U/U/U	/U
/X#S9n[	        UU[
        R                  " U /X#S9[
        R                  " U/X#S95      $ )a
  Create a single PinholeCamera with default parameters.

Args:
    height: Camera image height
    width: Camera image width
    device: Union[str, torch.device, None] for tensors
    dtype: Data type for tensors

Returns:
    PinholeCamera: A PinholeCamera instance
      ?       @        r   )mathpir4   rN   r   r   r   )heightwidthr	   r
   r/   r0   r1   r2   rE   rF   rG   rB   rC   rD   r3   rM   s                   r   create_pinhole_camerarW      s     
B	B
#+	B
3,#	B	B	B	BGGcMEDWWHsNE"B4"tbT&VJ0%4&5'B4RTQUXZW[djxJfXf:eWV9	 r   c                   [         R                  " / SQXS9n[         R                  " / SQXS9nUR                  5       nUR                  5       nUS-
  S-  nUS-
  S-  n/ SQn/ SQn	/ SQn
[        R                  nUS-  US-  US-  S/nSSSU/nU* S-  SUS-  S/n[        XEXgXS9n[        XXXXS9n[        UUX#5      nU$ )	zCreate four PinholeCameras with predefined parameters.

Args:
    device: Union[str, torch.device, None] for tensors
    dtype: Data type for tensors

Returns:
    PinholeCamera: A PinholeCamera instance with 4 cameras in batch
)   r   r   r   r   )	      r[   r[   rP   rQ   )rR   rR   rR   rR   )      &@r\   r\   g      @rR   )r   r   r#   rS   rT   r4   rN   r   )r	   r
   rU   rV   r/   r0   r1   r2   rE   rF   rG   rT   rB   rC   rD   r3   rM   camerass                     r   create_four_camerasr^      s     \\,vCFLLfBE	B	B
#+	B
3,#	B	B	B	 B	B#XrCxc3/Ec2DS3YR#Xs+E"22&NJ0eX^lJJ
FBGNr   c           
     V   [         R                  " S5        / n[        U R                  R	                  5       U R
                  R	                  5       5       HP  u  p#[         R                  " SSS[        U5      [        U5      4[         R                  S9nUR                  U5        MR     U$ )z0Create random images for a given set of cameras.p   r      r6   r
   )
r   manual_seedr$   rU   r#   rV   randintintuint8r&   )r]   imgsrU   rV   
image_datas        r    create_random_images_for_camerasri      s}    	c!DW^^224gmm6J6J6LM]]1cAs6{CJ+Gu{{[
J N Kr   c                H   / n[        U R                  R                  5       U R                  R                  5       5       H_  u  p4[        R
                  " S[        U5      [        U5      [        R                  S9nSUS'   UR                  UR                  US95        Ma     U$ )z-Create red images for a given set of cameras.r6   rb   ra   )r   .)r	   )
r$   rU   r#   rV   r   zerosre   rf   r&   to)r]   r	   rg   rU   rV   rh   s         r   create_red_images_for_camerasrm      s}    !DW^^224gmm6J6J6LM[[CKU5;;O
 
6JMMM01 N Kr   )r6   r   )
r	   Union[str, torch.device, None]r
   torch.dtyper   re   r   re   returnz/tuple[torch.Tensor, torch.Tensor, torch.Tensor])r(   list[float | int]r)   rq   r*    torch.Tensor | list[float | int]r+   rr   r	   rn   r
   ro   rp   torch.Tensor)r;   list[float]r<   rt   r=   rt   r>   rt   r?   rt   r@   rt   r	   rn   r
   ro   rp   rs   )
rU   floatrV   ru   r	   rn   r
   ro   rp   r   )r	   rn   r
   ro   rp   r   )r]   r   rp   list[torch.Tensor])r]   r   r	   rn   rp   rv   )
__future__r   rS   typingr   r   kornia.geometry.camerar   r   r4   rN   rW   r^   ri   rm    r   r   <module>r{      s/  $ #    1 bc )* )3> )IL )[^ )4 )F )	 )	 ) 
* ) 
*	 )
 + )  )  )F7)7)7) 7) 
	7)
 
7) 
7) +7) 7) 7)t###)G#P[##L Fr   