Repository navigation
Home
Fernando Alzueta edited this page Sep 11, 2024
·
4 revisions
Welcome to the Motion Detection with OpenCV project! This project implements a motion detection system using the OpenCV library in Python. When motion is detected, the system records a 17-second video.
- Real-time motion detection
- Video recording upon motion detection
- Adjustable parameters for contour area and video duration
- Python >= 3.9
- OpenCV libraries
- Clone the repository:
git clone https://github.com/devluisrodrigues/motion-detection
cd motion-detection
- Install the dependencies:
pip install -r requirements.txt
- Run the script motion_detection.py:
python motion_detection.py
- The script will open your device's default camera and start monitoring for motion. When motion is detected, a video will be recorded and saved in the current directory.
You can adjust the following parameters in the script motion_detection.py:
-
MIN_CONTOUR_AREA: Minimum contour area to consider as motion. Default is 15. -
VIDEO_DURATION: Duration of the video to be recorded after detecting motion. Default is 17 seconds.
- The script captures frames from the camera in real-time.
- Converts the frames to grayscale and applies Gaussian blur.
- Compares the current frame with the previous frame to detect changes.
- If the change is significant (based on contour area), a video is recorded.
- The video is saved in AVI format with a timestamp in the filename.
This project is licensed under the MIT License. See the LICENSE file for more details.