espressif / esp32-camera

Apache License 2.0
1.93k stars 641 forks source link

Motion Detection #65

Closed billyrudi closed 3 years ago

billyrudi commented 5 years ago

Hi, is it possible to detect motion only using video not pir or external sensor? How i can detect if the frame video is changing ? regards Paolo

ithinkido commented 5 years ago

https://github.com/raphaelbs/esp32-cam-ai-thinker/blob/master/examples/change_detection/README.md

billyrudi commented 5 years ago

Tank you. Is it compatible with arduino ide?

bkeevil commented 5 years ago

Well you would decode each JPG frame into a bitmap image, buffer it for a frame, and then do a pixel by pixel comparison, counting the number of changed pixels. Take a look at the motion package for linux, it is quite good. That package applies a blurring algorithm before doing the comparison to reduce false positives due to noise.

bluguru4567 commented 5 years ago

While my ESP32-CAM is waiting for a client to connect to stream video, I'd like it to be a motion detector and email me when it detects motion. I wonder what would work better: 1) comparing snapshots for change (and possibly missing something while processing or doing other actions), or 2) using a PIR. I love the idea of not using the PIR, but I guess I'd like to test both.

bkeevil commented 5 years ago

I was actually intending to do something similar with my webcam code if you want to compare notes. I will be starting the software motion detect feature soon.

bkeevil commented 5 years ago

I was thinking of creating a FreeRTOS task that retrieved a frame at a low resolution using YUV422 pixel encoding and comparing the individual pixels. The frame rate does not need to be very high.

alanesq commented 4 years ago

I have done something along these lines recently which may be of interest: https://github.com/alanesq/CameraWifiMotion

It is based on the motion detecting code created by https://eloquentarduino.github.io/2020/01/motion-detection-with-esp32-cam-only-arduino-version/ although I have modified it a lot.

github-actions[bot] commented 3 years ago

This issue appears to be stale. Please close it if its no longer valid.