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.
Try the synthetic exposure labMake 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.
Configure the capture
Choose stream size and format, then set controls exposed by your camera.
Work with image data
Capture arrays, image objects, buffers, and metadata for downstream analysis.
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.
Synthetic sensor
Give the light a little longer.
A synthetic illustration of exposure, independent of scicamera. No camera is accessed.
Increase the exposure to reveal faint stars. Push it further and the brightest cores saturate, losing information.
Next: open the downloaded frame in the FITS reader to inspect its pixels and exposure metadata.
What this model includes
This browser illustration is independent of scicamera. Its 65 artificial stars use Gaussian profiles. Illustrative settings: 8 electrons/pixel/second background, 4-electron RMS read noise, 1 electron/ADU gain, a 100-ADU bias and 12-bit clipping at 4095 ADU. These are not specifications for any camera.
Shot noise uses Poisson sampling (a Gaussian approximation at or above 30 electrons); read noise is Gaussian. The seed is fixed for repeatability. Turning noise off shows the expected signal, rounded and clipped. There is no atmosphere, tracking error, colour filter, hot-pixel model or calibration.
The preview uses a fixed square-root stretch; the FITS file stores the linear 16-bit integer array with exposure metadata. See STScI’s introduction to gain and read noise for the underlying concepts.
-
Choose a stream
Build a still-capture configuration for the camera and the image format you need.
-
Set available controls
Configure settings such as exposure time and analogue gain when the hardware exposes them.
-
Capture a frame
Start the camera and obtain image data through an asynchronous capture result.
-
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.
python -m pip install scicamera
Before opening a camera, confirm that Python can import both packages:
python -c "import libcamera; import scicamera; print(scicamera.__version__)"
Capture your first array.
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.
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 →
Use an open file format for astronomical image data.