Stream Motion Detect

De Slacam_Wiki
Ir para: navegação, pesquisa

Tutorial For Motion Detecting Raspberry Pi Security Camera That Notifies You Through An Email Alert With A Snapshot Attached.


Necessary materials for the security camera itself: A Gmail account, Raspberry Pi, Raspberry Pi Camera Board, 8gb or more SD card, 5 volt 2 amp minimum power supply, and a USB wifi module.

Make sure you have an SD card with plenty of space on it and Raspbian Wheezy OS installed.

Set up your Raspberry Pi.

If you're running a fresh install of Wheezy, you may be prompted to type a username and password before a desktop GUI is loaded, the username is pi and the password is raspberry, then type startx to launch the desktop GUI.

Connect your Raspberry Pi to wifi.

Connect your Raspberry Pi Camera to the Raspberry Pi itself.

Open LXTerminal.

Type "sudo raspi-config".

Select to enable Raspberry Pi Camera and select to not have to log in upon boot. Then you may exit raspi-config.

Type "sudo apt-get update".
Type "sudo apt-get upgrade".
Type "sudo apt-get install mpack".
Type "sudo apt-get install ssmtp".

To set the date and time type "sudo date 0413144913", set the numbers to your date and time, these numbers are an example.

For your reference, these numbers output "Sat Apr 13 14:49:00 UTC 2013".

Type "sudo nano /etc/ssmtp/ssmtp.conf".

Use the arrow keys to navigate through the configuration file.

Edit these lines:

root=YourUsernam@gmail.com mailhub=smtp.gmail.com:465 rewriteDomain=gmail.com FromLineOverride=YES

Add these lines at the bottom of the config file:

AuthUser=YourUsername AuthPass=YourPassword UseTLS=YES

Press CTRL+X, then y, and then enter to save the changes to your configuration file.

Type "sudo apt-get install motion".
Type "sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev".

Type "wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz".

Type "tar zxvf motion-mmal.tar.gz".

Type "sudo nano /home/pi/motion-mmalcam.conf".

Edit “width” to: 640 Edit “height” to: 480 Edit “mmalcam_use_still” to: mmalcam_use_still on Edit “threshold 1500” to: threshold 3000 Edit “output_pictures” to: output_pictures on Edit “quality 75” to: quality 100 Edit “ffmpeg_output_movies” to: ffmpeg_output_movies off Edit “target_dir” to: target_dir /home/pi Edit “stream_port” to: stream_port 0 Edit “webcontrol_port” to: webcontrol_port 0 Edit “on_picture_save value” to : on_picture_save mpack -s Alert %f YourUsername@gmail.com

Press CTRL+X, then y, and then enter to save the changes to your configuration file. Open File Manager. Navigate to "/home/pi". Right click, then click Create New, and click Blank File. Name the blank file, “sar.sh”. Make another blank file named “rm.sh”. Go back to LXTerminal. Type "sudo nano sar.sh". Type exactly what’s below:

#!/bin/sh . /motion -n -c motion-mmalcam.conf

Press CTRL+X, then y, and then enter to save the changes to your configuration file. Type "sudo nano rm.sh". Type exactly what’s below:

#!/bin/bash cd /home/pi while true; do rm -f *.jpg sleep 60 done

Press CTRL+X, then y, and then enter to save the changes to your configuration file. Type "sudo chmod +x /home/pi/sar.sh". Type "sudo chmod +x /home/pi/rm.sh". Type "sudo nano /etc/xdg/lxsession/LXDE/autostart". Under @xscreensaver -no-splash, type what’s below:

@/home/pi/sar.sh @/home/pi/rm.sh

Press CTRL+X, then y, and then enter to save the changes to your configuration file. Type "sudo reboot".

Your security camera should now be running correctly and sending you email alerts once motion is detected. If you have any issues, feel free to contact us.