Python · Shipped
Webcam Alert
Real-time motion detection using OpenCV to monitor webcam activity and trigger alerts.
Python
A Python-based security system that uses your computer's webcam to detect motion and send email alerts with captured images when movement is detected.
Features #
- Real-time motion detection using webcam
- Automatic email notifications with captured images
- Configurable motion sensitivity
- Clean and efficient image management
- Multi-threaded processing for better performance
Requirements #
- Python 3.x
- OpenCV (cv2)
- SMTP access for email functionality
- python-dotenv (for environment variables)
Installation #
- Clone the repository:
git clone https://github.com/AhmadTawil1/webcam-alert.git
cd webcam-alert
- Install the required packages:
pip install opencv-python python-dotenv
- Configure email settings:
Usage #
- Run the main script:
python main.py
-
The program will:
- Start your webcam
- Begin monitoring for motion
- Send email alerts when motion is detected
- Save captured images in the
images directory
-
Press 'q' to quit the program
How It Works #
The system uses computer vision techniques to:
- Capture video from the webcam
- Convert frames to grayscale and apply Gaussian blur
- Compare consecutive frames to detect motion
- When significant motion is detected:
- Capture and save the image
- Send an email notification with the image attached
- Clean up old images
Security Note #
- The system uses Gmail's SMTP server for sending emails
- Email credentials are stored in environment variables for security
- Make sure to use an app password instead of your main email password
- Keep your
.env file secure and never share it
- The
.env file is already in .gitignore to prevent accidental commits
Contributing #
Feel free to submit issues and enhancement requests!
License #
This project is open source and available under the MIT License.