Has the idea of create a home surveillance system with which you can record video parts and generate alerts when a movement is detected? This is one of the interesting projects that can be run with a Raspberry Pi.
But It is not the only use that you could give to this video surveillance system. It can serve as a video communicator, to record images during certain hours of the day or perform a security backup in the car.
And although great security systems are created and installed by professionals, This home product can be assembled by you. We will teach you the simple way to do it, the step by step you must take and the materials you will need to get to work.
What is Motion and what is this tool for on Raspberry Pi?
When you think of setting up a streaming video system there are several options. In this case, we are going to focus on Motion, a program that receives multiple signals from webcams through USB ports and monitors them. Formats that are supported include “jpeg”, “ppm” Y “mpeg”.
When a person appears within the limits that the installed camera covers, Motion begins with the capture of images and video recording, which allows to detect who is the intruder who has happened to your property. If no difference is detected in the image sequence, the program does nothing, it only acts when it perceives important variations. In addition, the tool periodically captures photos and performs timelapse.
What do I need to set up a video surveillance system with Motion and my Raspberry Pi?
There are not many materials that are needed to make the project of a movement detection system a reality, just have the following at hand:
- A Raspberry Pi micro computer with its power cord.
- As minimum, a USB webcam compatible with the operating system you are using.
- Micro SD card with enough capacity to store photos and videos.
- HDMI cable, mouse and keyboard, this in case you want to see the images directly on the plate. If you use a remote server it will not be necessary.
Learn step by step how to create a webcam server with Motion to create your video surveillance system from scratch
Yes on the Raspberry Pi the Raspberry Pi OS (formerly Raspbian) operating system is being used, there will be more compatibility. We will show you all the steps you must take from scratch to successfully make home video surveillance project setup.
Go for it:
Check compatibility
This is the first step we must take to start our project. For it we connect a webcam in the USB port.
Then type the following command in the terminal:
lsusb
In the result that the screen will show you, The name and model of your webcam should appear. If so, it means that it is compatible with your operating system.
Install the Motion system
There is at least two ways to install. We are going to stay with the first one, which is with distribution repositories.
To do this you must execute the following command:
sudo apt-get install motion
Configure Motion
What follows is adapt the new software to what we want to do Or, in other words, adapt it to be a surveillance platform.
To do this, we are going to follow a basic routine:
- Backup: We must save it before making any changes, it serves as a backup. To do this, run the following command:
sudo cp /etc/motion/motion.conf /etc/motion/motion.conf.bak
-
We edit the configuration file from the terminal with the following command:
sudo nano /etc/motion/motion.conf
- When loading the file, we start looking for the items that we are going to change or update.
- Daemon: to run in the background, we must place it in “On”.
- webcam_localhost: must be marked in “Off”.
- Live Webcam Center: here we put the following “webcam_port 8001”.
- Snapshots: in this case the interval in which the screenshots will be taken goes, we assign a time editing “snapshot_interval”, at the end there is a number that indicates the seconds of separation.
- HTTP Based Control: we change this segment to “control_port 888”. The value that corresponds to “control_localhost” we put it in “Off”.
- start_motion_daemon: we place “And it is”.
Start the surveillance system
To put into action Motion, we only need to execute the following command: sudo motion
. From this moment on we will begin to see results. If we want that the program starts automatically, you have to execute the following command: sudo nano /etc/default/Motion
and we will change this line: start_motion_daemon=no
. In the end instead of “No”, we will place “And it is”.
Use multiple cameras
The cameras must be configured individually. To do this, use the following command: /etc/motion
and for each device it should look like this: /etc/motion/camera1.conf
for the first and /etc/motion/camera2.conf
for the second and so depending on how many they are.
When we create the files, then we must modify the following:
-
"/dev/video0"
is assigned to the camera “one” and it will change for each one. - In case of USB cameras, in “Camera type” should be placed “imput -1”.
- And each one must have a different port: “stream_port 8081”.
- After the values are defined by camera, in case there are several, you must go to the configuration file of each one with the following command:
etc/motion/motion.conf
and leave them as follows:camera /etc/motion/camera1.conf
, remembering that the number changes according to the number of devices.
Configure where images are saved
The last step of the configuration is define the quality, the format and the images that will be registered in the system. Therefore, we are going to edit the following command /etc/motion/motion.conf
.
The following settings appear there:
- “On” to save all images and “Off” not to.
- “First” indicates that the first of each event will be saved or “Best“Only those with more movement.
- “Center” the ones with movement in the center of the frame are saved.
- Later, follow the image size and format. You should adjust them according to your preference in pixels.
The best webcams to integrate into your video surveillance system with your Raspberry Pi board
Let’s do the choice of the device that will give the image to be able to make the captures and security videos. Don’t worry if your budget is cut, even the cheapest are recognized by your badge, only the quality will not be the same. We have compiled five models with good characteristics that we leave them for you to analyze.
Remember that you must verify that there is a fair compatibility:
Raspberry Pi high quality HQ
With a resolution of 12.3MP, this camera is HQ quality with a sensor Sony IMX477, allowing you to have increased sensitivity to light. An advantage of this model is the exchange of lenses, thus increasing its focal length.
Raspberry Pi Camera Module V2
It is the second generation of cameras and use a fixed focus lens. It also uses a Sony imx219 sensor that records images at 1080px and 720px with a resolution of 8 megapixels. It has a short ribbon cable to connect to the Pi without major difficulties.
Ashu-H701 Webcam
This camera that displays images in 1080px has automatic focus and connection with USB 2.0 port using CCD technology. It is one of the best options you will see on the market.
LOGITECH-Webcam C270
The 3 megapixel camera with 1280px x 720px resolution, at 30 fps, includes automatic lighting correction And it can be adjusted securely with the built-in clip. The way to connect it is by USB. It is also an excellent option to make a video recording platform.
1080px camera module
This module is compatible with Raspberry Pi models 2, 3 and 4. It has a 75-degree wide angle, five million pixels and an OV5647 chip. One fact that you cannot miss is that Before buying a webcam you should check that it is compatible with the operating system that you are using, for this you can look for information on the official Raspberry site or see the specifications that the manufacturer places.
Meet the best Raspberry Pi boards to mount your video surveillance system with Motion without problems
Necessary make a good choice of the board for the video surveillance system to flow and have as few interruptions as possible.
Although from the first models they can be used to do it, we are going to show you three series that will be your allies:
Raspberry Pi B3 +
If your ideas include developing the project with more than one camera, you should take into account this model that includes four USB ports, apart from a CSI port to add an additional one. It has a 1GB RAM memory and the internet connection is both by Wifi and by network cable.
Pi 4
This is the most current model that you get on the market, with its respective updates. It can be obtained in versions of up to 8Gb of RAM, but we are interested in the connections. It has wifi and Gigabit Ethernet for the internet and also four USB ports, two 2.0 and the rest 3.0.
Pi Zero
The RAM 512 is a limitation, the 2 x 20 GPIO and 2 USB ports allow us to include this model among the best cards for your project. It was at the time one of the most powerful processors, giving a new face after the release of the Pi 1 version.
List of the best alternatives to Motion to mount a Webcam server on a Raspberry Pi without problem
Yes OK Motion is one of the most used programs by clients of Raspberry Pi to configure a video surveillance system, there are other applications that are supported.
You should know all the options on this list:
Shinobi Video
This video surveillance server is also easy to use. It is multiplatform and has two versions, a free license and a paid version., the biggest difference is in the regular updates. It has various recording methods, supports various video formats, remote storage management, and motion detection.
iSpyConnect.com
This tool is an alternative that allows you to connect and control the webcams that are in the mini computer for free. There is no limit of connections, it detects movements and recognizes certain objects. To download it, you just have to go to its official website ispyconnect.com.
Xeoma
This program offers different versions and is available for different operating systems. It can be used without problems on Raspberry Pi, allowing easily create the webcam server you need. It has facial recognition, object detector, motion search and recording to multiple discs simultaneously. You can access their website felenasoft.com/xeoma/es/
.