- Region of interest
- Adaptation to light changes
- Works 110% of the time
- Performant, uses 0-1% of CPU and 40 mb of RAM
- Download Python
- Download the file
main.py
- Install the
pyautogui
library for hotkey support usingpip install pyautogui
in the console. - Set the
debug
variable toTrue
in the main.py file. - Run the script with
python main.py
in the console. - Adjust the settings in the main.py file through trial and error to suit your use case.
- Set
debug
toFalse
and run again
You can modify theon_movement_detected()
function to customize actions upon movement detection. If issues arise, experiment with different settings.
Here is the algorithm:
- Capture the image from a webcam
- Downscale the image to eliminate some noise
- Convert to hsv and remove brightness information
- Compare the hues of the processed image to the previous frame's hues
- If the difference exceeds the threshold, motion is present