| """ |
| bash: |
| |
| python vis_preprocessed.py --npy ./Replica_OCC/preprocessed/office0.npy |
| """ |
|
|
| import argparse |
| import numpy as np |
| import open3d as o3d |
|
|
| def colorize_labels(labels: np.ndarray) -> np.ndarray: |
| """Deterministic pseudo-colors for integer labels.""" |
| labels = labels.astype(np.int64) |
| |
| r = ((labels * 97) % 255) / 255.0 |
| g = ((labels * 57) % 255) / 255.0 |
| b = ((labels * 17) % 255) / 255.0 |
| return np.stack([r, g, b], axis=1) |
|
|
| def main(): |
| ap = argparse.ArgumentParser() |
| ap.add_argument("--npy", type=str, required=True, help="path to preprocessed/<scene>.npy") |
| ap.add_argument("--max_points", type=int, default=300000, help="downsample for visualization") |
| args = ap.parse_args() |
|
|
| v = np.load(args.npy) |
| xyz = v[:, :3].astype(np.float32) |
| lab = v[:, 6].astype(np.int32) |
|
|
| |
| mask = lab > 0 |
| xyz = xyz[mask] |
| lab = lab[mask] |
|
|
| |
| if xyz.shape[0] > args.max_points: |
| idx = np.random.choice(xyz.shape[0], args.max_points, replace=False) |
| xyz = xyz[idx] |
| lab = lab[idx] |
|
|
| colors = colorize_labels(lab) |
|
|
| pcd = o3d.geometry.PointCloud() |
| pcd.points = o3d.utility.Vector3dVector(xyz) |
| pcd.colors = o3d.utility.Vector3dVector(colors) |
| print("points:", np.asarray(pcd.points).shape[0], "unique labels:", len(np.unique(lab))) |
|
|
| o3d.visualization.draw_geometries([pcd]) |
|
|
| if __name__ == "__main__": |
| main() |
|
|