Originally built in 2018/2019 for the German "Jugend forscht" science competition.
A low-cost home surveillance system built on a Raspberry Pi with a camera module. Rather than flagging every motion event as a potential threat, it uses face recognition to tell known people (household members, family, friends) apart from unknown visitors, and only notifies the owner about the latter via a Telegram bot.
When the camera detects a face:
- If the face is already known, the bot sends a message naming the person who was seen.
- If the face is unknown, the bot sends the photo to a Telegram group and asks whether the user recognizes the person. If yes, the user provides a name, confirms it, and the face is stored as known for next time. If not, the bot just says "handle it" (e.g. call a neighbor or the police), and the photo is not stored.
- Raspberry Pi 3 Model B
- Pi Camera Module
- A smartphone running Telegram (for notifications and replies)
- Language: Python 3
- Face recognition runs via the
face_recognitionlibrary (built on dlib), based on denverdino/face_recognition_pi. - Communication with the user happens through a Telegram bot built with
python-telegram-bot(v11-style API).
face_recognition_pi.py— runs on the Raspberry Pi: captures photos, detects and recognizes faces, and sends notificationstelegram_bot.py— the Telegram bot: handles the known/unknown-person conversation and saves newly labeled facessave_known_face.py— helper script to register a photo under a given namerequirements.txt— Python dependencies
pip install -r requirements.txt
export TELEGRAM_BOT_TOKEN="<your bot token from @BotFather>"
python3 telegram_bot.py &
python3 face_recognition_pi.pyBoth scripts expect a bilder/ directory one level above the script directory, used to store captured and known-face photos. face_recognition_pi.py also shells out to telegram-cli at a fixed path (/face_recognition/examples/tg/bin/telegram-cli) for sending photos — see the denverdino/face_recognition_pi setup for building that environment (originally run inside a Docker container).
The original 2018/2019 version had the Telegram bot token hardcoded directly in telegram_bot.py. It's been replaced here with the TELEGRAM_BOT_TOKEN environment variable — never commit a bot token directly into source code.