Industries · 6 min read
PPE detection in production, deciding who is wearing the hard hat
A gate camera, three classes and a spatial rule decide compliance per person. The hard hat carried in a hand is the label that decides whether the model holds.
Summary
This post builds PPE detection on a single site gate camera, with person, hard hat and vest as classes and compliance decided by where the hat sits relative to the person rather than by a no-hat class. It argues that the carried hat and the hat on the ground are the labels that decide whether the model holds in production, and that the alert should reach the safety lead with the frame, once per person. It is for site safety and operations teams.
Finn Ellingwood · Engineer · Sep 23, 2026

Two workers under scaffold netting with hard hats boxed, from a customer site camera
The gate camera on a construction site sees every worker once a day, at about 6:30 am, walking through a turnstile at the same distance and the same angle. Most are wearing a hard hat. Some are carrying one. One has it hanging from a rucksack strap, and one left it on the roof of a van. The safety lead wants to know which of those people walked onto the site without a hat on their head, and wants to know it while they are still near the gate.
A detector will happily find every hard hat in the frame. The hard part is deciding whose head it is on.
R-CNN or YOLO, the detector only finds hats and people
The model's job is small and it should stay small: three classes, person, hard hat and hi-vis vest, each as a box. Which detector family draws the boxes matters less than people expect. A two-stage detector in the R-CNN line and a one-stage detector trade a little accuracy for a little speed, and on a fixed gate camera with people at a known distance either one finds a hat.
What no detector does is tell you the hat is on a head. It returns a hat box and a person box, and the two might overlap because the hat is worn, or because it is carried at chest height, or because a worker is standing in front of the van with the hat on its roof. The use case page puts the rule in one sentence: a helmet box and a person box in the same frame do not tell you the helmet is on that person's head.
The detector's output is where the work starts.
Compliance is a spatial rule and never a no-hat class
The tempting shortcut is a fourth class, person without hat, so the detector answers the question directly. My view, and it is the point in this post I would argue hardest, is that this is the mistake that sinks PPE projects. A no-hat class asks the model to learn an absence, and absences are learned from whatever else the no-hat examples had in common: the bareheaded workers at the welfare cabin in the training set, the light at the time those frames were taken. The class ends up detecting the cabin.
Decide compliance in logic instead, the way the site safety and PPE compliance use case describes it. For each person box, look for a hat box whose centre sits in the top portion of the person box, roughly the top fifth for someone standing. Keypoints make this exact, putting the head in a known place so gear is attributed to a body rather than to a scene. Without keypoints the top-of-box rule is the approximation, and it holds at a gate at 6:30 am where everyone is upright and facing the same way.
That rule is a sentence anyone can read, and when the site changes its policy the sentence changes and the model does not.
The carried hat and the grounded hat decide the model
The frames that matter are rare and specific. A hat carried in a hand hangs at hip height. A hat on a rucksack strap sits at the shoulder. A hat on the van roof is in the frame at head height and belongs to nobody. Each of those is a hard hat box, correctly drawn, that the spatial rule has to place outside the head zone for the right person.
Those are the frames a reviewer labels deliberately, because the gate at 6:30 am produces hundreds of worn hats for every carried one. In LexAnnotate you type the three classes, Lexi puts a box on every frame, and a person checks each label before anything trains on it. The person's time goes on the carried hats, the hats on the ground and the two workers walking through side by side with one hat between them.
The hard hat itself dates from 1919 and a San Francisco maker of mining lamps, who built one from steamed canvas and glue and called it hard boiled. Sites have been arguing about who is wearing one ever since.
The safety lead gets the frame, once per person
An alert in LexAlert is a rule written as a sentence, with a severity and a cooldown, approved before it goes live: a person through the gate with no hat on their head, to the safety lead's Slack, with the frame attached. The frame is what makes the alert usable. The safety lead sees the person, the gate and the hat in a hand, and can walk over or let it go, from a phone, without opening anything. The monitoring and alerts guide covers routing by severity; for a gate, one channel and a person on it is enough.
The cooldown is per person, which needs tracking across the few seconds each worker is in frame. A worker who takes nine seconds to cross the gate area should produce one alert and not nine, and the model's uncertainty on three of those frames should never reach the safety lead as three separate messages. One person, one decision, one message.
Compliance is judged on the worst moment rather than the average one, so the alert is tuned to miss as few as possible and the safety lead absorbs the extra walks to the gate.
Winter hoods and fence hats train the second version
A model trained in August at a gate meets October with hoods up, and a hood over a hard hat looks like no hat at all. The rain jacket covers the vest. A worker who parks by the fence hangs a hat there, and the fence is in the frame. Each of these produces a frame the model doubts, and each doubted frame comes back to a person.
LexData takes the gate model through its whole life. You type what to look for, Lexi puts a box on every frame, and a person checks each label before anything trains on it. The model then watches the gate camera the site already has, in the cloud, on your servers, or on a runner beside the recorder. Frames it is unsure of come back to a person, the corrections retrain it, and the new version replaces the old one with no downtime.
The safety lead's override on a false alarm, the hood that was a hat, is the correction that trains the October version. A model that can be live in days is only worth having if it can also be corrected in days, and at a gate that sees the same walk every morning, the corrections arrive on schedule.
See it on your own footage.
Start with your footageMore in Industries

Industries · 8 min read
Computer vision for construction site safety, a warning before the worker and the excavator meet
A pole camera boxes people and machines, draws a danger zone that moves with the excavator, and sends the frame when someone walks into it.
Ayman Quadir · Sep 23, 2026

Industries · 7 min read
Computer vision in agriculture, from the sprayer boom to the packing line
Weeds against beet rows at dawn, lesions on a leaf, bruises on a packhouse belt, and labels that go stale as the season turns.
Ayman Quadir · Sep 23, 2026

Industries · 6 min read
Computer vision applications on a factory floor, four jobs for the cameras already there
Defect detection, assembly verification, safety and inventory on one plant's cameras, with cosmetic against functional written into the labeling schema.
Ayman Quadir · Sep 23, 2026