Skip to content

Commit

Permalink
remove usage of np.float deprecated in numpy 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
ylabbe committed May 11, 2023
1 parent 8b195d4 commit 99e01c8
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions bop_toolkit_lib/inout.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,13 +150,13 @@ def load_scene_camera(path):
for im_id in scene_camera.keys():
if 'cam_K' in scene_camera[im_id].keys():
scene_camera[im_id]['cam_K'] = \
np.array(scene_camera[im_id]['cam_K'], np.float).reshape((3, 3))
np.array(scene_camera[im_id]['cam_K'], np.float64).reshape((3, 3))
if 'cam_R_w2c' in scene_camera[im_id].keys():
scene_camera[im_id]['cam_R_w2c'] = \
np.array(scene_camera[im_id]['cam_R_w2c'], np.float).reshape((3, 3))
np.array(scene_camera[im_id]['cam_R_w2c'], np.float64).reshape((3, 3))
if 'cam_t_w2c' in scene_camera[im_id].keys():
scene_camera[im_id]['cam_t_w2c'] = \
np.array(scene_camera[im_id]['cam_t_w2c'], np.float).reshape((3, 1))
np.array(scene_camera[im_id]['cam_t_w2c'], np.float64).reshape((3, 1))
return scene_camera


Expand Down Expand Up @@ -192,9 +192,9 @@ def load_scene_gt(path):
for im_id, im_gt in scene_gt.items():
for gt in im_gt:
if 'cam_R_m2c' in gt.keys():
gt['cam_R_m2c'] = np.array(gt['cam_R_m2c'], np.float).reshape((3, 3))
gt['cam_R_m2c'] = np.array(gt['cam_R_m2c'], np.float64).reshape((3, 3))
if 'cam_t_m2c' in gt.keys():
gt['cam_t_m2c'] = np.array(gt['cam_t_m2c'], np.float).reshape((3, 1))
gt['cam_t_m2c'] = np.array(gt['cam_t_m2c'], np.float64).reshape((3, 1))
return scene_gt


Expand Down Expand Up @@ -248,9 +248,9 @@ def load_bop_results(path, version='bop19'):
'obj_id': int(elems[2]),
'score': float(elems[3]),
'R': np.array(
list(map(float, elems[4].split())), np.float).reshape((3, 3)),
list(map(float, elems[4].split())), np.float64).reshape((3, 3)),
't': np.array(
list(map(float, elems[5].split())), np.float).reshape((3, 1)),
list(map(float, elems[5].split())), np.float64).reshape((3, 1)),
'time': float(elems[6])
}

Expand Down Expand Up @@ -471,32 +471,32 @@ def load_ply(path):
model = {}
if texture_file is not None:
model['texture_file'] = texture_file
model['pts'] = np.zeros((n_pts, 3), np.float)
model['pts'] = np.zeros((n_pts, 3), np.float32)
if n_faces > 0:
model['faces'] = np.zeros((n_faces, face_n_corners), np.float)
model['faces'] = np.zeros((n_faces, face_n_corners), np.float32)

pt_props_names = [p[0] for p in pt_props]
face_props_names = [p[0] for p in face_props]

is_normal = False
if {'nx', 'ny', 'nz'}.issubset(set(pt_props_names)):
is_normal = True
model['normals'] = np.zeros((n_pts, 3), np.float)
model['normals'] = np.zeros((n_pts, 3), np.float32)

is_color = False
if {'red', 'green', 'blue'}.issubset(set(pt_props_names)):
is_color = True
model['colors'] = np.zeros((n_pts, 3), np.float)
model['colors'] = np.zeros((n_pts, 3), np.float32)

is_texture_pt = False
if {'texture_u', 'texture_v'}.issubset(set(pt_props_names)):
is_texture_pt = True
model['texture_uv'] = np.zeros((n_pts, 2), np.float)
model['texture_uv'] = np.zeros((n_pts, 2), np.float32)

is_texture_face = False
if {'texcoord'}.issubset(set(face_props_names)):
is_texture_face = True
model['texture_uv_face'] = np.zeros((n_faces, 6), np.float)
model['texture_uv_face'] = np.zeros((n_faces, 6), np.float32)

# Formats for the binary case.
formats = {
Expand Down

0 comments on commit 99e01c8

Please sign in to comment.