A Python-based intruder detection system that captures video from a webcam, detects objects in real-time, and sends an email notification with an image attachment when an object is detected.
- Real-Time Object Detection: Captures video from a webcam and processes it to detect objects.
- Email Notification: Sends an email with an image attachment when an object is detected.
- Image Storage and Cleanup: Saves detected object images and periodically cleans the storage folder.
- Multithreading: Uses threading to handle email sending and folder cleanup without interrupting the main detection process.
- Capture Video: The script captures video frames from the default webcam using OpenCV.
- Process Frames: Each frame is converted to grayscale and blurred to reduce noise. The first frame is used as a reference for detecting changes.
- Detect Motion: The difference between the current frame and the reference frame is computed. Thresholding and dilation are applied to highlight regions with motion.
- Identify Objects: Contours are detected in the processed frame. If a contour's area exceeds a certain threshold, it is considered an object.
- Save and Email Image: When an object is detected, the frame is saved as an image, and an email with the image attachment is sent.
- Clean Up: The images folder is periodically cleaned to remove old images.
-
Clone the repository:
git clone https://github.com/AVRSANAND/Intruder_Detection.git cd Intruder_Detector
-
Install the required packages:
pip install -r requirements.txt
-
Set up email credentials in
send_mail.py
:email_sender = "[email protected]" password = "your_app_password" receiver = "[email protected]"
-
Run the main script:
python main.py
-
Press q to quit the video stream.
-
main.py: Main script for capturing video, detecting objects, and sending emails.
-
send_mail.py: Script for sending email notifications with image attachments.