Skip to content

Commit

Permalink
tidied up the visualisation and normal rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMariday committed Jun 14, 2024
1 parent 4d4b3b4 commit 56bcca3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/led_map_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def get_center(self):
return np.average(self.get_xyz_list(), axis=0)

def get_normal_list(self):
return [self[led_id]["normal"] for led_id in self.keys()]
return np.array([self[led_id]["normal"] for led_id in self.keys()])

def _load(self, filename):
logging.debug(f"Reading 3D map {filename}...")
Expand Down
2 changes: 1 addition & 1 deletion lib/map_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def rescale(led_map, led_to_led_dist=1.0):

for led_id in led_map.data:
led_map[led_id]["pos"] *= scale
led_map[led_id]["normal"] *= scale
led_map[led_id]["normal"] *= led_to_led_dist
led_map[led_id]["error"] *= scale

for cam in led_map.cameras:
Expand Down
6 changes: 5 additions & 1 deletion lib/sfm/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def binary_to_led_map_3d(path):
led_map[led_id]["error"] = np.average(led_map[led_id]["error"], axis=0)
led_map[led_id]["views"] = list(set(led_map[led_id]["views"]))

translation_offset = np.average([led_map[led_id]["pos"] for led_id in led_map], axis=0)
translation_offset = np.average(
[led_map[led_id]["pos"] for led_id in led_map], axis=0
)

for led_id in led_map:
led_map[led_id]["pos"] -= translation_offset
Expand Down Expand Up @@ -63,6 +65,8 @@ def binary_to_led_map_3d(path):
np.average(all_views, axis=0) - led_map[led_id]["pos"]
)

led_map[led_id]["normal"] /= np.linalg.norm(led_map[led_id]["normal"])

led_map_3d = LEDMap3D(fix_normals(led_map))
led_map_3d.cameras = cameras

Expand Down
4 changes: 3 additions & 1 deletion lib/visualize_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ def reload_geometry__(self, first=False):
self.line_set.colors = open3d.utility.Vector3dVector(c)

self.point_cloud.points = open3d.utility.Vector3dVector(led_map.get_xyz_list())
self.point_cloud.normals = open3d.utility.Vector3dVector(led_map.get_normal_list())
self.point_cloud.normals = open3d.utility.Vector3dVector(
led_map.get_normal_list() * 0.2
)

if first:
self._vis.add_geometry(self.point_cloud)
Expand Down

0 comments on commit 56bcca3

Please sign in to comment.