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[tuple[int, ...], dtype[float64]]¶
Corresponds to the R in
P_world = [R | t] p_camera
. Synchronized automatically when assigned.
- property position: ndarray[tuple[int, ...], dtype[float64]]¶
Corresponds to the t in
P_world = [R | t] p_camera
. Synchronized automatically when assigned.The
look_at
point andup_direction
vectors are maintained when updatingposition
, which means that updates toposition
will often also affectwxyz
.
- property fov: float¶
Vertical field of view of the camera, in radians. Synchronized automatically when assigned.
- property near: float¶
Near clipping plane distance. Synchronized automatically when assigned.
- property far: float¶
Far clipping plane distance. Synchronized automatically when assigned.
- property aspect: float¶
Canvas width divided by height. Not assignable.
- property update_timestamp: float¶
- property look_at: ndarray[tuple[int, ...], dtype[float64]]¶
Look at point for the camera. Synchronized automatically when set.
- property up_direction: ndarray[tuple[int, ...], dtype[float64]]¶
Up direction for the camera. Synchronized automatically when set.
- on_update(callback: Callable[[CameraHandle], NoneOrCoroutine]) Callable[[CameraHandle], NoneOrCoroutine] [source]¶
Attach a callback to run when a new camera message is received.
The callback can be either a standard function or an async function:
Standard functions (def) will be executed in a threadpool.
Async functions (async def) will be executed in the event loop.
Using async functions can be useful for reducing race conditions.
- Parameters:
callback (Callable[[CameraHandle], NoneOrCoroutine])
- Return type:
Callable[[CameraHandle], NoneOrCoroutine]
- 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. This is an alias for
ClientHandle.get_render()
.- 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