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

Method __init__

src/sharp/utils/camera.py:274–319  ·  view source on GitHub ↗

Initialize GeneralPinholeCameraModel. Args: scene: The scene to display. screen_extrinsics: Extrinsics of the default position. screen_intrinsics: Intrinsics to use for rendering. screen_resolution_px: Width and height to render. f

(
        self,
        scene: Gaussians3D,
        screen_extrinsics: torch.Tensor,
        screen_intrinsics: torch.Tensor,
        screen_resolution_px: tuple[int, int],
        focus_depth_quantile: float = 0.1,
        min_depth_focus: float = 2.0,
        lookat_point: tuple[float, float, float] | None = None,
        lookat_mode: LookAtMode = "point",
    )

Source from the content-addressed store, hash-verified

272 """Camera model that focuses on point."""
273
274 def __init__(
275 self,
276 scene: Gaussians3D,
277 screen_extrinsics: torch.Tensor,
278 screen_intrinsics: torch.Tensor,
279 screen_resolution_px: tuple[int, int],
280 focus_depth_quantile: float = 0.1,
281 min_depth_focus: float = 2.0,
282 lookat_point: tuple[float, float, float] | None = None,
283 lookat_mode: LookAtMode = "point",
284 ) -> None:
285 """Initialize GeneralPinholeCameraModel.
286
287 Args:
288 scene: The scene to display.
289 screen_extrinsics: Extrinsics of the default position.
290 screen_intrinsics: Intrinsics to use for rendering.
291 screen_resolution_px: Width and height to render.
292 focus_depth_quantile: Where inside the depth range to focus on.
293 min_depth_focus: Depth to focus at.
294 lookat_point: a point that the camera's Z axis directs towards.
295 lookat_mode: "point" to look at a fixed point,
296 "ahead" to look straight ahead.
297 """
298 self.scene = scene
299 self.screen_extrinsics = screen_extrinsics
300 self.screen_intrinsics = screen_intrinsics
301 self.screen_resolution_px = screen_resolution_px
302
303 self.focus_depth_quantile = focus_depth_quantile
304 self.min_depth_focus = min_depth_focus
305 self.lookat_point = lookat_point
306 self.lookat_mode = lookat_mode
307
308 scene_points = scene.mean_vectors
309 if scene_points.ndim == 3:
310 scene_points = scene_points[0]
311 elif scene_points.ndim != 2:
312 raise ValueError("Unsupported dimensionality of scene points.")
313 self._scene_points = scene_points.cpu()
314
315 self.depth_quantiles = _compute_depth_quantiles(
316 self._scene_points,
317 self.screen_extrinsics,
318 q_focus=self.focus_depth_quantile,
319 )
320
321 def compute(self, eye_pos: torch.Tensor) -> CameraInfo:
322 """Compute camera for eye position."""

Callers

nothing calls this directly

Calls 1

_compute_depth_quantilesFunction · 0.85

Tested by

no test coverage detected