Scientific version

EIP's concurrent architecture

Modular design, RAW acquisition, shared previews and embedded web services on Raspberry Pi.

Software architectureC++17ConcurrencyMJPEGOpenMP (parallel computing)

How does EIP decouple acquisition, processing, recording and web serving while preserving a single timeline for all frames?

Purpose, question and scope

This article describes Embedded Imaging Platform as of 5 October 2026. It draws on the code, architecture documentation, archived performance measurements and the Git history of this repository, which begins with the first commit of this new version on 14 August 2026. Line counts describe the software's scale and growth, not its quality.

I first imagined PolarScope in 2019 as a digital polar scope for my Takahashi EM-10 astronomy mount; my notes on that prototype, built with a Raspberry Pi camera and Pi Zero, also document calibration and stellar correlation tests. This unfinished first version became the basis of the 2026 version that would lead to EIP.

The printed holder adapted a CS lens to the camera and allowed it to be mounted on the EM-10. The exploded view below documents this early prototype's mechanical design and test holder before adaptation to the mount.

OpenSCAD exploded view of the camera adapter parts for a CS lens.
OpenSCAD exploded view documenting the early mechanical design of the CS lens adapter.

EIP is a C++17 embedded imaging server accompanied by web applications and a secondary native client. It handles acquisition, raw sensor data (RAW) transport, previews, recording, storage, telemetry, astronomy and sensor characterisation.

Architectural invariant: one owner, a modular monolith

The main deployment uses a process named imaging-server. This gives the hardware a single owner, avoids interprocess frame serialisation and keeps the metadata on the same timeline as the pixels. The code remains organised into modules with distinct responsibilities.

Dependencies follow four layers:

ApplicationsPolarScope, PiNox, Dashboard, Projection, Characterisation and Files
Astronomycatalogues, apparent positions, detection, identification and plate solving
Imaging corecapture, image, transport, recording, storage, telemetry, configuration and HTTP
Driverslibcamera, ASICamera2, simulation, test datasets and AVI playback

The dependency direction is Applications → Astronomy → Imaging core → Drivers. Not every application uses the astronomy services. Drivers follow a common interface and publish their capabilities; the server therefore assumes neither a particular sensor family nor a single RAW bit depth.

Development recorded in Git

Development milestones up to 5 October 2026.
DateStageArchitectural consequence
14–17 AugustIn-memory libcamera, continuous acquisition, asynchronous clientThe sensor's frame rate is no longer tied to the display loop.
19 AugustClient/server separationThe camera protocol becomes generic.
24–29 AugustWeb control, MJPEG, asynchronous analysis, double bufferingThe browser becomes a full client without blocking acquisition.
17–23 SeptemberPiNox, Dashboard, portal and EIP configurationThe initial project evolves into a generic foundation for multiple applications.
25 SeptemberCompiled interfaces and PIMPLReduced coupling and recompilation cost on smaller Pi models.
28 SeptemberConsolidation of imaging, storage and filesHigh-rate local capture joins the shared portal.
29 September–1 OctoberMeasured ISP pathThe backend can produce paired RAW and RGB outputs with software fallback.
2–5 OctoberIn-memory C++ characterisationAcquisition, analysis and reporting are integrated into the same server.

Data plane and control plane

Communication with the server is divided into two planes. The data plane transports images through the endpoints /snapshot/raw, /stream/raw, /stream.mjpg and /preview.png, and handles local AVI, SER or PNG writing. The control plane uses structured responses for settings, telemetry and module status.

This separation avoids using the compressed preview as a scientific source. In full-resolution IMX477 mode, measured HTTP RAW throughput tops out at around 105 to 115 MB/s even though capture can be faster. The local recording path therefore branches off before the network.

Capture
Local recordingRAW written directly to storage
Optional RAW network transmissiona separate stream from the capture
Diagram not to scale: capture supplies two separate paths. The network does not sit downstream of the local file, which is not the source of the transmitted stream.

The frame lifecycle and shared processing

  1. The driver acquires the memory buffer and sensor metadata.
  2. The producer publishes a frame snapshot identified by frame_id.
  3. RAW data can be transmitted, analysed or queued for recording without an intermediate file.
  4. The preview selects raw, luminance or colour rendering and applies the requested reduction.
  5. Luminance, work buffers and the encoded JPEG are cached for that frame.
  6. Each client receives at most one MJPEG part for that frame identifier.

With the libcamera backend and image signal processor (ISP) active, the RAW data and red-green-blue (RGB) output of the hardware chain come from the same request. Scientific processing continues to use RAW; the colour output is only the starting point for the preview.

Execution domains, queues and buffers

Several execution threads handle the server's tasks. Depending on configuration, the arrangement includes:

Per-pixel operations use OpenMP (Open Multi-Processing, a parallel programming interface) above a size threshold so that scheduling and synchronisation overhead do not exceed the expected benefit of parallel work.

The plate solver can search for a field without knowing its centre, provided it has an approximate angular sampling value. It tests different catalogue regions; valid observer position and time allow a horizon filter to narrow the search. It also uses OpenMP, with at most four computing threads and one core left available when multiple cores are reported. The search therefore retains these prior inputs even without a known initial centre.

This architecture uses locks, condition variables and protected queues. These mechanisms aim to decouple processing rates: slow writing or expensive analysis should not force the camera to run at the same slower rate.

Write queues, buffers and overload

The recorder receives a reference to the RAW payload and passes it to a dedicated writer thread. Its queue is bounded by a memory budget; normal shutdown drains it before closing the container, whereas an explicit abort accounts for rejected frames. This distinction avoids silently producing an incomplete file.

The preview uses double buffering: while frame N's JPEG is encoded, frame N+1 can be prepared. The current frame, JPEG and intermediate buffers are reused to limit allocations, copies and swapping on Pi Zero.

Schematic, not to scale: processing frame N begins after its capture and overlaps part of the capture of frame N+1.

Shared cache and analysis rate

The cache is indexed by source identity and parameters that affect rendering. JPEG is not re-encoded for each browser. Bayer-cell luminance can be shared between video and overlay annotations. When analysis of an empty sky produces no useful change, its rate can fall to roughly one analysis per second to preserve video performance.

The 23 September fix also requires waiting for a new frame. Previously, a loop faster than the camera could resend the same JPEG several times. After the fix, IMX477 measurements at 1332 × 990 show 47.7 captured frames, 47.7 RAW frames and 47.7 distinct MJPEG frames per second, with 0% duplicates.

Measured performance: double buffering and ISP

The 29 August performance test uses an OV5647, a 20 ms exposure and gain 8. It counts distinct JPEG images without confusing HTTP repeats with new frames.

MJPEG frame rate before and after double buffering, OV5647 benchmark of 29 August.
Platform and modeRenderingBeforeAfterGain
Pi 4, bin2Colour31.1 FPS45.4 FPS+46%
Pi 4, bin2Colour + white balance31.2 FPS45.4 FPS+45%
Pi Zero 2 W, bin2Luminance16.5 FPS27.2 FPS+65%
Pi Zero 2 W, bin2Colour11.2 FPS19.2 FPS+71%
Pi Zero 2 W, bin2Colour + white balance11.2 FPS19.3 FPS+72%

On Pi 4 in bin1 mode, frame rate stays close to 15 FPS before and after: sensor readout is the limiting factor.

ISP integration

The ISP path introduces hardware acceleration without changing the core's contract. The choice of auto, software or isp belongs to preview settings. A neutralised settings profile must be available and validated for the sensor; otherwise automatic mode falls back to software and reports why.

On IMX477/Pi 4 at 4056 × 3040, measured frame rate stays near 11.2 FPS, limited by acquisition, while process load falls from 232.6% to 93.4% and latency from 55.7 to 40.2 ms. On OV5647/Pi 3 at 2592 × 1944, frame rate rises from 12.80 to 14.92 FPS, CPU load falls from 299.0% to 113.7%, and latency from 72.8 to 42.2 ms.

Modularisation and compilation cost

The original server was largely defined in header files. A change could force much of the project to be recompiled and sharply increase compiler memory use, which is costly on Pi Zero. The 25 September restructuring moves implementations into .cpp files, reduces transitive includes and hides substantial implementation details behind PIMPL interfaces.

HTTP transport, web resources, camera settings, drivers, RAW recording, monitoring, catalogues, solvers, image operations and application modules have been separated. The HTTP server still carries substantial orchestration responsibility: some functions remain to be extracted.

Growth in code volume

Growth in non-blank EIP software and test lines, from 12,071 lines on 14 August to 111,900 on 5 October 2026.
Git snapshots shown at equal horizontal intervals; spacing does not represent elapsed time. The total reaches 111,900 non-blank lines on 5 October: 87,870 in production code and 24,030 in tests. The jump on 28 September corresponds in part to consolidation of the imaging and storage chains and a substantial increase in test code. Download the CSV.

The series uses twelve snapshots of the latest commit available at the end of each date. Production scope is limited to C/C++, JavaScript, CSS and HTML files under src/ and assets/web/. Test scope includes C/C++, JavaScript and shell sources under tests/. Blank lines are removed. Exclusions include documentation, the editorial site web/, databases, catalogues, scientific data, figures, dependencies, benchmarks, deployment scripts and one-off tools.

Within this scope, production code grows by a factor of 7.45 and software plus tests by 9.27 in 52 days. Tests account for 21.5% of the final total. These ratios describe repository growth; they are not measures of maintainability or quality.

Resilience and embedded operation

The server monitors capture stalls, limits MJPEG streams per address, separates idle handling from long exposures and can keep acquisition running during operations that prevent power saving. Camera reconfigurations are serialised. Exposures of one second or longer use a single request, regardless of mode or resolution, to avoid an extra long preview frame.

The portal uses service discovery: applications that are not compiled in or are hidden are not displayed. A lightweight profile can omit PiNox on resource-constrained targets. Projection runs in a browser and can also launch locally when an HDMI output is detected.

Conclusion

EIP combines a single camera owner, two coherent data paths, frame-associated caches and asynchronous processing. A shared application programming interface (API) makes those services available to applications.

The measurements show where this architecture delivers a real gain and where it reaches the sensor's limit. The aim is to preserve acquisition, scientific traceability and service responsiveness when several uses coexist on the same Raspberry Pi.

Continue reading

Other version

Inside EIP — Discovery version · Understand the data paths and architectural choices through diagrams.