forked from HQU-gxy/CVTH3PE
x
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
from collections import OrderedDict, defaultdict
|
||||
from dataclasses import dataclass
|
||||
from datetime import datetime
|
||||
import string
|
||||
from typing import Any, TypeAlias, TypedDict, Optional, Sequence
|
||||
|
||||
from beartype import beartype
|
||||
@ -522,10 +523,14 @@ def to_homogeneous(points: Num[Array, "N 2"] | Num[Array, "N 3"]) -> Num[Array,
|
||||
raise ValueError(f"Invalid shape for points: {points.shape}")
|
||||
|
||||
|
||||
import awkward as ak
|
||||
|
||||
|
||||
@jaxtyped(typechecker=beartype)
|
||||
def point_line_distance(
|
||||
points: Num[Array, "N 3"] | Num[Array, "N 2"],
|
||||
line: Num[Array, "N 3"],
|
||||
description: str,
|
||||
eps: float = 1e-9,
|
||||
):
|
||||
"""
|
||||
@ -544,6 +549,12 @@ def point_line_distance(
|
||||
"""
|
||||
numerator = abs(line[:, 0] * points[:, 0] + line[:, 1] * points[:, 1] + line[:, 2])
|
||||
denominator = jnp.sqrt(line[:, 0] * line[:, 0] + line[:, 1] * line[:, 1])
|
||||
# line_data = {"a": line[:, 0], "b": line[:, 1], "c": line[:, 2]}
|
||||
# line_x_y = {"x": points[:, 0], "y": points[:, 1]}
|
||||
# ak.to_parquet(
|
||||
# line_data, f"/home/admin/Code/CVTH3PE/line_a_b_c_{description}.parquet"
|
||||
# )
|
||||
# ak.to_parquet(line_x_y, f"/home/admin/Code/CVTH3PE/line_x_y_{description}.parquet")
|
||||
return numerator / (denominator + eps)
|
||||
|
||||
|
||||
@ -571,7 +582,7 @@ def left_to_right_epipolar_distance(
|
||||
"""
|
||||
F_t = fundamental_matrix.transpose()
|
||||
line1_in_2 = jnp.matmul(left, F_t)
|
||||
return point_line_distance(right, line1_in_2)
|
||||
return point_line_distance(right, line1_in_2, "left_to_right")
|
||||
|
||||
|
||||
@jaxtyped(typechecker=beartype)
|
||||
@ -597,7 +608,7 @@ def right_to_left_epipolar_distance(
|
||||
$$x^{\\prime T}Fx = 0$$
|
||||
"""
|
||||
line2_in_1 = jnp.matmul(right, fundamental_matrix)
|
||||
return point_line_distance(left, line2_in_1)
|
||||
return point_line_distance(left, line2_in_1, "right_to_left")
|
||||
|
||||
|
||||
def distance_between_epipolar_lines(
|
||||
|
||||
Reference in New Issue
Block a user