ZiyuG/SAM2Point
16
1import os2import shutil3import numpy as np4import scipy.io as sio5import torch6 7 8def load_S3DIS_sample(text_path, sample=False):9 data = np.loadtxt(text_path)10 point, color = data[:, :3], data[:, 3:]11 12 point = point - point.min(axis=0)13 point = point / point.max(axis=0)14 color = color / 255.15 16 return point, color17 18def load_ScanNet_sample(data_path):19 20 all_data = torch.load(data_path)21 22 point = np.array(all_data['coord'])23 color = np.array(all_data['color'])24 25 point = point - point.min(axis=0)26 point = point / point.max(axis=0)27 color = color / 255.28 return point, color29 30def load_KITTI_sample(data_path, close=False):31 all_data = np.load(data_path)32 33 point = all_data[:, :3]34 color = all_data[:, 3:6]35 36 pmin = point.min(axis=0)37 point = point - pmin38 pmax = point.max(axis=0)39 point = point / pmax40 41 return point, color42 43def load_Objaverse_sample(data_path):44 all_data = np.load(data_path)45 46 point = all_data[:, :3]47 color = all_data[:, 3:6]48 49 pmin = point.min(axis=0)50 point = point - pmin51 pmax = point.max(axis=0)52 point = point / pmax53 54 return point, color55 56def load_Semantic3D_sample(data_path, id, sample=False):57 all_data = np.load(data_path)58 59 point = all_data[:, :3]60 color = all_data[:, 3:6]61 62 pmin = point.min(axis=0)63 point = point - pmin64 pmax = point.max(axis=0)65 point = point / pmax66 67 if id > 1: return point, color68 if id == 0:69 filter_mask = (point[:, 0] > 0.4) & (point[:, 1] > 0.4) & (point[:, 2] < 0.4)70 else:71 filter_mask = (point[:, 0] > 0.4) & (point[:, 1] < 0.5)72 point = point[filter_mask]73 color = color[filter_mask]74 75 pmin = point.min(axis=0)76 point = point - pmin77 pmax = point.max(axis=0)78 point = point / pmax79 80 return point, color