def convert_and_save(args, i): ptc = load_velo_scan(osp.join(args.input_path, "{:06d}.bin".format(i))) calib = Calibration(osp.join(args.calib_path, "{:06d}.txt".format(i))) img = load_image(osp.join(args.image_path, "{:06d}.png".format(i))) ptc = get_ptc_in_image(ptc, calib, img) depth_map = get_depth_map(ptc, calib, img) np.save(osp.join(args.output_path, "{:06d}".format(i)), depth_map)
def gen_sparse_points(data_idx, args): calib = Calibration(osp.join(args.calib_path, "{:06d}.txt".format(data_idx))) pc_velo = load_velo_scan(osp.join(args.ptc_path, "{:06d}.bin".format(data_idx))) img = load_image(osp.join(args.image_path, "{:06d}.png".format(data_idx))) img_height, img_width, img_channel = img.shape _, _, valid_inds_fov = get_lidar_in_image_fov( pc_velo[:, :3], calib, 0, 0, img_width, img_height, True) pc_velo = pc_velo[valid_inds_fov] if(args.div > 1): valid_inds = (pc_velo[:, 1] < 50) & \ (pc_velo[:, 1] >= -50) & \ (pc_velo[:, 2] < 1.5) & \ (pc_velo[:, 2] >= -2.5) else: valid_inds = (pc_velo[:, 0] < 120) & \ (pc_velo[:, 0] >= 0) & \ (pc_velo[:, 1] < 50) & \ (pc_velo[:, 1] >= -50) & \ (pc_velo[:, 2] < 1.5) & \ (pc_velo[:, 2] >= -2.5) pc_velo = pc_velo[valid_inds] if args.fill_in_map_dir is not None and (args.fill_in_spec is not None or args.fill_in_slice is not None): fill_in_line = np.load(os.path.join(args.fill_in_map_dir, "{:06d}.npy".format(data_idx))) else: fill_in_line = None if args.store_line_map_dir is not None: depth_map_lines, ptc = pto_ang_map(pc_velo, H=args.H, W=args.W, slice=args.slice, div=args.div,\ line_spec=args.line_spec, argo=args.argo, get_lines=True,\ fill_in_line=fill_in_line, fill_in_spec=args.fill_in_spec, fill_in_slice=args.fill_in_slice) np.save(osp.join(args.store_line_map_dir, "{:06d}".format(data_idx)), depth_map_lines) return ptc else: return pto_ang_map(pc_velo, H=args.H, W=args.W, slice=args.slice, div=args.div,\ line_spec=args.line_spec, argo=args.argo, get_lines=False, fill_in_line=fill_in_line, fill_in_spec=args.fill_in_spec, fill_in_slice=args.fill_in_slice)
def gen_sparse_points(data_idx, args): calib = Calibration( osp.join(args.calib_path, "{:06d}.txt".format(data_idx))) pc_velo = load_velo_scan( osp.join(args.ptc_path, "{:06d}.bin".format(data_idx))) # print('pc_velo', pc_velo.shape) img = load_image(osp.join(args.image_path, "{:06d}.png".format(data_idx))) img_height, img_width, img_channel = img.shape # print('img', img.shape) _, _, valid_inds_fov = get_lidar_in_image_fov(pc_velo[:, :3], calib, 0, 0, img_width, img_height, True) pc_velo = pc_velo[valid_inds_fov] valid_inds = (pc_velo[:, 0] < 120) & \ (pc_velo[:, 0] >= 0) & \ (pc_velo[:, 1] < 50) & \ (pc_velo[:, 1] >= -50) & \ (pc_velo[:, 2] < 1.5) & \ (pc_velo[:, 2] >= -2.5) pc_velo = pc_velo[valid_inds] # print('pc_velo', pc_velo.shape) if args.fill_in_map_dir is not None and (args.fill_in_spec is not None or args.fill_in_slice is not None): fill_in_line = np.load( os.path.join(args.fill_in_map_dir, "{:06d}.npy".format(data_idx))) else: fill_in_line = None if args.store_line_map_dir is not None: depth_map_lines, ptc = pto_ang_map(data_idx, pc_velo, H=args.H, W=args.W, slice=args.slice, line_spec=args.line_spec, get_lines=True, fill_in_line=fill_in_line, fill_in_spec=args.fill_in_spec, fill_in_slice=args.fill_in_slice) np.save(osp.join(args.store_line_map_dir, "{:06d}".format(data_idx)), depth_map_lines) return ptc else: depth_map = pto_ang_map(data_idx, pc_velo, H=args.H, W=args.W, slice=args.slice, line_spec=args.line_spec, get_lines=False, fill_in_line=fill_in_line, fill_in_spec=args.fill_in_spec, fill_in_slice=args.fill_in_slice) # should save a 3D array in size (H, M, 4) np.save(osp.join(args.output_path, "{:06d}".format(data_idx)), depth_map) return depth_map
ptc = load_velo_scan(osp.join(args.input_path, "{:06d}.bin".format(i))) calib = Calibration(osp.join(args.calib_path, "{:06d}.txt".format(i))) img = load_image(osp.join(args.image_path, "{:06d}.png".format(i))) ptc = get_ptc_in_image(ptc, calib, img) depth_map = get_depth_map(ptc, calib, img) np.save(osp.join(args.output_path, "{:06d}".format(i)), depth_map) if __name__ == "__main__": if not os.path.exists(args.output_path): os.makedirs(args.output_path) if args.i is not None: i = args.i ptc = load_velo_scan(osp.join(args.input_path, "{:06d}.bin".format(i))) calib = Calibration(osp.join(args.calib_path, "{:06d}.txt".format(i))) img = load_image(osp.join(args.image_path, "{:06d}.png".format(i))) ptc = get_ptc_in_image(ptc, calib, img) depth_map = get_depth_map(ptc, calib, img) np.save(osp.join(args.output_path, "{:06d}".format(i)), depth_map) else: with open(args.split_file) as f: idx_list = [ int(x.strip()) for x in f.readlines() if len(x.strip()) > 0 ] pbar = tqdm(total=len(idx_list)) def update(*a): pbar.update() pool = Pool(args.threads) res = []
def get_right_image(self, idx): img_filename = os.path.join(self.right_image_dir, '%06d.png' % (idx)) return utils.load_image(img_filename)