Skip to content

Commit d1797e0

Browse files
authored
Merge pull request andyzeng#15 from yenchenlin/fix-weight-bug
fix weight bug
2 parents b5266ad + 388e151 commit d1797e0

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

fusion.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def integrate_tsdf(tsdf_vol, dist, w_old, obs_weight):
201201
w_new = np.empty_like(w_old, dtype=np.float32)
202202
for i in prange(len(tsdf_vol)):
203203
w_new[i] = w_old[i] + obs_weight
204-
tsdf_vol_int[i] = (w_old[i] * tsdf_vol[i] + dist[i]) / w_new[i]
204+
tsdf_vol_int[i] = (w_old[i] * tsdf_vol[i] + obs_weight * dist[i]) / w_new[i]
205205
return tsdf_vol_int, w_new
206206

207207
def integrate(self, color_im, depth_im, cam_intr, cam_pose, obs_weight=1.):
@@ -287,9 +287,9 @@ def integrate(self, color_im, depth_im, cam_intr, cam_pose, obs_weight=1.):
287287
new_b = np.floor(new_color / self._color_const)
288288
new_g = np.floor((new_color - new_b*self._color_const) /256)
289289
new_r = new_color - new_b*self._color_const - new_g*256
290-
new_b = np.minimum(255., np.round((w_old*old_b + new_b) / w_new))
291-
new_g = np.minimum(255., np.round((w_old*old_g + new_g) / w_new))
292-
new_r = np.minimum(255., np.round((w_old*old_r + new_r) / w_new))
290+
new_b = np.minimum(255., np.round((w_old*old_b + obs_weight*new_b) / w_new))
291+
new_g = np.minimum(255., np.round((w_old*old_g + obs_weight*new_g) / w_new))
292+
new_r = np.minimum(255., np.round((w_old*old_r + obs_weight*new_r) / w_new))
293293
self._color_vol_cpu[valid_vox_x, valid_vox_y, valid_vox_z] = new_b*self._color_const + new_g*256 + new_r
294294

295295
def get_volume(self):
@@ -422,4 +422,4 @@ def pcwrite(filename, xyzrgb):
422422
ply_file.write("%f %f %f %d %d %d\n"%(
423423
xyz[i, 0], xyz[i, 1], xyz[i, 2],
424424
rgb[i, 0], rgb[i, 1], rgb[i, 2],
425-
))
425+
))

0 commit comments

Comments
 (0)