1
0
forked from HQU-gxy/CVTH3PE

refactor: Update type hints and streamline distance calculations in playground.py

- Changed the return type of `perpendicular_distance_point_to_line_two_points` to `jnp.floating[Any]` for improved type accuracy.
- Refactored the `perpendicular_distance_camera_2d_points_to_tracking_raycasting` function to store distances in a typed variable, enhancing clarity and type safety.
- Improved the overall readability of the distance calculation logic by returning the computed distances directly.
This commit is contained in:
2025-04-27 18:00:56 +08:00
parent d4ade248dc
commit 9639bcb794

View File

@ -620,7 +620,7 @@ def calculate_affinity_2d(
@jaxtyped(typechecker=beartype)
def perpendicular_distance_point_to_line_two_points(
point: Num[Array, "3"], line: tuple[Num[Array, "3"], Num[Array, "3"]]
) -> Float[Array, ""]:
) -> jnp.floating[Any]:
"""
Calculate the perpendicular distance between a point and a line.
@ -674,9 +674,11 @@ def perpendicular_distance_camera_2d_points_to_tracking_raycasting(
# Vectorize over all keypoints
vmap_calc_distance = jax.vmap(calc_distance)
distances: Float[Array, "J"] = cast(
Any, vmap_calc_distance(predicted_pose, back_projected_points)
)
# Calculate and return distances for all keypoints
return vmap_calc_distance(predicted_pose, back_projected_points)
return distances
@jaxtyped(typechecker=beartype)