From a camera to a sleep score
All the video work happens on a Mac at home. The website only ever gets the results.
The pipeline, from the camera to the site
Cameras
Record all day and night.Two Wyze Cam OG to SD cards. Only the hours needed are copied home.
The slow pass
Find every hen, once a second.Frames are read at 640 px wide, 2 a second. A YOLO11 detector looks once a second, plus motion per hen. Saved, so it runs once.
Identity
Work out who is who.Over the whole night at once. Every number after this depends on it.
The fast pass
Turn seconds into stories.Asleep, awake, moving, hidden, then scores, meters and meals. Seconds to re-run.
The site
coopwat.ch.Tables, report data and a few frames, sent every hour the Mac is awake.
The labeling loop: People name hens in frames on the site, and those labels go back to the Mac to retrain the detector in step 2.
Cameras get bumped. Each recording is matched to a reference view, and the zones move with the camera. When it can't be matched, that day is held back rather than published with wrong numbers.
One name, never on two birds
A detector looking at one frame at a time makes the same mistakes over and over. So Coopwatch looks at the whole night at once.
- Follow each bird second to second, so a sleeping hen becomes one track lasting hours.
- Pool the evidence along the track, trusting confident seconds most.
- Name tracks by elimination, strongest claim first.
- A bird it can't name stays unknown rather than guessed.
Teaching it who's who
People label frames on the site: tap a box, then her name. A label counts as soon as one person saves it. The Mac pulls the labels home and retrains. Real nights are replayed against the owner's own labels to check the naming stays right.
“There was no clever shortcut: it took a lot of old-fashioned labeling and retraining.”
Sign in to help label frames.
Why these choices
YOLO11
Quick to iterate on, and fine-tuning it on a few hundred frames worked.
A Mac at home
Keeps footage at home and was the fastest way to start. A move to the cloud is being looked at.
A small website
Python on Google Cloud Run, with Cloud Storage and Firestore. Sign in with Google.
Scores from research
Sleep thresholds come from EEG studies of laying hens. See the sources. Sources
For the curious: moving the processing to the cloud
The processing could run in the cloud for about $3-15 a month. The hard part is getting footage off the cameras without someone copying SD cards.
| Option | About $/month | Trade-off |
|---|---|---|
| Keep the Mac, automate the copy | $0 | Fastest; the Mac must stay on |
| Raspberry Pi + a nightly cloud job | $3-15 | Fits today's setup; batch, not instant |
| Cloud job with a GPU | $10-25 | Quick, but not needed at this frame rate |
| All at home on a Pi 5 with an AI accelerator | ~$285 once | Best privacy; recompile after each retrain |
| Switch to RTSP cameras | Cameras + one above | Officially supported; a new purchase |
Estimates from October 2026