Video surveillance with the Raspberry Pi
Eye in the Pi
Set up a professional video surveillance system armed with motionEyeOS and a Raspberry Pi.
Theft, vandalism, and property damage are commonplace occurrences today. Police investigations into such cases often come up empty, and the culprits escape undetected and unpunished. As a result, sales of video surveillance systems consisting of several cameras and a video recorder are booming. Here, I show you how, armed with just a Raspberry Pi and motionEyeOS, you can catch the culprits in the act.
Thanks to inexpensive IP and USB cameras, you can find numerous software packages for the home that can be used to upcycle a computer into a full-fledged video surveillance system. However, these solutions all have a serious disadvantage: They have to run constantly and require a correspondingly large amount of energy.
Professional surveillance cameras are bulky and usually attached by a cable to a control unit; just cutting the data cable will disable the camera. Video surveillance with the Raspberry Pi and the motionEyeOS [1] free operating system, on the other hand, is simple, less conspicuous, and less expensive.
Installation
MotionEyeOS is based on BuildRoot and comes as a small source tarball or as images from the developer's website [2] for various Raspberry Pis and other small board computers. After downloading and unpacking, install the system on a microSD card. For example, on Linux, enter:
dd if=<Image> of=/dev/<Device> bs=1M
Replace the device name with the name of your microSD card, which you can discover by typing the lsblk
command in a terminal window. Now you can boot the Raspberry Pi from the freshly written microSD card.
Before the first startup of motionEyeOS, connect the cameras intended for video surveillance to the Raspberry Pi through a USB port or connect them to your home network. USB cameras are easier to configure over software, but they require a data cable, making wireless cameras a far better choice for surveillance purposes.
The first deployment requires a wired connection to the router: Without such a connection, the boot process aborts after the automatic network setup fails, and the operating system restarts in an infinite loop.
Once you have fulfilled all the requirements, all the services you need will start up automatically when the system is booted, and you will see a login prompt. The first time the system boots, it also creates a new data partition automatically on the memory card and formats it. This can take a long time with large memory cards; however, you should use as much memory as possible, because the recordings from all connected cameras end up on this partition.
After starting the system, you can access the IP address of the Raspberry Pi in your web browser from any workstation on your home network. The browser then opens the login screen of the motionEyeOS front end, which is written in Python and acts as the graphical interface for the Motion daemon.
The username is admin with no password. The software then prompts you to configure the cameras in an almost empty browser window. Now enter the configuration data for the individual cameras in a small dialog.
The software uses the Video4Linux API to address cameras connected to a USB port. You can connect network cameras to the motionEyeOS system by way of Motion JPEG (MJPEG) or the Real Time Streaming Protocol (RTSP) (Figure 1). To secure the connection, you also need to specify the authentication credentials used to access a wireless or wired camera or your local network.
Problematic
When setting up cameras that reside on the local network, motionEyeOS exhibits a minor error, which you can avoid by manually editing a configuration file. With careful configuration, wired and wireless cameras request authentication data during access, rather than being openly accessible in the network.
If you have secured the camera with a self-signed certificate, motionEyeOS simply denies access. In this case, log on to the Raspberry Pi as the administrator over SSH and edit the /data/etc/
file in the motioneye.conf
directory. Next, add a line reading validate_certs false
at the end of the file. After a reboot, the software no longer checks for certificates; the camera in question can then talk to the system, and the web browser displays the current camera image (Figure 2).
Settings
If you click on the menu icon at top left in the application window, the software opens a configuration menu on the left side where you can configure the camera settings. If you have integrated several cameras into the system, select the desired model in the drop-down at the top to assign settings for that specific camera.
In the Preferences group you first need to define how many columns of camera images you want the front end to display in the overview. Use the slide control to change the number of images arranged next to each other. This setting is useful when you want to connect multiple cameras to your Raspberry Pi and display all the images on the screen.
If you are using a low-resolution display, be careful not to activate too many columns; otherwise, the camera images will not be clear because of the extreme reduction in size. In the General Settings area, you can configure basic authentication, provided you have administrative privileges. The data for the administrator and viewers can be adjusted separately.
Other groups in the left pane contain settings for the specific camera. Be sure to activate the Movies option by switching the slide control to its left to ON (Figure 3). If you keep the default OFF setting, the software will not record any video sequences.
During activation, you also have the option of specifying in a selection box the retention period for the recordings. By default, motionEyeOS never deletes recordings, which can lead to storage space problems in the long term. That said, motionEyeOS only records video sequences and stores them on the microSD card when the program detects motion in front of the camera. Changes to the settings only take effect after pressing the Apply button that appears at the top right in the camera pane.
The Working Schedule section lets you switch video surveillance on or off on a daily basis. As soon as you use the slide control to enable the system for a specific day of the week, two additional selection fields open where you can enter times.
At the same time, a selection field appears in the lower part of the window. You can use this to enable or disable motion detection. Motion detection ensures that video streams are not displayed on the monitor without motion in the image.
Assuming you have defined a meaningful retention period for your video recordings, the software ensures that a medium-sized microSD card is all you need as a storage medium for the videos. MotionEyeOS saves the videos in the /data/output/
directory and creates a separate subdirectory for each installed camera.
The settings dialog also has an option to change the directory for the recordings so that the system automatically stores sequences, for example, on the second partition that was created by the operating system when first launched.
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Support Our Work
Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.
News
-
Latest Cinnamon Desktop Releases with a Bold New Look
Just in time for the holidays, the developer of the Cinnamon desktop has shipped a new release to help spice up your eggnog with new features and a new look.
-
Armbian 24.11 Released with Expanded Hardware Support
If you've been waiting for Armbian to support OrangePi 5 Max and Radxa ROCK 5B+, the wait is over.
-
SUSE Renames Several Products for Better Name Recognition
SUSE has been a very powerful player in the European market, but it knows it must branch out to gain serious traction. Will a name change do the trick?
-
ESET Discovers New Linux Malware
WolfsBane is an all-in-one malware that has hit the Linux operating system and includes a dropper, a launcher, and a backdoor.
-
New Linux Kernel Patch Allows Forcing a CPU Mitigation
Even when CPU mitigations can consume precious CPU cycles, it might not be a bad idea to allow users to enable them, even if your machine isn't vulnerable.
-
Red Hat Enterprise Linux 9.5 Released
Notify your friends, loved ones, and colleagues that the latest version of RHEL is available with plenty of enhancements.
-
Linux Sees Massive Performance Increase from a Single Line of Code
With one line of code, Intel was able to increase the performance of the Linux kernel by 4,000 percent.
-
Fedora KDE Approved as an Official Spin
If you prefer the Plasma desktop environment and the Fedora distribution, you're in luck because there's now an official spin that is listed on the same level as the Fedora Workstation edition.
-
New Steam Client Ups the Ante for Linux
The latest release from Steam has some pretty cool tricks up its sleeve.
-
Gnome OS Transitioning Toward a General-Purpose Distro
If you're looking for the perfectly vanilla take on the Gnome desktop, Gnome OS might be for you.