Ask a bakery QA team which foreign material worries them most, and the answer is rarely the blue glove. Blue hardly ever occurs in baked goods, which is exactly why gloves, hairnets and scrapers on a food line are blue. The cases that keep quality teams busy are the ones that come from the line itself and look almost like the product. This article looks at why those are so hard for cameras to catch, and how we train AI to find them anyway.
Why blue is the easy part
Classical camera inspection works on contrast. The system sets a threshold on color or brightness, looks for a blob above a minimum size, and rejects the piece.
For a blue tie-wrap on a light cookie, that works well. It is the same logic behind making everything on the line blue: pick a color the food never has, and anything out of place becomes obvious.

The contamination that looks like product
The contaminants that come up when we go through a QA team's list are different. A sugar clump. A smear of grease from the machinery. A scrap of packaging film, a fiber from a cleaning cloth, a piece of the conveyor belt. They share the colors of the product, and sometimes they are the product, just in the wrong place or state.
This is where a fixed threshold breaks down, because normal variation between batches is often bigger than the difference a defect makes. Tighten the threshold to catch the sugar clump, and a slightly darker bake ends up in the reject bin. Loosen it to keep the line running, and the clump goes through.
It also matters whether a defect is a one-off or a pattern. One clump on one biscuit is a routine reject. The same contamination showing up across many pieces in a row usually means something changed upstream, and that calls for a much faster response.

Training a model on defects you rarely see
A better approach is a model that learns what good product looks like, across all its normal variation, and flags whatever falls outside it. A grease smear then doesn't need to be defined in advance. It only needs to look unlike the biscuit around it.
The catch is that models learn from examples, and a well-run plant might see a grease spot only a handful of times a year. Nobody waits a year for training data, and no producer will contaminate their own production to build a data set.
So we use synthetic data. Starting from a small set of real images of the producer's own product, we generate realistic defects on it: fat smears, clumps, dark dough, fragments of materials that are actually present in that plant. The model then trains on thousands of variations of defects that barely ever show up on the real line.
One limit is worth stating up front. A camera sees the surface, so material buried inside the product or stuck underneath it stays out of view. We would rather put that in the spec than discover it during commissioning.
Detection only counts if operators trust it
Detection gets most of the attention, but whether a system stays in use comes down to how often it rejects good product. If it throws out good biscuits every few minutes, operators loosen the threshold or switch it to bypass "just for this run." From then on, it catches nothing.
Training on far more normal variation helps the model stop confusing a darker bake or a broken edge with foreign material. The rest is a decision the plant owns: how much good product are you willing to reject to catch one more grease spot? The answer for an allergen risk is not the same as for a cosmetic defect, so it should be set together with the QA team.

How Polysense approaches foreign material
Polysense Qualify inspects 100% of production output inline, using cameras and AI. For foreign material, that means a model trained on what your good product looks like, strengthened with synthetic defects based on the materials found in your plant.
We set reject thresholds together with your QA team, defect type by defect type, so the line keeps running and good product stays on the belt. And we are clear from the start about what a camera can and can't see.




