MCPcopy Create free account
hub / github.com/apple/ml-sharp / compute_max_offset

Function compute_max_offset

src/sharp/utils/camera.py:53–71  ·  view source on GitHub ↗

Compute the maximum offset for camera along X/Y/Z axis.

(
    scene: Gaussians3D,
    params: TrajectoryParams,
    resolution_px: tuple[int, int],
    f_px: float,
)

Source from the content-addressed store, hash-verified

51
52
53def compute_max_offset(
54 scene: Gaussians3D,
55 params: TrajectoryParams,
56 resolution_px: tuple[int, int],
57 f_px: float,
58) -> np.ndarray:
59 """Compute the maximum offset for camera along X/Y/Z axis."""
60 scene_points = scene.mean_vectors
61 extrinsics = torch.eye(4).to(scene_points.device)
62 min_depth, _, _ = _compute_depth_quantiles(scene_points, extrinsics)
63
64 r_px = resolution_px
65 diagonal = np.sqrt((r_px[0] / f_px) ** 2 + (r_px[1] / f_px) ** 2)
66 max_lateral_offset_m = params.max_disparity * diagonal * min_depth
67
68 max_medial_offset_m = params.max_zoom * min_depth
69 max_offset_xyz_m = np.array([max_lateral_offset_m, max_lateral_offset_m, max_medial_offset_m])
70
71 return max_offset_xyz_m
72
73
74def create_eye_trajectory(

Callers 1

create_eye_trajectoryFunction · 0.85

Calls 2

_compute_depth_quantilesFunction · 0.85
toMethod · 0.80

Tested by

no test coverage detected