| 503 | |
| 504 | # ───────────── Refresh Point Clouds (Confidence Slider) ───────────── |
| 505 | def refresh_pointclouds(): |
| 506 | pct = gui_conf.value |
| 507 | cur_subsample = current_subsample[0] |
| 508 | new_point_size = gui_point_size.value * (cur_subsample ** 0.5) |
| 509 | |
| 510 | for i in tqdm(range(S), leave=False, desc="Refreshing PCs"): |
| 511 | for cam_id in cam_ids: |
| 512 | if gui_show_cams[cam_id].value : |
| 513 | current_conf = conf_data[cam_id][i] |
| 514 | current_xyz_c = xyz_centered_data[cam_id][i] |
| 515 | current_img = img_data[cam_id][i] |
| 516 | |
| 517 | mask = gen_mask(current_conf, pct) |
| 518 | # Reshape arrays for masking: (H,W,3) -> (H*W,3) and (H,W) -> (H*W,) |
| 519 | pts_flat = current_xyz_c.reshape(-1, 3) |
| 520 | mask_flat = mask.reshape(-1) |
| 521 | rgb_img_for_pts = current_img |
| 522 | if rgb_img_for_pts.max() <= 1.0: rgb_img_for_pts = rgb_img_for_pts * 255 |
| 523 | rgb_flat = rgb_img_for_pts.astype(np.uint8).reshape(-1, 3) |
| 524 | |
| 525 | # Apply mask |
| 526 | pts = pts_flat[mask_flat] |
| 527 | rgb = rgb_flat[mask_flat] |
| 528 | |
| 529 | pcd_handles[cam_id][i].points = pts |
| 530 | pcd_handles[cam_id][i].colors = rgb |
| 531 | pcd_handles[cam_id][i].point_size = new_point_size |
| 532 | |
| 533 | # ───────────── GUI Callback Bindings ───────────── |
| 534 | @gui_next.on_click |