in gss/selective_search_3d_run.py [0:0]
def _run_gss(args, scene_id, visualize=False):
for name, mask in zip(args['names'], args['masks']):
out_dir = os.path.join('computed_proposal_' + FLAGS.dataset, name)
if FLAGS.dataset == 'scannet':
os.makedirs(out_dir, exist_ok=True)
output_file = os.path.join(out_dir, scene_id+'_prop.npy')
input_file = os.path.join(FLAGS.data_path, FLAGS.dataset+'_all_points', scene_id+'_vert.npy')
else:
os.makedirs(os.path.join(out_dir, scene_id), exist_ok=True)
output_file = os.path.join(out_dir, scene_id, 'prop.npy')
input_file = os.path.join(FLAGS.data_path, FLAGS.dataset+'_all_points', scene_id, 'vert.npy')
if not os.path.isfile(output_file):
print(scene_id)
points = np.load(input_file)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points[:, :3])
pcd.colors = o3d.utility.Vector3dVector(points[:, 3:] / 255)
if visualize:
o3d.io.write_point_cloud(os.path.join(out_dir, scene_id, "pcd.ply"), pcd)
# use segmentation
if mask[1] == 1:
seg_file = os.path.join(FLAGS.seg_path, scene_id+'_sem_pred.npy') \
if FLAGS.dataset == 'scannet' \
else os.path.join(FLAGS.seg_path, scene_id, 'sem_label.npy')
seg_i = np.load(seg_file)
proposals = _selective_search_one(pcd, scene_id, mask, FLAGS, seg=seg_i)
else:
proposals = _selective_search_one(pcd, scene_id, mask, FLAGS)
boxes = np.stack([item[1] for item in proposals])
boxes = np.hstack((boxes, np.arange(boxes.shape[0]).reshape(-1, 1)))
if visualize:
write_bbox(boxes, os.path.join(out_dir, scene_id, 'props_raw.ply'))
# post-processing
boxes_post = post_process(boxes)
np.save(output_file, boxes_post)
print('saved to %s' % output_file)
if visualize:
write_bbox(boxes_post, os.path.join(out_dir, scene_id, 'props_post.ply'))