+
    åûj‰&  ã                  ó^   € R t ^ RIHt ^ RIHt ^ RIt^ RIHt R R ltRR R llt	R	 R
 lt
R# )zlPerspective projection of camera-frame points onto the normalized z = 1 plane, its inverse and its Jacobian.)Úannotations)ÚOptionalN©ÚKORNIA_CHECK_SHAPEc               ó    € V ^8„  d   QhRRRR/# ©é   Úpoints_in_cameraútorch.TensorÚreturn© )Úformats   "Ú`C:\Ai_Coding\apps\studio\ComfyUI\.venv\Lib\site-packages\kornia\geometry\camera\projection_z1.pyÚ__annotate__r      s   € ÷ 4Bñ 4B¨ð 4B¸ñ 4Bó    c                óL   € \        V RR.4       V R,          V R,          ,          # )a‡	  Divide camera-frame points by z onto the normalized z = 1 plane, without intrinsics.

``xy = project_points_z1(points)`` takes camera-frame points ``(..., 3)`` and returns ``(x / z, y / z)`` as
``(..., 2)``: normalized coordinates, not pixels. Map them to pixels with :func:`distort_points_affine`, or
through a fisheye lens with :func:`distort_points_kannala_brandt`; for pixels from a ``3x3`` ``K`` in one call,
use :func:`~kornia.geometry.camera.perspective.project_points` instead.

.. math::

    \begin{bmatrix} u \\ v \\ w \end{bmatrix} =
    \begin{bmatrix} x \\ y \\ z \end{bmatrix} / z

.. note::

    This function has a precondition that the points are in front of the camera, i.e. z > 0.
    If this is not the case, the points will be projected to the canonical plane, but the resulting
    points will be behind the camera and causing numerical issues for z == 0.

Convention:
    - the input is a **camera-frame** point and the output its position on the canonical ``z = 1`` plane,
      a normalized coordinate rather than a pixel; applying ``K`` with
      :func:`~kornia.geometry.conversions.denormalize_points_with_intrinsics` gives the pixel.
    - the ``z > 0`` precondition above is not validated.

.. warning::
    The divide is plain at every ``z``: at ``z = 0`` a component is infinite, or ``nan`` for a zero
    numerator. :func:`~kornia.geometry.camera.perspective.project_points` instead skips its divide at
    ``abs(z) <= 1e-8`` and returns finite pixels there, so the two disagree below that threshold:
    `#4267 <https://github.com/kornia/kornia/issues/4267>`_.

Args:
    points_in_camera: torch.Tensor representing the points to project with shape ``(..., 3)``.

Returns:
    torch.Tensor representing the projected points with shape ``(..., 2)``.

See Also:
    - :func:`unproject_points_z1`: the reverse, scaling a normalized point by a depth.
    - :func:`dx_project_points_z1`: the ``(..., 2, 3)`` Jacobian of this projection.
    - :func:`project_points_orthographic`: drops ``z`` instead of dividing by it.
    - :class:`~kornia.sensors.camera.projection_model.Z1Projection`: the same projection on ``Vector3`` points.
    - :func:`~kornia.geometry.camera.perspective.project_points`: pixels from a ``3x3`` ``K`` in one call,
      with the divide skipped at ``abs(z) <= 1e-8``.

Example:
    >>> points = torch.tensor([1., 2., 3.])
    >>> project_points_z1(points)
    tensor([0.3333, 0.6667])

Ú*Ú3).:Nr   N).:r   é   Nr   )r	   s   &r   Úproject_points_z1r      s*   € ôf Ð'¨#¨s¨Ô4Ø˜GÕ$Ð'7¸Õ'AÕAÐAr   c               ó$   € V ^8„  d   QhRRRRRR/# )r   Úpoints_in_cam_canonicalr
   Ú	extensionzOptional[torch.Tensor]r   r   )r   s   "r   r   r   U   s)   € ÷ :Hñ :HØ)ð:HØ6Lð:Hàñ:Hr   c                ó„  € \        V RR.4       Vf6   \        P                  ! V \        P                  ! V R,          4      .RR7      # VP                  V P                  ^,
          8X  d
   VR,          p\        VRR.4       W,          p\        P                  ! W!P                  VR,          P                  4      .RR7      # )a¸  Scale normalized z = 1 points by a depth into camera-frame points, z = 1 by default.

``points = unproject_points_z1(xy, depth)`` takes normalized coordinates ``(..., 2)`` and their camera-frame
depths ``d``, ``(...,)`` or ``(..., 1)``, and returns ``(x d, y d, d)`` as ``(..., 3)``; without a depth it
appends ``z = 1``. For pixels and a ``3x3`` ``K``, use
:func:`~kornia.geometry.camera.perspective.unproject_points` instead.

.. math::
    \begin{bmatrix} x \\ y \\ z \end{bmatrix} =
    \begin{bmatrix} u \\ v \\ 1 \end{bmatrix} \cdot w

Convention:
    - ``extension`` is the camera-frame ``z`` of the unprojected point: the canonical point is multiplied
      by it and it becomes the third component.
      :meth:`~kornia.sensors.camera.projection_model.Z1Projection.unproject` names the same argument
      ``depth``. Both ``(...,)`` and ``(..., 1)`` extensions are accepted, and their leading dimensions
      broadcast against the points'. An extension with one dimension fewer than the points is read as
      ``(...,)``, any other as ``(..., 1)``: for ``(2, 5, 2)`` points a ``(5, 1)`` extension is read as
      ``(...,)`` and raises, so pass ``(1, 5, 1)``. One depth scales both coordinates: any other trailing size
      raises ``ShapeError``.

Args:
    points_in_cam_canonical: torch.Tensor representing the points to unproject with shape ``(..., 2)``.
    extension: torch.Tensor representing the extension (depth) of the points to unproject with shape
        ``(..., 1)`` or ``(...,)``, broadcastable against the points' leading dimensions. Defaults to unit
        depth.

Returns:
    torch.Tensor representing the unprojected points with shape ``(..., 3)``.

See Also:
    - :func:`project_points_z1`: the reverse, dividing by ``z``.
    - :func:`unproject_points_orthographic`: appends the depth without scaling ``x`` and ``y``.
    - :class:`~kornia.sensors.camera.projection_model.Z1Projection`: the same unprojection on ``Vector2`` points.
    - :func:`~kornia.geometry.camera.perspective.unproject_points`: from pixels, with a ``3x3`` ``K``.

Example:
    >>> points = torch.tensor([1., 2.])
    >>> extension = torch.tensor([3.])
    >>> unproject_points_z1(points, extension)
    tensor([3., 6., 3.])

r   Ú2©ÚdimÚ1).:Né   Néÿÿÿÿ).N)r   ÚtorchÚcatÚ	ones_likeÚndimÚexpandÚshape)r   r   Úxys   && r   Úunproject_points_z1r'   U   s¥   € ô\ Ð.°°c°
Ô;àÒä�yŠyÐ1´5·?²?ÐCZÐ[bÕCcÓ3dÐeÐkmÔnÐnØ‡~�~Ð0×5Ñ5¸Õ9Ô9Ø˜iÕ(ˆ	Ü�y 3¨ *Ô-Ø	 Õ	,€Bô �9Š9�b×*Ñ*¨2¨g­;×+<Ñ+<Ó=Ð>ÀBÔGÐGr   c               ó    € V ^8„  d   QhRRRR/# r   r   )r   s   "r   r   r   ’   s   € ÷ =ñ =¨<ð =¸Lñ =r   c           	     óV  € \        V RR.4       V R,          pV R,          pV R,          pRV,          pWD,          p\        P                  ! V4      p\        P                  ! \        P                  ! WFV) V,          .RR7      \        P                  ! WdV) V,          .RR7      .R	R7      # )
a   Compute the 2x3 Jacobian of the z = 1 projection with respect to the camera-frame point.

``J = dx_project_points_z1(points)`` takes camera-frame points ``(..., 3)`` and returns the Jacobian of
:func:`project_points_z1` at each, ``(..., 2, 3)``: the derivatives of ``(x / z, y / z)`` with respect to
``(x, y, z)``. At ``z = 0`` its nonzero entries are infinite, or ``nan`` where ``x`` or ``y`` is 0. Chain it
with :func:`dx_distort_points_affine` or :func:`dx_distort_points_kannala_brandt` for the Jacobian of a whole
camera model.

.. math::
    \frac{\partial \pi}{\partial x} =
    \begin{bmatrix}
        \frac{1}{z} & 0 & -\frac{x}{z^2} \\
        0 & \frac{1}{z} & -\frac{y}{z^2}
    \end{bmatrix}

.. note::
    This function has a precondition that the points are in front of the camera, i.e. z > 0.
    If this is not the case, the points will be projected to the canonical plane, but the resulting
    points will be behind the camera and causing numerical issues for z == 0.

Convention:
    - the result is the full Jacobian of :func:`~kornia.geometry.camera.project_points_z1` with shape
      ``(..., 2, 3)``, laid out row-major in the output index: the ``u`` row then the ``v`` row, each
      holding the derivatives with respect to ``x``, ``y`` and ``z``.
    - the same ``z > 0`` precondition applies, and it is not validated either.

Args:
    points_in_camera: torch.Tensor representing the points to project with shape ``(..., 3)``.

Returns:
    torch.Tensor representing the Jacobian of the projected point :math:`(u, v)` with respect to
    :math:`(x, y, z)`, with shape ``(..., 2, 3)``.

See Also:
    - :func:`project_points_z1`: the projection this differentiates.
    - :func:`dx_project_points_orthographic`: the orthographic counterpart, which returns ``du/dx`` alone.
    - :func:`dx_distort_points_affine`: the Jacobian of the next step of a camera model, the intrinsics.

Example:
    >>> points = torch.tensor([1., 2., 3.])
    >>> dx_project_points_z1(points)
    tensor([[ 0.3333,  0.0000, -0.1111],
            [ 0.0000,  0.3333, -0.2222]])

r   r   g      ð?r   ).é    ).r   ).r   r   éþÿÿÿ)r   r    Ú
zeros_likeÚstack)r	   ÚxÚyÚzÚz_invÚz_sqÚzeross   &      r   Údx_project_points_z1r4   ’   sŸ   € ô\ Ð'¨#¨s¨Ô4à˜Õ €AØ˜Õ €AØ˜Õ €Aà�!�G€EØ�=€DÜ×Ò˜UÓ#€EÜ�;Š;ä�KŠK˜¨ r¨D¥yÐ1°rÔ:Ü�KŠK˜¨ r¨D¥yÐ1°rÔ:ð	
ð ôð r   )N)Ú__doc__Ú
__future__r   Útypingr   r    Úkornia.core.checkr   r   r'   r4   r   r   r   Ú<module>r9      s,   ðñ$ sõ #å ã å 0õ4B÷n:H÷z=r   