Make your Pi moonlight as a security camera | Techno Glob

A decade ago, I was learning Linux by creating projects for my own needs. One of the projects is a DIY CCTV system based on a Linux box – specifically, a user-friendly all-in-one package for anyone willing to pay for it. I stumbled upon ZoneMinder, and those in the know can already tell what happened – I’ll put it this way, I spent several days trying to get it to work, and my Linux skills weren’t up to par at the time. Cool software like Motion was available at the time, but I wasn’t working on turning the whole system around it. He said, it is not impossible, will it happen now?

Five years later, I joined Hackerspace, and eventually learned that its CCTV cameras, though visually striking, had long since stopped working. At the time, I was in a position to do something about it and built an entire CCTV network around a software package called MotionEye. Having working CCTV cameras is very important in the hackerspace – the functionality not only solves the problem of “who made a mess that no one admits to”, but over the years it has helped us with things like finding security interlock keys. Laser cutters that were removed during the reconstruction, their temporary location was immediately forgotten.

Using MotionEye to quickly build security cameras became easy – when I needed it, I could make a simple camera to monitor my bicycle, verify that my neighbors didn’t forget to feed the pets as promised while I was away. , and under certain circumstances, I was able to ensure the physical safety of myself and others with its help. How do you build an always-recording camera network in your home, hackerspace, or other property? Here is a simple and powerful software package that I would like to show you today and it is called MotionEye.

Help => About

Motion is a powerful daemon on Linux for transferring video streams in a security camera-like fashion – it does things like detect motion and record video clips when it happens. However, it is a commandline daemon, and does not have a comfortable enough graphical interface for user-friendly camera imaging operations. MotionEye is a Python package wrapped around Motion, giving you a web interface to manage your cameras, but more importantly a wealth of quality-of-life features.

MotionEye is reasonably easy to install – it only needs a few packages and a few Python dependencies on your OS, and you can set it to autostart using things like systemd. Then, point your browser at its web interface, and you’ll be presented with all that MotionEye has to offer, accessible using your desktop OS and your phone. Your software also has Docker images if you like! From there, you can start exploring the features.

For example, setting up motion detection can be annoying when dealing with GUI-less tools – sometimes you have areas in your image that are constantly changing, but you don’t consider these areas meaningful for motion detection purposes. MotionEye lets you quickly set a motion mask via a web interface, which the motion daemon then uses to filter motion events at their source, with as little overhead as possible. It also introduces you to options like hardware encoding, which you might otherwise miss out on manually.

For those of us who don’t want to set up some kind of local storage, or push motion notifications to their phones, MotionEye can use numerous picture and video upload methods that rely on online services – email, Google Drive, Dropbox, etc. It also lets you set commandline hooks on the start and end of motion events, which you can then use for various automation tasks – I’ve personally used these hooks to graph motion events. matplotlibHackerspace as a visual tool of attendance data for automation purposes.

There are limits, of course. For example, as Motion is based on, MotionEye doesn’t have audio support – although you can use MotionEye hooks with an external audio recording script to split sound into recorded clips. If you have cameras with different aspect ratios, MotionEye won’t always display them in a neat grid, although I’ve solved that before with CSS hacking. However, it’s still a pretty powerful package in terms of what you can do.

MotionEyeOS – Out-of-the-box experience

You don’t need to preinstall a distro. MotionEyeOS is a small SD card image containing MotionEye and everything you need to make it work built with the help of Buildroot. Simply flash the image to a MicroSD card, provide wireless credentials, or plug in an Ethernet cable. After setting up MotionEyeOS, it will automatically pick up all cameras if it detects a CSI-connected Raspberry Pi camera. It’s not limited to the Raspberry Pi, of course – there are also releases for Odroid, NanoPi, Kenapi, OrangePi and Pine46 boards.

MotionEyeOS uses read-only storage by default for the system, and I’ve found it to be incredibly resilient to power outages, although of course, if you don’t enable local recording, it won’t write anything except settings changes. SD card. Since the images are so small, I used some leftover 512MB cards for the boards I set up. It’s so handy for single-purpose cameras, perhaps its only problem is that it hasn’t yet been updated for boards like the Zero W 2, but there are custom builds by MotionEye community members!

In the default configuration, MotionEye will record to your available main storage device – using your root file system in the case of a standalone MotionEye installation, and in the case of MotionEyeOS, it will be an automatically created partition taking up all space not occupied by the MotionEyeOS core. . Given that you’ll likely run off an SD card plugged into the Raspberry Pi, it makes more sense if you connect a USB HDD or SSD instead, and if you’re setting up multiple cameras, a network-connected storage device. Better than that. Which brings me to the next point!

DVR-ready, too

MotionEye isn’t just for camera-equipped devices – you can create DVRs with it. For that, install MotionEye on a reasonably powerful computer with some large inexpensive hard drives and then capture video from network cameras, whether MotionEye-based or Chinese IP cameras connected to an Internet-less subnet. With a setup like this, you don’t need to do motion detection or storage on the camera itself – which lets you use cheap Raspberry Pi boards, like the original Model B, and small SD cards without fear of corrupting video files if there’s power. Cuts off in the middle of writing.

In the aforementioned hackerspace, I have Raspberry Pi-connected cameras in various corners, some powered by MotionEyeOS and some added with MotionEye already running on them to enable various hackerspace features. Our DVR platform was an industrial DN2800MT mainboard with two SATA HDDs in software RAID1 – I had no hardware encoding, as the N2800’s iGPU drivers were subpar on Linux, but the CPU was sufficient to work with 8 cameras of various resolutions. at one time.

You don’t need to use a separate DVR. You can have MotionEye cameras, and then set up MotionEye as a non-recording camera viewer on some computer, maybe even your personal laptop – letting you view and configure all cameras from one place. This way, you get a dashboard with all the cameras and no additional hardware required. You’ll find that MotionEye is more flexible than the scenarios I’m telling you about, but this is a decent overview of what you can do.

Help, stay safe, stay equipped

Now, MotionEye is one of those projects that is beloved by many, but doesn’t have enough developer attention right now because the lead developer stepped down two years ago. Because of the value it provides, the community remains vibrant and useful, but the codebase could use a few people who are willing to explore it. The code is pretty maintainable, but there are numerous TODOs to take care of – some I’ve noticed are working through the kinks of the Python 3 port, integrating the new Raspberry Pi firmware into the build, getting the buildroot integration working again, fixing the Google Drive integration and all that has accumulated. Moving on to smaller problems.

You may already have a use case in mind, but don’t forget to check your local laws! You may not be allowed to operate the camera willy-nilly or with certain objects in its view. However, a sticker that says “video recording” may be enough for where you are. One could also argue that if a camera is on your property, it has a right to be there and perform all the functions that a camera does. On the other hand, it wouldn’t go amiss to spook a guest with a camera in your living room – like, adjust accordingly.

You probably have a spare Raspberry Pi camera or two, and now you know what you can do with one. Who knows what you can create – after all, we’ve even seen MotionEye-powered Halloween decorations! Next time, I’d like to tell you more about securing your Linux-powered camera network, specifically using point-to-point WireGuard tunnels on your LAN – ensuring that even your WiFi-connected cameras can’t be snooped on. .

Source link