Skip to content

Screenshots

With Panopti you can capture screenshots directly from the interactive viewer (using the screenshot UI button), or programmatically like so:

import panopti
viewer = panopti.connect(server_url="http://localhost:8080", viewer_id='client')

# Frame your shot:
viewer.set_camera(
    position=(5.0, 2.5, 7.5),
    target=(0.0, 1.5, 0.0),
    projection_mode="orthographic"
)

# Take screenshot
img_arr = viewer.screenshot(filename='screenshot.png',
                            bg_color=(0.75, 0.3, 0.3), # use bg_color=None for transparent bg
                            resolution=(1920,1080))

viewer.hold()
Screenshot - viewer.screenshot()

Capture a screenshot from the frontend viewer. This function is fully compatible with headless mode.

Parameters:

Name Type Description Default
filename str or None

If provided, the image will be saved to this path. Supported extensions are png (default), jpg, and jpeg.

None
bg_color tuple or None

Background color as RGB values in [0,1] range. None results in a transparent background.

None
resolution tuple or None

Resolution tuple (W, H) of the screenshot in pixels. If provided, the screenshot will be rendered at this resolution.

None
timeout float

How long to wait for the screenshot data from the frontend. Default is 2 seconds.

2.0

Returns:

Type Description
Optional[ndarray]

np.ndarray or None: RGB/RGBA image array, or None if the request timed out.

Tips

Screenshot resolution

Screenshot Resolution

Screenshot outputs will naturally depend on the resolution of your local viewer; i.e., rescaling your Panopti window will affect .screenshot(...). It is recommended that you manually specify screenshot resolution through the resolution parameter as shown above.