Of the many projects you can build with a Raspberry Pi, one of the most interesting and consistently useful is a motion capture security system.

All you need is a basic Raspberry Pi setup, a webcam and an extra battery, and a nondescript security case.

With this setting, you can monitor your property from a remote location, receiving alerts if something is captured by the webcam and optionally a link to the footage.

Compared to the price of off-the-shelf security systems, it’s surprisingly affordable and portable, and as you’ll see below, it can be set up in minutes.

What You Need for Your Motion Capture Security System

There are several approaches to creating a motion capture security system for the Raspberry Pi. I first followed blogger Kean Walmsley’s suggestion to use an ARM-based Arch Linux distribution rather than regular Raspbian.

However, that didn’t seem to work, so I went back to Raspbian OS and used the camera drivers and the motion detection package, which we’ll cover in a moment.

ii-rpi-secsystem-sd-camera

In addition, you will also need a Raspberry Pi, a formatted SD card, a webcam (see Elinux.org/RPi_USB_Webcams for compatible devices), and a power supply; You will probably need a powered USB hub as well, as many webcams need their own power supply when connected to the Pi. This can be a powered USB cable or a Raspberry Pi battery solution, of which there are many options, most of which you can find via the eLinux wiki. Please note that there are alternatives such as 4x or 6x rechargeable AA batteries. Some portable iPad chargers will also work — but check your charger’s model number online before trying to connect to your Raspberry Pi)

If you don’t already have a webcam, you can spend a few dollars on an official Raspberry Pi webcam.

Follow the instructions outlined earlier in to install Raspbian and for best results make sure it’s configured using SSH . You must also change the password using the raspi_config menu. .

Install the necessary software

With a Raspberry Pi loaded and an open SSH connection from your main computer (you can use the keyboard on your Pi, but SSH is better as it will need to link to the security setting in the future) should be done this way) you should start the process of downloading the latest update:

sudo apt-get update 

Next, install the emacs editor by agreeing to the prompts:

 sudo apt-get install emacs 

After that, you will need to install the VNC server. This will allow you to connect to the security system and view the output. Comply and agree to any requests.

ui-rpi-secsystem-vnc-install

 sudo apt-get install tightvncserver 

After installing VNC Server, enter the command vncserver — You will need to set a password to use the system. You must also agree to the subsequent view-only password prompt.

ui-rpi-secsystem-vnc-conf

The next step is to edit the VNC server initialization script. Enter the following to navigate to the correct directory:

 cd /etc/init.d 

Then you can start emacs:

 sudo emacs tightvncserver 

With the console open, copy the following:

 #! /bin/sh # /etc/init.d/tightvncserver # # Carry out specific functions when asked to by the system case "$1" in start) su pi -c '/usr/bin/vncserver' echo "Starting VNC server " ;; stop) pkill vncserver echo "VNC Server has been stopped (didn't double check though)" ;; *) echo "Usage: /etc/init.d/blah {start|stop}" exit 1 ;; esac exit 0 

Right click to paste it into Emacs. After a few moments, it should automatically save. Exit by pressing Ctrl + X and agreeing to save the file on exit.

Then you must change the permissions on the VNC server directory by making a new script executable:

 sudo chmod +x tightvncserver 

The following command will tell the VNC server to boot when the Raspberry Pi Security Center boots:

 sudo update-rc.d tightvncserver defaults 

We’re almost done, so let’s end the current VNC session:

 sudo pkill Xtightvnc 

You are then ready to restart it:

 sudo /etc/init.d/tightvncserver start 

On your primary device — the computer you plan to monitor your webcam from — you can now open your VNC client. Various suitable clients are available — I used the TightVNC client for Windows.

Setting up your webcam

ui-rpi-secsystem-pi-camera

We are now at the point where we can start preparing the Raspberry Pi for your webcam, which means installing the drivers, necessary libraries, and capture software. Enter the following commands in turn, paying attention to the prompts.

First is the motion detection software:

 sudo apt-get install motion 

Next, install the required libraries:

 sudo apt-get install libv4l-0 

ui-rpi-secsystem-uvccapt

UVCcapture is a software designed to capture a feed from a webcam:

 sudo apt-get install uvccapture 

Now you can attach your webcam and check that everything is working. Enter the following command:

 dmesg | tail 

This will output the details of your camera model as shown below.

Create a Motion Capture security system using Raspberry Pi muo rpi system camera

Next, we need to install motion capture, so run:

 emacs /etc/default/motion 

… and set to start_motion_daemon meaning yes .

If you have permission issues here, use:

 sudo chmod 777 /etc/default/motion 

Don’t forget to undo this after the edit has been saved.

After saving this change (CTRL + C, following the instructions on the screen to save), you will need to edit the motion.conf file.

 emacs /etc/motion/motion.conf 

The script below (taken from the Raspberry Pi forum thread «Installation Guide for Motion Detection with Webcam») should be added to motion.conf:

 set "daemon on" set "minimum_frame_time 5" (this can be modified, depending how often you want to take picture) set "pre_capture 2" set "post_capture 2" set "output_normal on" set "quality 100" set "ffmpeg_cap_new on" set "ffmpeg_timelapse 30" set "ffmpeg_variable_bitrate 2" set "get_dir /media/webcam/motion" set "webcam_port 8080" set "control_port 8081" (important) set "webcam_localhost off" set "width 320" (important) set "height 240" (important) 

Note that these settings can be customized as needed. Those marked as «(important)» should be left as is.

Set media options for motion

We’re almost done with a few media settings and a wireless dongle setup.

The motion detection images need to be saved in the media folder, but first you need to change the read/write permissions:

 sudo chmod 777 /media 

Then run the motion software:

 sudo /etc/init.d/motion start 

Movement can be stopped with:

 sudo /etc/init.d/motion stop 

You should see a message confirming that the software is working. Does it speak to your webcam? Run the following command to check:

 tail -f /var/log/syslog 

The output should confirm that the device is running and receiving data. The last step here is to download the VNC client on your desktop computer and connect to your Raspberry Pi (run ipconfig to check the IP address) using the suffix : one which stands for X session number one.

Boxing and Positioning Motion Sensor Security Camera

While you might prefer to remove the webcam from its stylized case for improved portability and easier coverage, it’s best to evaluate positioning options before doing so.

Indoor testing will help you set the camera’s range and motion capture sensitivity, which is useful when setting up the device outdoors.

For outdoor use, you’ll need a suitable waterproof case, perhaps an old ice cream tub or a hobby box from an electronics store. Some drilling may be required to run the power cable to the installed Raspberry Pi powered security camera if you want to position it outside. However, you may also want to consider a battery-powered solution for your small computer (note, however, that this will require regular recharging). Ethernet is preferable under these conditions, so you may need to go into DIY mode and apply some mastic gun waterproofing, but if you want to use wireless, you can. Using a wireless repeater can help with outdoor signal strength.

Checks after positioning

With the RPi installed, you should go back to your computer and make sure everything is in order.

ii-rpi-secsystem streaming

Start by making sure the network connection is up and running. Although it should have been checked before, your wireless dongle may have problems connecting in windy conditions or if you have any unusual architectural structures or materials .

Once the connection is established, you must also go outside and go through several motion capture scenarios to make sure your motion is detected and alerted.

Finally, during the first day of testing, keep an eye on battery usage if you opt for a portable power source, as you will need to know how much recharging is required. Keep in mind that if the camera is indoors or relatively close to a switched off building, the best solution is to use AC power.

Conclusion: a home security solution with an educational tool!

Who would have thought you could do so much if you had a caseless mini computer ostensibly designed to teach kids to code with tools like Scratch?

As a media center creation solution and other great uses, setting up the Raspberry Pi as a home security solution with motion capture is that it can be done with a single device as well as with a single device. chose security when you go out, or with an available dedicated device.

The possibilities of the Raspberry Pi seem endless.

Похожие записи