@@ -143,23 +143,25 @@ def cast_to_max(arr):
143
143
return arr .astype (np .uint32 )
144
144
145
145
# Dump the camera mappings information for each camera
146
- # compressing the numbers by rounding to nearest int
146
+ # compressing the numbers by rounding to nearest int * mul
147
147
# and then by attempting to offset the values
148
148
# the original value of the map can then be computed with:
149
- # map1[px_y, px_x] <--> compressed_map1[px_y,px_x] + offset[0] + px_x
150
- # map2[px_y, px_x] <--> compressed_map2[px_y,px_x] + offset[1] + px_y
151
- # (note our values are rounded to the closest pixel, though )
149
+ # map1[px_y, px_x] <--> (( compressed_map1[px_y,px_x] + offset[0]) / 10.0) + px_x
150
+ # map2[px_y, px_x] <--> (( compressed_map2[px_y,px_x] + offset[1]) / 10.0) + px_y
151
+ # (note our values are rounded to 1/10th of a pixel )
152
152
idx = 0
153
153
for key , v in _camera_mapping_cache .items ():
154
154
ids .append (v ['id' ])
155
155
map1 , map2 = v ['map' ]
156
- map1 = np .round (map1 )
157
- map2 = np .round (map2 )
156
+ mul = 10.0 # keep precision up to 1/10th of a pixel
158
157
159
158
i = np .arange (map1 .shape [0 ]).reshape (- 1 , 1 )
160
159
j = np .arange (map1 .shape [1 ])
161
160
map1 -= j
162
161
map2 -= i
162
+ map1 = np .round (map1 * mul )
163
+ map2 = np .round (map2 * mul )
164
+
163
165
offset = np .array ([np .min (map1 ), np .min (map2 )])
164
166
map1 -= offset [0 ]
165
167
map2 -= offset [1 ]
@@ -170,6 +172,7 @@ def cast_to_max(arr):
170
172
outs ['%s_x' % idx ] = map1
171
173
outs ['%s_y' % idx ] = map2
172
174
outs ['%s_offset' % idx ] = offset
175
+ outs ['%s_mul' % idx ] = np .array ([mul ])
173
176
174
177
idx += 1
175
178
0 commit comments