Skip to content

Test/uncertainty examples#4

Open
donceykong wants to merge 37 commits intomainfrom
test/uncertainty_examples
Open

Test/uncertainty examples#4
donceykong wants to merge 37 commits intomainfrom
test/uncertainty_examples

Conversation

@donceykong
Copy link

SEE THIS AWESOMENESS.


N_COMMON = 13

COMMON_LABELS = {
Copy link
Collaborator

@Dreycey Dreycey Feb 24, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@donceykong
So are we trying to use common labels between all of the datasets? Like some intermediate transformation?

"kitti360": "cenet_kitti360",
}

KITTI360_ORIGIN_LATLON = (48.9843445, 8.4295857)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this just come from the config file?

Comment on lines +17 to +18
_SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
OSMBKI_ROOT = os.path.abspath(os.path.join(_SCRIPT_DIR, "..", "..", ".."))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should avoid hard-coding paths like this at all costs

Comment on lines +115 to +186
# ---------------------------------------------------------------------------
# Mercator projection
# ---------------------------------------------------------------------------

def lat_to_scale(lat_deg):
"""Mercator scale factor at given latitude."""
return math.cos(math.radians(lat_deg))


def latlon_to_mercator_absolute(lat_deg, lon_deg, scale):
"""Convert lat/lon to Web Mercator x, y in meters."""
lon_rad = math.radians(lon_deg)
lat_rad = math.radians(lat_deg)
x = scale * lon_rad * EARTH_RADIUS_M
y = scale * EARTH_RADIUS_M * math.log(math.tan(math.pi / 4 + lat_rad / 2))
return x, y


def latlon_to_mercator_relative(lat_deg, lon_deg, origin_lat, origin_lon):
"""Convert lat/lon to meters relative to an origin point via Web Mercator."""
scale = lat_to_scale(origin_lat)
ox, oy = latlon_to_mercator_absolute(origin_lat, origin_lon, scale)
mx, my = latlon_to_mercator_absolute(lat_deg, lon_deg, scale)
return mx - ox, my - oy


def mercator_relative_to_latlon(rel_x, rel_y, origin_lat, origin_lon):
"""Inverse of latlon_to_mercator_relative."""
scale = lat_to_scale(origin_lat)
origin_lon_rad = math.radians(origin_lon)
origin_lat_rad = math.radians(origin_lat)
lon_rad = rel_x / (scale * EARTH_RADIUS_M) + origin_lon_rad
log_origin = math.log(math.tan(math.pi / 4 + origin_lat_rad / 2))
lat_rad = 2.0 * math.atan(math.exp(rel_y / (scale * EARTH_RADIUS_M) + log_origin)) - math.pi / 2
return math.degrees(lat_rad), math.degrees(lon_rad)

# ---------------------------------------------------------------------------
# OSM geometry rendering
# ---------------------------------------------------------------------------

def create_thick_lines(points, lines, color, radius=2.0):
"""Build Open3D triangle mesh for line segments (cylinders)."""
meshes = []
points = np.array(points, dtype=np.float64)
for line in lines:
start, end = points[line[0]], points[line[1]]
vec = end - start
length = np.linalg.norm(vec)
if length < 1e-6:
continue
cyl = o3d.geometry.TriangleMesh.create_cylinder(radius=radius, height=length, resolution=8)
cyl.paint_uniform_color(color)
z_axis = np.array([0.0, 0.0, 1.0])
direction = vec / length
rot_axis = np.cross(z_axis, direction)
rot_angle = np.arccos(np.clip(np.dot(z_axis, direction), -1.0, 1.0))
if np.linalg.norm(rot_axis) > 1e-6:
rot_axis = rot_axis / np.linalg.norm(rot_axis)
R_mat = o3d.geometry.get_rotation_matrix_from_axis_angle(rot_axis * rot_angle)
cyl.rotate(R_mat, center=[0, 0, 0])
elif np.dot(z_axis, direction) < 0:
R_mat = o3d.geometry.get_rotation_matrix_from_axis_angle(np.array([1.0, 0.0, 0.0]) * np.pi)
cyl.rotate(R_mat, center=[0, 0, 0])
cyl.translate((start + end) / 2)
meshes.append(cyl)
if not meshes:
return None
out = meshes[0]
for m in meshes[1:]:
out += m
return out

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not use the mercator projection provided in the CPP library and used in the other scripts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants