Camera Handles

class viser.CameraHandle[source]

A handle for reading and writing the camera state of a particular client. Typically accessed via ClientHandle.camera.

property client: ClientHandle

Client that this camera corresponds to.

property wxyz: ndarray[Any, dtype[float64]]

Corresponds to the R in P_world = [R | t] p_camera. Synchronized automatically when assigned.

property position: ndarray[Any, dtype[float64]]

Corresponds to the t in P_world = [R | t] p_camera. Synchronized automatically when assigned.

The look_at point and up_direction vectors are maintained when updating position, which means that updates to position will often also affect wxyz.

property fov: float

Vertical field of view of the camera, in radians. Synchronized automatically when assigned.

property aspect: float

Canvas width divided by height. Not assignable.

property update_timestamp: float
property look_at: ndarray[Any, dtype[float64]]

Look at point for the camera. Synchronized automatically when set.

property up_direction: ndarray[Any, dtype[float64]]

Up direction for the camera. Synchronized automatically when set.

on_update(callback: Callable[[CameraHandle], None]) Callable[[CameraHandle], None][source]

Attach a callback to run when a new camera message is received.

Parameters:

callback (Callable[[CameraHandle], None])

Return type:

Callable[[CameraHandle], None]

get_render(height: int, width: int, transport_format: Literal[‘png’, ‘jpeg’] = 'jpeg') ndarray[source]

Request a render from a client, block until it’s done and received, then return it as a numpy array.

Parameters:
  • height (int) – Height of rendered image. Should be <= the browser height.

  • width (int) – Width of rendered image. Should be <= the browser width.

  • transport_format (Literal[‘png’, ‘jpeg’]) – Image transport format. JPEG will return a lossy (H, W, 3) RGB array. PNG will return a lossless (H, W, 4) RGBA array, but can cause memory issues on the frontend if called too quickly for higher-resolution images.

Return type:

ndarray