OrbitalCommons / projects / scicamera

Capture · Python

scicamera

Scientific camera capture in Python, built on libcamera. Configure still-image capture and bring pixel arrays, buffers, and metadata into your imaging workflow.

Python 3.9+BSD-2-ClauseLinux + libcamera
Try the synthetic exposure lab
SCICAMERA / SENSOR ILLUSTRATION

Make every frame count.

Scientific imaging often calls for control over exposure, sensor modes, and the path from sensor to array. scicamera began as a fork of picamera2 and focuses on high-quality, timing-sensitive still images with minimal processing.

01

Configure the capture

Choose stream size and format, then set controls exposed by your camera.

02

Work with image data

Capture arrays, image objects, buffers, and metadata for downstream analysis.

03

Build on libcamera

Use a Python interface over the Linux camera stack, with a still-image focus.

From sensor to array.

A capture is more than a picture. The stream configuration determines what arrives, and metadata helps describe how it was acquired.

  1. Choose a stream

    Build a still-capture configuration for the camera and the image format you need.

  2. Set available controls

    Configure settings such as exposure time and analogue gain when the hardware exposes them.

  3. Capture a frame

    Start the camera and obtain image data through an asynchronous capture result.

  4. Keep the context

    Use capture metadata alongside your arrays or buffers in the next stage of your application.

scicamera runs on a Linux host with supported camera hardware and libcamera bindings. This page describes the capture workflow; it does not access your browser’s camera.

Prepare your camera host.

The project documents 64-bit Raspberry Pi OS (Bullseye or later) and x86 Ubuntu. The Python package depends on libcamera and its Python bindings, which must be installed separately for your platform.

Follow the project’s libcamera setup instructions, then install scicamera into a Python environment that can see those bindings.

Terminal
python -m pip install scicamera

Before opening a camera, confirm that Python can import both packages:

Terminal
python -c "import libcamera; import scicamera; print(scicamera.__version__)"

Capture your first array.

Python · supported camera hardware required
from scicamera import Camera, CameraConfig

with Camera() as camera:
    config = CameraConfig.for_still(camera)
    camera.configure(config)
    camera.start()

    camera.discard_frames(2).result()
    pixels = camera.capture_array().result()
    print(pixels.shape, pixels.dtype)

    camera.stop()

The context manager handles the camera lifetime, while capture methods return results you can wait for. Available resolutions, formats, and controls depend on the camera and its libcamera driver.

See array-capture examples in the project tests →

Build for the camera you have.

Area Interface
Configuration CameraConfig and StreamConfig describe capture streams.
Capture Request NumPy arrays, images, buffers, or metadata.
Controls Inspect the camera’s available controls before setting exposure or gain.
Testing A FakeCamera implementation supports the project’s test workflows.

For low-bandwidth real-time video streaming, the project points to picamera2. scicamera’s focus is still-image acquisition for scientific applications.

API example reviewed against scicamera 0.4.2. Run it on a configured camera host. Source & contributions →

Keep exploringfitsio-pure

Use an open file format for astronomical image data.