Video surveillance with the Raspberry Pi

Eye in the Pi

© Lead Image © svedoliver, 123RF.com

© Lead Image © svedoliver, 123RF.com

Article from Issue 231/2020
Author(s):

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.

Figure 1: In addition to webcams connected by USB, the motionEye system supports IP cameras integrated into the 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).

Figure 2: The system lets you integrate several cameras into the overview. MotionEyeOS automatically records when it detects motion.

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.

Figure 3: MotionEyeOS supports multiple video formats and lets you customize the recording setup to suit your needs.

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

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • PiCam Surveillance

    The new PiCam camera for the Raspberry Pi delivers image data with very little overhead, making it ideal for video surveillance applications. We find the bumps in the road you'll encounter and show you how to smooth them out with a few Linux commands and pipes.

  • Charly's Column

    Commercial surveillance systems are expensive and typically involve maintenance agreements. I thought there must be a low-budget alternative.

  • Security Lessons: Secure Video

    Unless your surveillance cameras are wired directly to a video board, they are notoriously insecure. We show you how to keep your cameras from being compromised.

  • Surveillance with NAS

    Take advantage of the low watt per operation compute power offered by modern NAS to monitor your cameras.

  • Motion Detection

    The motion detector software, Motion, monitors the video signal from one or multiple cameras and is able to detect whether a significant part of the picture has changed, record and track movement, or launch arbitrary external commands to trigger other actions.

comments powered by Disqus

Direct Download

Read full article as PDF:

Price $2.95

News