+
    åûjç  ã                   óX   € R t ^ RIt^ RIHu Ht ^ RIHtHtH	t	H
t
 R R ltRR R lltR# )zoPerspective projection of camera-frame points to pixels with a 3x3 intrinsics matrix, and back at given depths.N)Úconvert_points_from_homogeneousÚconvert_points_to_homogeneousÚ"denormalize_points_with_intrinsicsÚ normalize_points_with_intrinsicsc                óx   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  /# )é   Úpoint_3dÚcamera_matrixÚreturn)ÚtorchÚTensor)Úformats   "Ú^C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\camera\perspective.pyÚ__annotate__r      s2   € ÷ 8Hñ 8HœUŸ\™\ð 8H¼%¿,¹,ð 8HÌ5Ï<É<ñ 8Hó    c                ó.   € \        V 4      p\        W!4      # )a"  Project camera-frame 3D points to pixels with a 3x3 intrinsics matrix K.

``uv = project_points(points, K)`` takes camera-frame points ``(*, 3)``, with at least two dimensions, and the
intrinsics ``(*, 3, 3)``, and returns their pixels ``(fx x / z + cx, fy y / z + cy)`` as ``(*, 2)``. ``K``
broadcasts against the points as in :func:`~kornia.geometry.conversions.denormalize_points_with_intrinsics`:
a ``(B, 3, 3)`` ``K`` pairs camera ``b`` with ``points[b]`` of ``(B, 3)`` or ``(B, N, 3)`` points; for
``(B, H, W, 3)`` points pass ``K[:, None, None]``. For world points, project through the extrinsics with
:meth:`~kornia.geometry.camera.pinhole.PinholeCamera.project`; for a lens with Brown-Conrady distortion, pass
the result to :func:`~kornia.geometry.calibration.distort_points`.

Convention:
    - ``point_3d`` is a **camera-frame** point and ``camera_matrix`` the ``(*, 3, 3)`` ``K``; the
      function takes no extrinsics, so it does not move between frames. Pixel centres are integers; see the
      Convention block on :class:`~kornia.geometry.camera.pinhole.PinholeCamera`.
    - the input must be at least rank 2: an unbatched ``(3,)`` point raises :class:`ValueError`.
    - the skew entry ``K[0, 1]`` is ignored, as in
      :func:`~kornia.geometry.conversions.denormalize_points_with_intrinsics`.

.. warning::
    At ``abs(z) <= 1e-8`` the divide is skipped and ``K`` is applied to the undivided point, giving the
    finite placeholder ``fx x + cx``; the other projection entry points do not follow this rule yet:
    `#4267 <https://github.com/kornia/kornia/issues/4267>`_. Neither that placeholder nor a point behind the
    camera is flagged as invalid: `#4555 <https://github.com/kornia/kornia/issues/4555>`_.

Args:
    point_3d: tensor containing the 3d points to be projected
        to the camera plane. The shape of the tensor can be ``(*, 3)``.
    camera_matrix: tensor containing the intrinsics camera
        matrix. The tensor shape must be ``(*, 3, 3)``.

Returns:
    tensor of (u, v) pixel coordinates with shape ``(*, 2)``.

See Also:
    - :func:`unproject_points`: the reverse, pixels at given depths to camera-frame points.
    - :meth:`~kornia.geometry.camera.pinhole.PinholeCamera.project`: world points, through ``(B, 4, 4)``
      intrinsics and extrinsics.
    - :func:`~kornia.geometry.camera.project_points_z1`: the divide alone, to the normalized ``z = 1`` plane
      without intrinsics, with a plain divide at ``z = 0``.
    - :func:`~kornia.geometry.camera.project_points_orthographic`: drops ``z`` instead of dividing by it.
    - :func:`~kornia.geometry.calibration.distort_points`: adds Brown-Conrady lens distortion to the pixels.

Example:
    >>> _ = torch.manual_seed(0)
    >>> X = torch.rand(1, 3)
    >>> K = torch.eye(3)[None]
    >>> project_points(X, K)
    tensor([[5.6088, 8.6827]])

)r   r   )r   r	   Ú	xy_coordss   && r   Úproject_pointsr      s   € ôn >¸hÓG€IÜ-¨iÓGÐGr   c          
      ó¤   € V ^8„  d   QhR\         P                  R\         P                  R\         P                  R\        R\         P                  /# )r   Úpoint_2dÚdepthr	   Ú	normalizer
   )r   r   Úbool)r   s   "r   r   r   Z   sK   € ÷ Dñ DÜ�l‰lðDÜ#(§<¡<ðDÜ@EÇÁðDÜY]ðDä
‡\�\ñDr   c                óN  € \        V\        P                  4      '       g   \        R\	        V4       24      hVP
                  R,          ^8X  g   \        RVP
                   24      h\        W4      p\        V4      pV'       d   \        P                  ! VRRR7      pWQ,          # )a}  Unproject pixels at given depths to camera-frame 3D points with a 3x3 matrix K.

``points = unproject_points(uv, depth, K)`` takes pixels ``(*, 2)``, with at least two dimensions, their depths
``(*, 1)`` and the intrinsics ``(*, 3, 3)``, and returns the camera-frame points
``((u - cx) d / fx, (v - cy) d / fy, d)`` as ``(*, 3)``. ``K`` broadcasts against the pixels as in
:func:`~kornia.geometry.conversions.normalize_points_with_intrinsics`: a ``(B, 3, 3)`` ``K`` pairs camera ``b``
with ``uv[b]`` of ``(B, 2)`` or ``(B, N, 2)`` pixels; for ``(B, H, W, 2)`` pixels pass ``K[:, None, None]``.
For a whole depth map, use :func:`~kornia.geometry.depth.depth_to_3d_v2`; for world points,
:meth:`~kornia.geometry.camera.pinhole.PinholeCamera.unproject`.

Convention:
    - ``point_2d`` is a pixel coordinate and the result is in the **camera** frame: the function takes no
      extrinsics, so it cannot return world coordinates.
      :meth:`~kornia.geometry.camera.pinhole.PinholeCamera.unproject` is the world-frame counterpart.
      Pixel centres are integers; see the Convention block on
      :class:`~kornia.geometry.camera.pinhole.PinholeCamera`.
    - ``depth`` is the camera-frame ``z`` of the result. With ``normalize=True`` it is read as the
      Euclidean ray length instead, so the result has that norm and a smaller ``z``.
    - ``depth`` must be a tensor (else :class:`TypeError`) whose last dimension is 1 (else
      :class:`ValueError`); its leading dimensions broadcast against the pixels'.

Args:
    point_2d: tensor containing the 2d points to be projected to
        the camera frame. The shape of the tensor can be ``(*, 2)``.
    depth: tensor containing the depth value of each 2d
        points. The tensor shape must be equal to point2d ``(*, 1)``.
    camera_matrix: tensor containing the intrinsics camera
        matrix. The tensor shape must be ``(*, 3, 3)``.
    normalize: whether to normalize the pointcloud. This
        must be set to `True` when the depth is represented as the Euclidean
        ray length from the camera position.

Returns:
    tensor of (x, y, z) camera coordinates with shape ``(*, 3)``.

See Also:
    - :func:`project_points`: the reverse, camera-frame points to pixels.
    - :meth:`~kornia.geometry.camera.pinhole.PinholeCamera.unproject`: world points, through ``(B, 4, 4)``
      intrinsics and extrinsics.
    - :func:`~kornia.geometry.depth.depth_to_3d_v2`: every pixel of a depth map, channels last.
    - :func:`~kornia.geometry.camera.unproject_points_z1`: from the normalized ``z = 1`` plane, without
      intrinsics.
    - :func:`~kornia.geometry.calibration.undistort_points`: removes Brown-Conrady lens distortion from the
      pixels, to call first.

Example:
    >>> _ = torch.manual_seed(0)
    >>> x = torch.rand(1, 2)
    >>> depth = torch.ones(1, 1)
    >>> K = torch.eye(3)[None]
    >>> unproject_points(x, depth, K)
    tensor([[0.4963, 0.7682, 1.0000]])

z,Input depth type is not a torch.Tensor. Got z0Input depth must be in the shape of (*, 1). Got g       @)ÚdimÚpéÿÿÿÿ)Ú
isinstancer   r   Ú	TypeErrorÚtypeÚshapeÚ
ValueErrorr   r   ÚFr   )r   r   r	   r   ÚxyÚxyzs   &&&&  r   Úunproject_pointsr%   Z   s…   € ôr �eœUŸ\™\×*Ò*ÜÐFÄtÈEÃ{ÀmÐTÓUÐUà�;‰;�r�?˜aÔÜÐKÈEÏKÉKÈ=ÐYÓZÐZä7¸ÓP€BÜ5°bÓ9€CßÜ�kŠk˜# 2¨Ô-ˆà�;Ðr   )F)Ú__doc__r   Útorch.nn.functionalÚnnÚ
functionalr"   Úkornia.geometry.conversionsr   r   r   r   r   r%   © r   r   Ú<module>r,      s1   ðñ$ vã ß Ð ÷ó õ8H÷vDñ Dr   