Skip to content

Commit

Permalink
Use better names for camera mappings dump
Browse files Browse the repository at this point in the history
  • Loading branch information
pierotofy committed Jun 10, 2024
1 parent 9a0e2f0 commit 1750fb2
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions opensfm/undistort.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,7 @@ def dump_camera_mapping_cache(dest_file):
global _camera_mapping_cache

ids = []
x_maps = []
y_maps = []
offsets = []
outs = {}

def cast_to_max(arr):
m = np.max(arr)
Expand All @@ -151,6 +149,7 @@ def cast_to_max(arr):
# map1[px_y, px_x] <--> compressed_map1[px_y,px_x] + offset[0] + px_x
# map2[px_y, px_x] <--> compressed_map2[px_y,px_x] + offset[1] + px_y
# (note our values are rounded to the closest pixel, though)
idx = 0
for key, v in _camera_mapping_cache.items():
ids.append(v['id'])
map1, map2 = v['map']
Expand All @@ -168,11 +167,13 @@ def cast_to_max(arr):
map1 = cast_to_max(map1)
map2 = cast_to_max(map2)

x_maps.append(map1)
y_maps.append(map2)
offsets.append(offset)
outs['%s_x' % idx] = map1
outs['%s_y' % idx] = map2
outs['%s_offset' % idx] = offset

np.savez_compressed(dest_file, ids=ids, *x_maps, *y_maps, *offsets)
idx += 1

np.savez_compressed(dest_file, ids=ids, **outs)

def undistort_image_and_masks(arguments) -> None:
shot, undistorted_shots, data, udata, imageFilter = arguments
Expand Down

0 comments on commit 1750fb2

Please sign in to comment.