viser: 3D Visualization for Computer Vision and Robotics

1.0.26 · active · verified Sun Apr 12

Viser is a Python library designed for interactive 3D visualization, primarily targeting applications in computer vision and robotics. It provides a rich API for visualizing 3D primitives and constructing interactive GUI elements, all delivered through a responsive, web-based client that enables easy use over SSH and in Jupyter notebooks. The library is actively maintained with frequent releases, currently at version 1.0.26.

Warnings

Install

Imports

Quickstart

This quickstart code initializes a Viser server, adds a red sphere to the 3D scene, and includes a GUI slider to interactively control the sphere's X-axis position. Access the visualization by navigating to the printed URL in your web browser.

import time
import numpy as np
from viser import ViserServer

# Create a Viser server
server = ViserServer(port=8080, label='My Viser App')
print(f"Viser server started at: http://localhost:{server.get_port()}")

# Add a red sphere to the scene
server.scene.add_sphere(
    name="/my_sphere",
    position=(0.0, 0.0, 0.0),
    radius=0.5,
    color=(1.0, 0.0, 0.0)
)

# Add a simple GUI slider to control sphere's X position
x_position_slider = server.gui.add_slider(
    name="Sphere X Position",
    min=-2.0,
    max=2.0,
    step=0.1,
    initial_value=0.0
)

@x_position_slider.on_update
def _(field):
    current_position = list(server.scene["/my_sphere"].position)
    current_position[0] = field.value
    server.scene["/my_sphere"].position = tuple(current_position)

# Keep the server running indefinitely
server.sleep_forever()

view raw JSON →