A Python-based home surveillance system that uses face recognition to detect known and unknown individuals in real-time via webcam. When an unknown person is detected, it starts video recording and sends an SMS alert to the specified phone number using Twilio.
- π Detects faces using
face_recognitionand classifies as known or unknown. - π§ Loads known faces from a directory and matches with live video feed.
- π₯ Automatically records video when an unknown face is detected.
- π± Sends SMS alerts via Twilio when unknown faces appear.
- β Stops recording automatically after a few seconds of no unknown activity.
- π Saves recorded videos in a designated directory.
face-surveillance/
βββ known_faces/ # Folder for known people's images
β βββ Alice/ # Person 1
β β βββ alice1.jpg # Image 1
β β βββ alice2.png # Image 2
β βββ Bob/ # Person 2
β βββ bob.jpg # Single image
β
βββ unknown_videos/ # Auto-created recordings
β βββ unknown_20231115_1430.avi # Example video filename
β
βββ surveillance.py # Main application script
βββ requirements.txt # Python dependencies
βββ README.md # Project documentation
- π¦ Install Required Libraries: pip install face_recognition opencv-python numpy twilio
Note:
face_recognitionrequiresdlibwhich might need CMake and Visual Studio Build Tools on Windows.
- π Add Known Faces: create a known faces foler and insert faces in folder of theor names
known_faces/
βββ John/
β βββ john1.jpg
β βββ john2.jpg
βββ Alice/
βββ alice.jpg
-
unknown_vedios folder will be automatically created if not exist
-
π Configure Twilio: Replace the placeholders in the script:
TWILIO_ACCOUNT_SID = "YOUR_ACCOUNT_SID"
TWILIO_AUTH_TOKEN = "YOUR_AUTH_TOKEN"
TWILIO_PHONE_NUMBER = "+1234567890"
RECIPIENT_PHONE_NUMBER = "+91XXXXXXXXXX"
-
βΆοΈ Run the Program:python surveillance.py
| Variable | Description | Default |
|---|---|---|
TOLERANCE |
Face matching tolerance (lower = stricter) | 0.4 |
MIN_SIZE |
Minimum face size to be considered (pixels) | 50 |
SMS_COOLDOWN |
SMS cooldown period (in seconds) | 60 seconds |
RECORD_BUFFER_SECONDS |
Time to keep recording after last unknown | 5 seconds |
For bugs or suggestions, open an issue or email:
π§ praveenpuni80@gmail.com
π GitHub: @praveenh001