(image_folder, depth_folder, config, specific=None, aft_certain=None)
| 836 | return far_edge, uncleaned_far_edge, far_edge_with_id, near_edge_with_id |
| 837 | |
| 838 | def get_MiDaS_samples(image_folder, depth_folder, config, specific=None, aft_certain=None): |
| 839 | lines = [os.path.splitext(os.path.basename(xx))[0] for xx in glob.glob(os.path.join(image_folder, '*' + config['img_format']))] |
| 840 | samples = [] |
| 841 | generic_pose = np.eye(4) |
| 842 | assert len(config['traj_types']) == len(config['x_shift_range']) ==\ |
| 843 | len(config['y_shift_range']) == len(config['z_shift_range']) == len(config['video_postfix']), \ |
| 844 | "The number of elements in 'traj_types', 'x_shift_range', 'y_shift_range', 'z_shift_range' and \ |
| 845 | 'video_postfix' should be equal." |
| 846 | tgt_pose = [[generic_pose * 1]] |
| 847 | tgts_poses = [] |
| 848 | for traj_idx in range(len(config['traj_types'])): |
| 849 | tgt_poses = [] |
| 850 | sx, sy, sz = path_planning(config['num_frames'], config['x_shift_range'][traj_idx], config['y_shift_range'][traj_idx], |
| 851 | config['z_shift_range'][traj_idx], path_type=config['traj_types'][traj_idx]) |
| 852 | for xx, yy, zz in zip(sx, sy, sz): |
| 853 | tgt_poses.append(generic_pose * 1.) |
| 854 | tgt_poses[-1][:3, -1] = np.array([xx, yy, zz]) |
| 855 | tgts_poses += [tgt_poses] |
| 856 | tgt_pose = generic_pose * 1 |
| 857 | |
| 858 | aft_flag = True |
| 859 | if aft_certain is not None and len(aft_certain) > 0: |
| 860 | aft_flag = False |
| 861 | for seq_dir in lines: |
| 862 | if specific is not None and len(specific) > 0: |
| 863 | if specific != seq_dir: |
| 864 | continue |
| 865 | if aft_certain is not None and len(aft_certain) > 0: |
| 866 | if aft_certain == seq_dir: |
| 867 | aft_flag = True |
| 868 | if aft_flag is False: |
| 869 | continue |
| 870 | samples.append({}) |
| 871 | sdict = samples[-1] |
| 872 | sdict['depth_fi'] = os.path.join(depth_folder, seq_dir + config['depth_format']) |
| 873 | sdict['ref_img_fi'] = os.path.join(image_folder, seq_dir + config['img_format']) |
| 874 | H, W = imageio.imread(sdict['ref_img_fi']).shape[:2] |
| 875 | sdict['int_mtx'] = np.array([[max(H, W), 0, W//2], [0, max(H, W), H//2], [0, 0, 1]]).astype(np.float32) |
| 876 | if sdict['int_mtx'].max() > 1: |
| 877 | sdict['int_mtx'][0, :] = sdict['int_mtx'][0, :] / float(W) |
| 878 | sdict['int_mtx'][1, :] = sdict['int_mtx'][1, :] / float(H) |
| 879 | sdict['ref_pose'] = np.eye(4) |
| 880 | sdict['tgt_pose'] = tgt_pose |
| 881 | sdict['tgts_poses'] = tgts_poses |
| 882 | sdict['video_postfix'] = config['video_postfix'] |
| 883 | sdict['tgt_name'] = [os.path.splitext(os.path.basename(sdict['depth_fi']))[0]] |
| 884 | sdict['src_pair_name'] = sdict['tgt_name'][0] |
| 885 | |
| 886 | return samples |
| 887 | |
| 888 | def get_valid_size(imap): |
| 889 | x_max = np.where(imap.sum(1).squeeze() > 0)[0].max() + 1 |
no test coverage detected