Open
Conversation
Dreycey
reviewed
Feb 24, 2026
|
|
||
| N_COMMON = 13 | ||
|
|
||
| COMMON_LABELS = { |
Collaborator
There was a problem hiding this comment.
@donceykong
So are we trying to use common labels between all of the datasets? Like some intermediate transformation?
Dreycey
reviewed
Feb 24, 2026
| "kitti360": "cenet_kitti360", | ||
| } | ||
|
|
||
| KITTI360_ORIGIN_LATLON = (48.9843445, 8.4295857) |
Collaborator
There was a problem hiding this comment.
Shouldn't this just come from the config file?
Dreycey
reviewed
Feb 24, 2026
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, "..", "..", "..")) |
Collaborator
There was a problem hiding this comment.
We should avoid hard-coding paths like this at all costs
Dreycey
reviewed
Feb 24, 2026
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 | ||
|
|
Collaborator
There was a problem hiding this comment.
Why not use the mercator projection provided in the CPP library and used in the other scripts?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
SEE THIS AWESOMENESS.