Build Your Own Surveillance Camera With Raspberry Pi and Motioneye

20,670

176

24

About: A web developer and Technology enthusiast love to explore something, right now my interest is on raspberry pi.

Intro: Build Your Own Surveillance Camera With Raspberry Pi and Motioneye

Hi there, in this project I'm going to show the steps I done how I setup my raspberry pi security camera with 2 webcam using motioneye in this tutorial I use a 1080P A4 - Tech camera & low resolution A4 - Tech camera you can plug multiple camera on the raspberry pi but I suggest to max it up to 2 or 3 of any webcam you want. Also note that this will not cover how to access the surveillance camera at office or at other places ( can only be access thru your network ), this will focus on how you'll able to setup a home surveillance with multiple camera using a raspberry pi and motioneye an easy step by step procedure.

Here's the hardware I use for my home surveillance system:

Notice that I use a heat sink and a fan to reduce the temperature and since it's processing an image & video obviously the temperature can go easily high but it's normal and optional it's not required though it's up to you.

Step 1: Installation ( Fresh Setup No OS )

Assuming that you have a new pi and trying to figure out how to build your own affordable home surveillance with multiple cameras that's capable of motion detection and records it or take a pictures using a raspberry pi and motioneye. Here's what you need to do:

Download the latest OS here get the latest raspbian version, in my case I use the latest RASPBIAN JESSIE WITH DESKTOP version "2017-07-05" by the time this tutorial was made.

Step 2:

Write it to your SD Card, download & install the software etcher it's easy to use don't worry, it takes a couple of minutes to write the image depending on your machine and when it's finished writing, your SD Card will look like only a couple of MBs space left but it's normal don't panic when it happened.

Step 3:

Insert the SD Card to your pi remember at first installation SSH is disabled by default so the only work around here is to plugged your monitor to the raspberry pi hdmi, you'll gonna need a VGA to HDMI converter. It's necessary to enable so you can access your pi in other PC / Laptop / Devices using a Putty client if there's something you want to add or you want to shutdown / reboot your pi. Unless you want to run it with monitor for a long time.

Once the raspberry desktop has start click the command line at the task-bar and type the following command:

sudo raspi-config

This will show you a bunch of options similar to the image below:

Step 4:

Choose #5 and another screen will follow this time Select P2 SSH after doing this your ssh is now enabled.

For fresh install raspbian you need to set the root password manually ( if you don't know the default password ) to do this just enter this command and enter your desired password:

sudo passwd root

Step 5:

You need to remember some command can't be used without a root privileges that's why we need to log as root user for us to be able to perform administrative tasks to do this just type "su" at the command line and enter the password that you set at Step 4. Once you're log in as root, type this command to updates the dependencies of the pi.

sudo aptitude update && sudo aptitude upgrade

Step 6:

motioneye require some dependencies for it to enable some features in this tutorial we will going to install all dependencies required for it to run all the features. Let's start by installing the ffmpge for the video let's download the package by using this command:

wget https://github.com/ccrisan/motioneye/wiki/precompiled/ffmpeg_3.1.1-1_armhf.deb

After the download let's install it to our pi, in here you need to have a root privileges as discussed at Step 5.

dpkg -i ffmpeg_3.1.1-1_armhf.deb

Step 7:

We need to make sure that there's no duplicate libraries for your home security camera to work properly. Let's remove some packages that can interfere on motioneye using this command.

apt-get remove libavcodec-extra-56 libavformat56 libavresample2 libavutil54

Step 8:

Let's install a couple of dependencies using this command:

apt-get install python-pip python-dev curl libssl-dev libcurl4-openssl-dev libjpeg-dev libx264-142 libavcodec56 libavformat56
libmysqlclient18 libswscale3 libpq5

Step 9:

Download the motioneye package:

wget https://github.com/Motion-Project/motion/releases/download/release-4.0.1/pi_jessie_motion_4.0.1-1_armhf.deb

After the download let's install it:

dpkg -i pi_jessie_motion_4.0.1-1_armhf.deb
pip install motioneye

Step 10:

Prepare the configuration directory:

mkdir -p /etc/motioneye

and copy the config file just in-case you will be editing it in future:

cp /usr/local/share/motioneye/extra/motioneye.conf.sample /etc/motioneye/motioneye.conf

Prepare the media directory:

mkdir -p /var/lib/motioneye

Step 11:

Add an init script, configure it to run at startup and start the motioneye server:

cp /usr/local/share/motioneye/extra/motioneye.systemd-unit-local
/etc/systemd/system/motioneye.service
systemctl daemon-reload
systemctl enable motioneye
systemctl start motioneye

Step 12: Installation Done!

That's it you have now installed the motioneye and you now have a home surveillance camera using raspberry pi. To access the configuration go to your raspberry IP Address there's two way to get your IP:

  1. If you are still connected to your raspberry pi, you can type this command: ifconfig
  2. Or access your router dashboard to find your raspberry pi address.

If you are able to find it type this to your browser: Your-raspberry-ip-address:8765 and you'll be able to render a login form.

Step 13: Motion Eye Basic Setup

Once you access your Raspberry IP address you'll be prompt with a login form, remember atdefault the user is 'admin' and leave the passwordempty.

Step 14:

It's time to plug-in those web camera for your DIY home surveillance system wait for a couple of seconds to be recognized by your raspberry pi.

Step 15:

Once you add all you home surveillance camera you need to have an access to the advance settings of motioneye.

Step 16:

"Automatic Brightness" is required only if your camera is capable of it in my case the 1080P A4-Tech has this.

Step 17:

Settings for image capture when motion is detected it will take a pictures.

Image Quality: Self explainable it's up to you if you go 100%.

Capture Mode: There are 3 other options here I haven't tried the other except 'Motion Triggered' this settings allowed to take a snapshot if it's triggered by motion.

Preserve Pictures: Duration how the image will be saved to your storage (SD Card).

Step 18:

Set this ON it's a settings for video recording when a motion is detected it's the same settings to image.

Step 19:

Motion Detection settings for your surveillance camera this is also important you'll be able to tweak some default settings in motion detection.

Frame Changes Threshold: I found this sensitive in my test I can say the option that fit best for my camera is 5%, It checks the slightest changes on the environment and found no problem when I check the log of my home surveillance camera I found images / recordings with people walking.

Motion Gap: The gap between movement and none movement.

Captured Before & Capture After: Self explainable.

Minimum Motion Frames: Count of frame that it detect of motion, meaning to say if the camera found a motion it will wait for two frames and check if those motion are not the same, if found not match it will start to take a pictures & take a video recording of those motions, this settings rely on the Frame Changes Threshold.

That's it enjoy! :D

Share

    Recommendations

    • Plastics Contest

      Plastics Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Optics Contest

      Optics Contest

    24 Discussions

    0
    None
    3463264078qwer

    Question 2 months ago on Step 14

    i don't know how to add pi camera,

    i try sudo nano /etc/modules

    Then add:

    bcm2835-v4l2

    Then reboot.but it didn't work;

    i don't know what the camera url is,thank you for your time!

    捕获.PNG
    0
    None
    nfarrow

    5 months ago

    Does MotionEye work with a Pi zero?

    0
    None

    There is another solution for activate ssh without monitor / tv. When the SD is writed, you can navigate from your computer and create a file named "ssh" in the /root directory. When the raspberry pi starts, has enabled ssh.

    0
    None
    smooth_jamie

    1 year ago

    Cool project! can I use any generic webcam? or does it have to be the one you've used?

    3 replies
    0
    None
    HARD-softIsmooth_jamie

    Reply 8 months ago

    yes u can use but for image processing project you better use CSI or R-pi based default camera because usb camera is too slower for even an average performance. you can use both but only for economic design not premium one.

    0
    None
    wb666greeneyourdiy

    Reply 1 year ago

    Not quite, most modern web cams use the UVC driver, these should work, but its a long way from "any" as there are still some floating around that don't have working Linux drivers.

    0
    None
    wb666greene

    1 year ago

    You can find instructions for installing Motineye on Raspbian-Stretch here:

    https://groups.google.com/forum/#!topic/motioneye/...

    I hope @yourdiy will add them to this instructable, as his explanations are much clearer than what I have time to produce.

    All the post installation stuff is unchanged, its just the OS underneath has some packaging differences that prevent the Jessie instructions from working.

    1
    None
    willbird

    1 year ago

    Installed everything and it worked great up until step 13. Motioneye works fine but I am not able to add the pi camera. I know the camera works fine because I have run it with motioneyeos. I ran sudo raspi-config and enabled camera, that did not help.

    2 replies
    1
    None
    wb666greenewillbird

    Reply 1 year ago

    Did you do:

    sudo nano /etc/modules

    Then add:

    bcm2835-v4l2

    Then reboot. Should find the Pi camera afterwards.

    0
    None
    yourdiywillbird

    Reply 1 year ago

    Hi sorry I was busy lately, hmmm I haven't encounter this situation my
    other camera was an old model and was recognize and the other was a bit
    newer i'll inform you once I found a solution I'm planning to add new
    camera and planning to buy a newer model of a4-tech perhaps with IR if possible.

    0
    None
    ZeeshanR3

    1 year ago

    How to Power Pi?

    and Does it need Constantly Provided Supply?

    2 replies
    0
    None
    willbirdZeeshanR3

    Reply 1 year ago

    You can power it from a usb "wall wart" or using many usb type battery banks.

    0
    None
    Tinker-Bel

    1 year ago

    There is an easy way to activate ssh on your Pi, before the first boot.

    Put an empty file called 'SSH' on the sdcard, after placing the OS image on it and before the first boot.

    Voila, you can ssh into the pi! Standard login and password are pi and raspberry

    1 reply
    0
    None
    yourdiyTinker-Bel

    Reply 1 year ago

    Good one! I never knew there's another approach. Thanks :)

    0
    None
    TheRadMan

    1 year ago

    I have built two of these from RPi-2 with main cam as the 5MP RPiCam and then a 8MPNoIRCAM because I need *license plates* resolution in a short driveway, and then added USB cam to rear door. Do you have any tricks to increase distance of USB cams beyond the standard 1-3meters? I also try USB-RG45 inter-conversion but the cam distance only extends perhaps 5meters, mostly around the problem of +5Vdc supply currents ~250mA and up. It gets costly to use multiple RPi's and MotionEye setups. I concentrate the RTSP streams with one iSpy64 server and that server goes out to secure internet, also handling motion capture centrally.

    This post is very good write up, and includes detail not found on the ccrisan original sites and forums.

    3 replies
    0
    None
    MikBTheRadMan

    Reply 1 year ago

    Sounds like the RJ45/USB are passive devices: Look for ACTIVE (powered) USB extenders: these can get you further. You can even chain them together, up to the point where it stops working :)

    0
    None
    TheRadManMikB

    Reply 1 year ago

    I tried two twisted pair active extenders and the issue is reduced bandwidth.

    Bi-purposing the RPi to capture front and rear simultaneously may be limited by bandwidth constrains of USB2, and the WiFi-G network link.

    I am now in consideration of a second RPi with another 8M NoIR at the building rear. The resolution for surveillance is so much better than USB2 web cams re-purposed into surveillance.

    The goal was to capture unattended front images of delivery trucks and their identities and the RPi NoIR 8Meg cam takes up much of the RPi computational capacity and some of the 100baseTX network bandwidth.

    I also want to lobby for RTSP usage as it seems to be efficient in terms of sending stream back to a main CPU running iSpy64 .

    0
    None
    yourdiyTheRadMan

    Reply 1 year ago

    Thanks for your comment nice setup there! To be honest I haven't tried to do some tweaking on the distance, right now the setup that I made running 24 / 7 without a problem I'm satisfy on the performance I might as well search for a solution on that for future use :) Cheers!