All MAIN articles
MAIN · Technical record
MAIN · Technical5 min read

Machine Vision for Spirulina: Catching What the Numbers Miss

MAIN's six numeric sensors describe the water; an optional camera describes the cells — and a picture catches the contamination, stress, and morphology that numbers alone smear into noise.

Key facts
  • Spirulina's helical, filamentous shape is a visual fingerprint — a camera can confirm a healthy culture and flag uncoiling, yellowing, or foreign cells that no bulk sensor reading captures.
  • Vision catches contamination early: a grazer or green-algae bloom shows up as foreign shapes and motion in pixels well before it moves pH, OD, or TDS.
  • The ESP32-CAM (OV2640) only captures frames; the heavier analysis runs locally and offline on the Pi Zero 2W, so no image ever leaves the reactor.
  • An image-based optical-density proxy uses the same Beer-Lambert attenuation as the turbidity probe, giving a second, self-checking estimate of biomass.

Every one of MAIN's six numeric sensors measures the water, not the organism. pH, temperature, dissolved oxygen, TDS, light, and optical density are exquisitely sensitive to the chemistry and physics of the culture, but they are all bulk averages — a single number standing in for billions of cells. They can tell you the pond is alkaline and warm and slowly getting denser; they cannot tell you whether the things growing in it are actually spirulina. That blind spot is exactly what the optional ESP32-CAM is built to cover. Where a probe reports a scalar, a camera reports a scene, and a scene carries shape, color, and texture that no single number can encode.

Arthrospira has one of the most recognizable silhouettes in the microbial world: a blue-green trichome — the technical name for the filament — coiled into a regular open helix, a living spring a fraction of a millimeter long. A healthy, well-lit, well-fed culture is dominated by these tight, uniform spirals, and the first job of vision is simple positive confirmation that they are there and thriving. The second job is to read their body language. When a culture is stressed — too hot, too bright, short on nitrogen — trichomes often uncoil toward straight filaments, fragment more aggressively, or fade from deep teal toward a sickly yellow-green as phycocyanin and chlorophyll degrade. That drift from coiled-and-blue to straight-and-pale shows up in an image long before it becomes a decisive swing in any probe reading, and it is precisely the kind of gradual morphological change that bulk numbers blur into noise.

The higher-stakes job is spotting what should not be there at all. Spirulina's natural defense is its habitat — soda-lake pH near 10 poisons most invaders — but nothing is perfect, and the classic intruders each have a distinct look. Round, unicellular green algae like Chlorella; boat-shaped diatoms; darting ciliates and other protozoa; and the real villains, grazers such as rotifers and amoebae that physically eat the crop. A camera catches a grazer bloom or a green-algae takeover as foreign shapes and motion while the water chemistry still looks fine, because a modest contaminant population barely moves pH, TDS, or optical density. By the time the numbers do react — the tell-tale unexpected fall in pH, often with a foul smell as the culture crashes — the contamination is already advanced. Vision buys back the days between "something looks wrong" and "the chemistry has tipped," which is often the difference between a rinse-and-recover and a total dump.

The camera also earns its keep on the mundane task of gauging biomass. Because a dense culture absorbs and scatters light, the average brightness of a backlit frame falls as cell concentration rises — the same Beer-Lambert attenuation that MAIN's turbidity probe relies on, only measured in pixels instead of a photodiode. That yields an independent, image-based optical-density proxy MAIN can cross-check against the dedicated OD sensor. When the two agree, confidence in the density estimate goes up; when they diverge, it is a strong hint that one of them is wrong — typically a biofilm or bubble film fouling the optical probe, or wall-growth skewing the camera. A second, physically different way of seeing density turns a single point of failure into a self-checking pair.

The hardware is deliberately humble. The ESP32-CAM pairs a small OV2640 sensor with Wi-Fi on a board that costs a few dollars, fitted with a close-focus macro lens and lit from behind by an LED — or by MAIN's own RGB actuator — to resolve the helical filaments at near-microscope scale. The ESP32 itself does little more than capture JPEG frames and ship them over Wi-Fi or MQTT to the Raspberry Pi Zero 2W, where the actual analysis runs: lightweight classical computer vision such as blob detection, color histograms, and shape and texture filters tuned to the helix, plus a small quantized neural net where it fits. Crucially, all of it runs on the Pi, on-site and offline — no image has to leave the reactor, which keeps the system private and keeps it working when the internet does not. Honest engineering matters here: the air pump throws bubbles that can masquerade as round cells, and drifting debris can look alive, so the pipeline leans on motion cues, focus, and multiple frames to avoid crying wolf.

None of this replaces the numbers; it argues with them. MAIN treats vision and the six probes as complementary evidence streams — the sensors continuous, quantitative, and fast, the images slower but rich in structure — and fuses them into a single read on culture health. A vision flag can act as a prior on the physics-based digital twin: if the classifier reports foreign cells or a collapsing morphology, MAIN can down-weight optimistic growth forecasts and bias its two-layer safety gate toward caution, refusing aggressive moves and surfacing the concern to the grower. It might recommend reinforcing the culture's alkaline defense — replenishing the bicarbonate buffer that holds the water in the high-pH range where spirulina outcompetes its rivals — or an early harvest to salvage biomass before the culture crashes. As always, vision only informs; the AI proposes and the safety gate disposes, and no camera frame ever drives a pump on its own.

The camera is an optional add-on for a reason: MAIN runs perfectly well on six senses, and vision is a second opinion rather than a life-support system. But it is a genuinely independent opinion, and that is the point — the failure modes of a chemistry probe and a camera rarely overlap, so the pair catches more than the sum of its parts. For a home grower learning to read a culture, it is also simply a wonderful window; watching your own spirulina coil and drift across a screen teaches more about what a thriving culture looks like than any spec sheet ever could. That is the whole spirit of the project — putting the tools of a research lab, and the understanding that comes with them, within reach of anyone curious enough to look.

All MAIN articles Reserve a reactor