This project captures video from a webcam, detects movement, and sends an email with an image attachment when movement is detected. The project uses OpenCV for video processing and the smtplib library for sending emails.
- Python 3.x
- OpenCV
- smtplib
- imghdr
-
Clone the repository:
git clone https://github.com/Nibir2405/email_webcam_detection.git cd email_webcam_detection -
Install the required packages:
pip install opencv-python
-
Update the email credentials in
sending_email.py:EMAIL_ADDRESS = "your_email@example.com" PASSWORD = "your_password" Receiver = "recipient_email@example.com"
-
Run the main script:
python main.py
-
Press
qto quit the video feed.
main.py: The main script that captures video, detects movement, and triggers the email sending.sending_email.py: The script that handles sending emails with the captured image as an attachment.images/: Directory where captured images are stored temporarily.
- The script captures video from the webcam.
- It converts each frame to grayscale and applies Gaussian blur.
- It calculates the difference between the current frame and the first frame to detect movement.
- If movement is detected, it saves an image and sends an email with the image attached.
- The script cleans up the
images/directory after sending the email.
- Ensure that you have enabled access for less secure apps in your email account settings.
- Check your SMTP server details and credentials.
- If you encounter issues with sending emails, try using a different email provider.