Aim: To use the raspberry pi camera as a CCTV camera which records only when motion is detected.
Imagine a scenario wherein something gets stolen from your house. With a normal security camera set up at your door, you'd have to go through hours of footage to get to the time when someone entered your house. Meanwhile, the thief could be using this precious time to cover his tracks and escape.
However, with this program in place, you’d be able to easily access points where movement happened at your front door, making the process more efficient. Not only does it make reviewing feed easier, but is also easy and inexpensive to implement since it is very lightweight. It can easily be run on a raspberry pi.
The program runs repeatedly and when ended, it shows the date and time of the recordings in a tabular form, using a CSV file of the format:
S.No. | File Name | Start Time | Date |
---|
This program calculates the Root Mean Squared Error (RMSE) between the RGB values of successive images clicked at 2 second intervals. If RMSE > 50, then feed is classified as "moving", else it is classified as "stationary".
Logic:
- If the camera is not recording and RMSE > 50, then recording is started
- Else if the camera is recording and RMSE < 50, then recording is stopped
- Else do nothing
- Raspberry Pi 3b+/4b+
- Raspberry Pi Camera Module V2
- Power Supply for Raspberry Pi
- HDMI/Micro-HDMI cable or VNC server installed on Raspberry Pi
Connect the camera module to the raspberry pi's camera port.
For this project, I installed Raspbian and the required libraries (as declared in the program) on a Raspberry Pi 4b+.
I ran the program cctvFeedController.py using Thonny.
If all goes well, your output should look like this:
Feel free to reach out to me in case of any queries. I'll try to reply to all questions within 24 hours.
Do share your comments. I'd love to hear about your experience while trying out the project!
- YouTube:
a. Scientify Inc
b. Scientify Hindi - Linkedin
- Instagram
- Instructables