SmartHome
It knows who is at my gate, and records anyone who lingers.
In short
SmartHome is the security system I built for my own house. Its cameras recognise the people it knows and keep a list of who came and who left. If anyone hangs around the gate for too long, it saves a video of them. One screen shows every camera and opens the door with a tap. The face recognition happens on a computer inside the house, not on some company’s servers.
- What it is
- Home security dashboard with face recognition
- Built with
- Node.js, React, Python, go2rtc
- AI
- YOLO, YuNet, ArcFace, Qwen3 VL
- Runs on
- One M1 Mac at home
- Tests
- Around 700, plus a 50 check health script
- Status
- Private, v0.3.0, runs at home
Full stack: Computer vision, YOLO, ArcFace, YuNet, Apple GPU (MPS, CoreML), Vision language model, RTSP, go2rtc, Python, Node.js, React
Everything below is for engineers: how it is built, what I measured and what went wrong.
The setup
The cameras are on a Dahua recorder and stream over RTSP. The door opener is a Tuya relay set to pulse once and switch itself off, so opening the door is a single command. Everything else runs on one Mac as background services that start on their own.
How it works
One origin. A Node gateway serves the React dashboard, the live video and the AI service from one address. Every request except a health check, the app manifest and its icons needs a login, including the live video socket, which skips the usual request handling and has to be checked on its own.
Video. go2rtc is the only part that serves the video streams. The AI service takes a still frame from each camera every two seconds.
People and faces. YOLO tracks each person across frames. YuNet then looks for a face only inside each person’s box, and ArcFace says whose face it is. Each camera has its own detection zone, and someone who stays in the zone long enough on one unbroken track is logged as loitering, with a clip.
Descriptions. A vision language model, Qwen3 VL at 4 bits, describes what each visitor looks like. It runs in its own isolated process on the Mac.
| Stage | Model | Runs on |
|---|---|---|
| Find and track people | YOLO, small | GPU (MPS) |
| Find faces in each person | YuNet | CPU |
| Say whose face it is | ArcFace | GPU (CoreML) |
| Describe the visitor | Qwen3 VL, 4 bit | Own process (MLX) |
Decisions that mattered
Move the models to the GPU, then spend the time. Person tracking and face recognition moved off the CPU onto the Mac’s GPU and CoreML, timed on 33 real frames on an M1:
| Job | Model | CPU | GPU |
|---|---|---|---|
| Person tracking | YOLO | 59 ms | 28 ms |
| Face recognition | ArcFace | 49 ms | 3.6 ms |
The system was already keeping up, so the time saved went into looking at each frame at two sizes, which catches smaller and farther people.
Look for faces only inside people. On a whole frame, a flower pot in the zone scored 0.54 as a face, and parked cars and plants caused more false faces, so the score bar had to sit at 0.9. Searching only inside person boxes let it drop to 0.6. On 48 crops I labelled by hand, 40 real faces and 8 fakes:
| Setting | Real faces found | Fakes let through |
|---|---|---|
| Head enlarged 2 times, bar 0.6, in use | 32 of 40 (80%) | 2 of 8 |
| Plain crop, bar 0.6 | 25 of 40 (63%) | 2 of 8 |
| Head enlarged 2 times, stricter bar 0.8 | 14 of 40 (35%) | 0 of 8 |
“Head” is the top of the person box, where a face would be. So I chose 0.6 with the enlarged head region. Those crops came from smaller frames than the cameras send now, so the bar needs checking again (see Limits).
Keep the small person model. I tested the medium and large YOLO models on the same 216 photos:
| YOLO model | Real people gained | New mistakes | Time per photo |
|---|---|---|---|
| Small, in use | baseline | baseline | 73 ms |
| Medium | about 19 to 23 | about 1 | 170 ms |
| Large | 27 | 10 | 202 ms |
The medium one looked clean on single photos but lost a person for 6 seconds in a clip and gave them a new ID afterwards. Loitering is judged on one unbroken track, so a gap like that could hide a real loiterer. The small model stayed.
Open the door without the cloud. The relay is tried on the home network first and through Tuya’s cloud only as a backup. The change came when Tuya’s cloud API started asking for a paid renewal. Now the door still opens when the internet is down. The choice is written up as a decision record in the repository.
Testing
Around 700 tests cover the gateway, the dashboard and the AI service, and a health check script runs 50 checks against the live system. The tests never touch the real relay: the gateway tests run the server in an empty folder with a minimal environment, so the relay’s key cannot load by accident.
Limits
- The 0.6 face threshold was measured on smaller frames than the cameras send today, so it needs checking again on full resolution footage.
- It is built for one camera brand and one relay brand on purpose, with no abstraction for others until a second one exists.
- The repository is private.