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

Function _compute_depth_quantiles

src/sharp/utils/camera.py:368–386  ·  view source on GitHub ↗

Compute disparity quantiles for scene and extrinsics id.

(
    points: torch.Tensor,
    extrinsics: torch.Tensor,
    q_near: float = 0.001,
    q_focus: float = 0.1,
    q_far: float = 0.999,
)

Source from the content-addressed store, hash-verified

366
367
368def _compute_depth_quantiles(
369 points: torch.Tensor,
370 extrinsics: torch.Tensor,
371 q_near: float = 0.001,
372 q_focus: float = 0.1,
373 q_far: float = 0.999,
374) -> FocusRange:
375 """Compute disparity quantiles for scene and extrinsics id."""
376 points_local = points @ extrinsics[:3, :3].T + extrinsics[:3, 3]
377 depth_values = points_local[..., 2].flatten()
378 depth_values = depth_values[depth_values > 0]
379 q_values = torch.tensor([q_near, q_focus, q_far])
380 depth_quantiles_pt = torch.quantile(depth_values.cpu(), q_values)
381 depth_quantiles = FocusRange(
382 min=float(depth_quantiles_pt[0]),
383 focus=float(depth_quantiles_pt[1]),
384 max=float(depth_quantiles_pt[2]),
385 )
386 return depth_quantiles

Callers 3

compute_max_offsetFunction · 0.85
__init__Method · 0.85
set_screen_extrinsicsMethod · 0.85

Calls 1

FocusRangeClass · 0.85

Tested by

no test coverage detected