Where Part 3 Left Off
Part 3 ended with everything in place for Gate 4’s exit test: the model running on the STM32U585 in 8.2 ms, two debouncers turning frames into a decision, and a small screen on the pole showing that decision to whoever walks in. The sensor head had been knocked out of position during the display work, I had brought it back with the accelerometer and an alignment mode that compares the empty room against a reference, and a quick live check in the new pose looked fine.
The exit test itself is simple: one scripted run of walking in, sitting, standing, leaning, leaving and walking past, with the result read off the device. The bar was fixed before Phase 4 started: no false change while nothing is changing, every real change shown within 3 s, and walking past never shown as seated.
It took two days and a whole new dataset to pass.
I Walked Into It
The board hangs on a boom almost directly above head height. On the first attempt I walked straight into it.
The accelerometer showed it at once: roll at 172.1° against the 167.2° reference, tilt unchanged. The run showed it too: a 23-second stretch of present and some low-confidence empty where I was sitting. I didn’t score it.
Re-setting it should have been routine. tilt_check brought tilt and roll back (44.9° / 167.1°), but the alignment mode wouldn’t get below the low thirties of the 64 distance zones disagreeing with the empty-room reference, even with the column shift at zero. The camera ball head I’m using couples its axes: turning it to fix yaw moves the roll. It was bought for holding a camera, not for positioning to a fraction of a degree.
So I ran it again, as close as I could get. Empty was solid every time. A walk past showed present for 4.6 s and never seated. The final sit was seated for 50 s at 97–98% confidence. And in the middle, a sit read present for about 30 seconds at 100% confidence.
Not a pass. And it wasn’t the firmware, the display or the debouncers. They all did exactly their job. The model simply no longer recognised some sitting postures from this viewpoint.
What a sit should look like on the pole. After the bump, one read PRESENT for half a minute instead.
What That Actually Measured
This is the most useful result of the whole project so far, even though it’s a failure. A few degrees of roll and yaw, one bump, turned a reliable seated into a confident present. The model had learned one viewpoint of one room. Move the viewpoint and it is wrong, and wrong with full confidence, which is worse than being unsure.
A real installation has two ways out: a mount that cannot move (a fixed bracket out of reach), or training data that covers the poses it will actually meet. I’m not building a product. This project is about understanding the essentials, so I didn’t go shopping for a precision mount. Instead I did the thing that makes the data match the device: re-record the whole dataset in the setup as it now stands, and write down the limitation honestly.
The Redo
The plan, in COLLECTION.md before a single session was recorded:
- Move the stand out of the walking path. The cheapest fix in the project.
- Lock the pose and check it before every session. 44.5° tilt / 167.3° roll, set once after moving the stand and securing the harness, and never chased after that.
- Six rounds again, evening / morning / afternoon over three days, so every held-out test is a daypart the model never trained on.
- 12 sessions per round, about 3 minutes each: four empties (chair on its marks, pulled out, turned, away), three ways of sitting (normal, hunched over the desk, leaning back), two of standing (upright, bent over the keyboard), two walk-pasts, and a new one.
- The new one is a transitions session with video: three full cycles of walking in, sitting down, standing up and leaving. Those were exactly the moments the live tests had failed on, and the old dataset had almost none of them.
The original 70 sessions stayed. Whether they still help, recorded from the wrong pose, became a question for the retraining.
From 2026-11-28 evening to 2026-11-30 afternoon: 72 sessions, 66,106 frames.
The Pose Held
The worry with a re-record is that the thing you’re fixing moves again halfway through. It didn’t. Every session sat between 44.5–44.7° tilt and 166.99–167.12° roll, through two overnight unplugs and three days.
One small thing showed up in the logs: when I hunched over the desk, the tilt read about 0.3° higher, and it came back when I sat back. Leaning on the desk flexes the boom. Within tolerance, but a reminder of how little it takes.
The empty room agreed. Every round’s empty-room session is within 2–16 zones of every other. In the old dataset, empty-room sessions differed from each other by typically 12 zones and up to 38. Same room, much steadier view.
Nobody in view: EMPTY, 100%.
What the Redo Taught Me About the Data
Recording 72 sessions with my eyes on the numbers was also the closest look I’ve had at what the sensors actually see. A few things I didn’t expect:
Bent over the keyboard sits at the same distance as sitting. Standing upright puts head and shoulders 250–530 mm from the sensor. Bent over the keyboard reads 390–670 mm, the same range as seated. What separates them is the shape across the bottom rows, not the distance. That is the original bent-over error from Part 3 in one line.
A shirt nearly hides a standing person from the thermal camera. The afternoon rounds are shirtless, because that’s normal at home in a Brisbane summer, and the evening and morning rounds are in a shirt. Standing shirtless lights up about 21–28 hot pixels. Standing in a shirt: 0–5. Seated, the head and arms still show 10–15. So when I’m standing in a shirt, the time-of-flight sensor is doing the work on its own. That’s the case for fusing both sensors, shown in a single round.
Walk-pasts behind the chair are invisible. With the chair on its marks, I have to walk around it, and sometimes that takes me outside the sensor’s view entirely: plenty of frames where the webcam sees me and the sensor sees nothing. With the chair moved away, I walked right through the chair area, up to 63 of the 64 zones lit. Every round ended up with one of each, which covers both near and far passes.
The label rule had to be made explicit. Twice, while labelling transitions from the video, I marked frames present because the webcam showed me walking up. Checking against the sensor, those frames were identical to the empty room: no warm pixel, no near zone. They were reverted. The rule that came out of the reviews: present means in the sensor’s view. That starts at the first warm edge pixel or near zone, gaps of up to 5 frames inside a pass are bridged, and nothing is labelled from the video alone. It sounds obvious written down. It wasn’t while I was looking at video of myself clearly in the room.
The Hot Afternoon
The last round, 2026-11-30 afternoon, the room was at 28.5–28.8 °C. The afternoon before it had been 24.2–24.8.
A thermopile array measures contrast between you and the room. My hottest pixel seated was about 31 °C: 2.3 °C above the room, against 5.3 °C the day before. That meant 2–7 warm pixels where there had been 15–20. A Brisbane afternoon takes away most of what the thermal sensor gives the model.
That’s not a fault. It’s the condition the device will meet every summer. And in the same round, seated leaning slightly forward and standing overlapped on the time-of-flight side too: 7–10 near zones against 7–9. For those frames the video decided the labels, because the sensor data alone couldn’t.
Retraining
Same small CNN as Part 3, same fixed recipe, nothing tuned on held-out data. The test is leave-one-round-out on the six new rounds: train on five, test on the sixth, rotate. So all three models below are scored on the same 66,100 frames, from the setup the device actually runs in.
| Trained on | Accuracy | Hot round alone | Other five rounds |
|---|---|---|---|
| Old 70 sessions only (the model that failed) | 76.7% | 66.0% | 66–86% |
| New 72 only | 98.7% | 94.5–95.2% | 99.1–99.7% |
| New 72 + old 70 | 98.8% | 95.9–96.2% | 98.5–99.7% |
The first row is the failed exit test, measured. The old model still gets an empty room right (99.9%) and little else. Bent over the keyboard is wrong in every round, and only 36% of present frames are recognised. A few degrees of viewpoint took it from 99% to 77%.
Either new model makes the five ordinary rounds a solved problem, at 98.5% or better, and in them a seated person is never called empty.
The hot round is not solved. With the thermal contrast gone, the errors move to the one place that matters most to a building: seated called empty. Run through the debouncers, that’s 2–9 seconds of false VACANT in the plain seated session, for five of the six models I trained. There was no false OCCUPIED anywhere.
New + old is the better model where it counts: about a point better on the hot round, with seated-called-empty roughly halved. The old sessions were recorded from the wrong viewpoint, but they still teach “a warm thing near the seat is a person”, and more variety of room temperature. That’s what I deployed, as model v3.
One caveat on the hot round: held out, it’s a condition no training round had. The deployed model trains on all six, so it has seen one hot afternoon. That helps, but one afternoon is thin.
The Exit Test, Again
Model v3 on the board. First the usual check that the board and the PC agree: 283 of 283 frames the same class, largest difference in the raw outputs 1.1×10⁻⁵, still 8.2 ms per inference.
I ran it on an afternoon at about 28.5 °C, shirtless: the exact conditions the model is weakest in. If it was going to fail, I wanted it to fail here, not in Gate 6.
| Display | Seconds | What I was doing | Lag |
|---|---|---|---|
| EMPTY | 0–13 | empty room | — |
| PRESENT | 13–21 | walking in, sitting down | — |
| SEATED | 21–53 | sitting | 2.0 s |
| PRESENT | 53–104, 51 s unbroken | standing, reaching, bent over the keyboard | — |
| SEATED | 104–137 | hunched | 1.6 s |
| PRESENT → EMPTY | 137–140 | leaving | — |
| EMPTY | 140–172 | empty | — |
| PRESENT | 172–175 | walking past, never SEATED | — |
| EMPTY | 175–192 | empty | — |
| SEATED | 194–232 | walking in and sitting | 1.2 s |
The display state comes from the board’s log and the moments from the webcam. No false empty↔occupied change, every change within 2 s, and bent over the keyboard read present for the whole 51 seconds: the posture that failed both earlier live tests. During the hunched sit the model produced 36 raw present frames, and the debouncer absorbed every one.
Gate 4: pass.
What I’m Taking From This
- The model learns the viewpoint, not just the room. I knew that in theory. A bump of a few degrees and a drop from 99% to 77% made it real. If I deployed this for real, the mount would be the first thing I designed, not the last.
- The accelerometer and the alignment mode earned their keep. Neither stopped the bump. Both told me within a minute exactly what had moved, which turned “the model is broken” into “the head moved 5° in roll”.
- Re-recording beat chasing the old pose. Three days of sessions was less work than trying to put a ball head back to within a fraction of a degree, and it produced a better dataset: steadier, with transitions in it, and with a written label rule.
- Each sensor covers for the other, until the room is hot. A shirt hides a standing person from the thermal camera. A seated person leaning forward looks like a standing one to the time-of-flight sensor. Fused, they cover each other. A 28.5 °C room is where that cover gets thin, and it’s the honest weak spot.
Both limits are in the README now: one viewpoint, and a hot room weakens the thermal channel. Recording more hot-day data is the obvious fix, and it can wait until the device has been running for a while.
What’s Next
Gate 5 takes the decision off the screen and puts it where a building can use it: an MQTT message, into the same InfluxDB and Grafana stack my other sensors already feed, plus a minimal set of BACnet objects (occupied / vacant, and confidence). I’m keeping it deliberately small. A Grafana panel showing my desk going occupied and vacant, live, is the point. Then a few days of just leaving it running.
The code, both datasets and the full lab notes for every round are on GitHub: mapfumo/camera-free-occupancy.
