This repository contains the work done for RaspberryPi based surveillance. I followed a great tutorial on motion detection to get started with the code.
- RaspberryPi 3, and PiCam
- Ubuntu Mate setup for Raspberry, can be found here
- Python 2.7, OpenCv
- Setup of PiCam, can be found here
Here only image processing and motion detection part is summarized.
- The captured frame is first resized to a custom width and then converted to grayscale.
- The gaussian smoothing is also applied to remove some noise.
- The very first frame is assumed as a reference i.e. a static model of the background
- In order to detect the foreground, absolute difference is taken in between reference frame and every new frame.
- If there was any motion in curret frame then the absolute difference image would contain intensity difference. This difference is then magnified by using thresholding
- In last step, OpenCv based countour detection was use to detect the shapes in image. If the detected contour is of a area greater than predefined area then a bounding box was drawn over the countour.