A motion detection and logging application in Python using a stationary camera.
RPi Camera | Sample output |
---|---|
py-motion-detection
is a Python/OpenCV app that can be used for detecting motion and logging the frames in a directory.
The motion detection app expects a motion detection model. The one developed in this project is inspired by the excellent tutorial by Adrian Rosebrock.
Once motion has been detected the motion detection model will return a list of bounding boxes indicating the location of the objects that have been detected, or an empty list if no motion has been detected.
The users can define callback classes to respond to motion detected events. The default callback used by the command line tool is to store the frames where motion has been detected in a user-defined directory along with the bounding boxes stored as jsons.
- Poetry 1.8.2 or above
- Python >= 3.12 or above
To install py-motion-detection
run:
poetry install
To run all the tests:
poetry run pytest tests
To read the project's documentation run:
poetry run mkdocs serve
and click on this link.
The py-motion-detection
CLI will start the motion detection app.
To see all the available options of the py-motion-detection
app run:
py_motion_detector --help
Example usage:
py_motion_detector -p $HOME/Downloads/motion_detected_frames/ -r 800 -m 500 -t 4 -l /tmp/log -i INFO
The py_motion_detector_data_player
CLI can be used to replay the stored frames and their bounding boxes.
To see all the available options run:
py_motion_detector_data_player --help
Example usage:
py_motion_detector_data_player -p $HOME/Downloads/motion_detected_frames/ -w 500 -l
sudo apt-get install libatlas-base-dev
sudo apt-get install libjasper-dev
sudo apt-get install libqtgui4
sudo apt-get install python3-pyqt5
sudo apt install libqt4-test
Run the following before running the python script:
sudo modprobe bcm2835-v4l2
The content of this site is distributed under MIT NON-AI License.