Skip to content

Feature Proposal: Smooth Camera Animations & Image Carousel GUI #548

@illusive-chase

Description

@illusive-chase

Hi there,

Thanks for creating and maintaining this excellent library! I've been using viser extensively in my research on multi-view reconstruction, and it has been incredibly helpful. As I've worked with visualizing camera poses, I've identified two potential enhancements that might be useful.

1. Smooth, Frontend-Based Camera Transitions

The current documentation provides a great example for programmatic camera control by updating the camera pose in a loop from the backend. While this works, I've noticed that the resulting animation can sometimes stutter, likely due to the communication latency between the Python backend and the browser frontend. For applications requiring fluid camera movements (like cycling through a set of known camera poses), a smoother, frontend-native animation might be ideal. To this end, I envision a simple, declarative API to move the camera to a target pose over a specified duration, with the animation handled entirely on the frontend. This would look something like:

client.set_camera(
    wxyz=T_world_set.rotation().wxyz,
    position=T_world_set.translation(),
    smoothness=0.9,
    duration=2000,
)

This would provide a more efficient alternative to the current backend-looping approach, as shown in the video demo.

screenshots.mp4
The current backend-looping approach
for j in range(20):
    T_world_set = T_world_current @ tf.SE3.exp(
        T_current_target.log() * j / 19.0
    )

    # We can atomically set the orientation and the position of the camera
    # together to prevent jitter that might happen if one was set before the
    # other.
    with client.atomic():
        client.camera.wxyz = T_world_set.rotation().wxyz
        client.camera.position = T_world_set.translation()

    client.flush()  # Optional!
    time.sleep(1.0 / 60.0)

2. Image Carousel GUI Component

Besides, I also wonder if there could be an image carousel GUI component (from @mantine/carousel ). In many visualization scenarios, especially those involving datasets of images (like NeRFs or multi-view stereo), it's very useful to have a GUI component to browse through the images.

For general cases, an image carousel could be used for displaying a list of images as a standalone image gallery.

image_carousel = server.gui.add_image_carousel(
    image_list,
    names=image_names, # Optional
)

image_carousel.value = 127 # Optionally programmatic control for showing 127th image

For some specific cases, like visualizing NeRF datasets, it could be used as a synchronized view selector. For example, when a user selects an image in the carousel, the 3D view automatically animates to the corresponding camera pose. This would pair perfectly with the smooth camera transition proposed above.

image_list = ...
camera_pose_list = ...

image_carousel = server.gui.add_image_carousel(
    image_list,
    names=[f'view[{i:04d}]' for i in range(len(image_list))],
)

@image_carousel.on_update
def _(event: viser.GuiEvent) -> None:
    selection = image_carousel.value
    event.client.set_camera(
        wxyz=camera_pose_list[selection].rotation().wxyz,
        position=camera_pose_list[selection].translation(),
        smoothness=0.9,
        duration=2000,
    )

I wonder whether these features would enhance the user experience for many common visualization tasks. I'd love to hear your thoughts on these proposals. If you think they align with the project's direction, I would be happy to work on a pull request to implement them.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions