Quelle:
http://downloads.sourceforge.net/project/motiongui/motion-gui%28source%29/motion-Gui-1.1.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmotiongui%2F&ts=1356038786&use_mirror=ignum
Now it’s worth changing the root password and setting up a new user (which I’ll name “pi”):
passwd root
adduser
# Add a user named pi - accept default options
Linux distributions have different command-line tools for installing approved component packages – much as some of you may be used to with NuGet in recent versions of Visual Studio. Raspbian has apt-get, Arch Linux ARM has pacman. To make sure pacman is installed and (along with the OS itself) up-to-date, run these operations:
pacman -Syu
pacman-key --init
pacman -Syu
pacman -S sudo
visudo
# Scroll down to "root ALL=(ALL) ALL", i to insert:
pi ALL=(ALL) ALL
Esc ZZ # (to quite & save)
ssh pi@192.168.1.110
sudo pacman -S bash-completion
sudo pacman -S motion
We’re going to ask Motion to save it's running process ID in a file in the /var/run/motion folder. First, though, we need to create that folder:
sudo mkdir -p /var/run/motion
Next we’re going to install Python and the GData component we need to access GMail and Google Drive.
sudo pacman -S python2 python2-pip
sudo pip2 install gdata
mkdir /home/pi/motion
Now we can download and install the Uploader.py file, which I’ve adapted from the one in this post (with the help of the information in this page). You might download the file and FTP it across, or you could use the following approach to download it directly using the Pi (and then make it executable):
cd /etc/motion
sudo wget "http://through-the-interface.typepad.com/files/uploader.py"
sudo chmod +x uploader.py
[gmail]
# GMail account credentials
name = Kean Walmsley
user = keanrw@gmail.com
password = this_is_not_really_my_password
sender = keanrw@gmail.com
# Recipient email address (could be same as from_addr)
recipient = kean.walmsley@autodesk.com
# Subject line for email
subject = You have a visitor
# First line of email message
message = See attachment. Video of visitor uploaded to:
[docs]
# Folder (or collection) in Docs where you want the videos to go
folder = motion
[options]
# Delete the local video file after the upload
delete-after-upload = true
# Send an email after the upload
send-email = true
cd ~
wget "http://through-the-interface.typepad.com/files/VidTest.avi"
wget "http://through-the-interface.typepad.com/files/VidTest.jpg"
/etc/motion/uploader.py /etc/motion/uploader.cfg ./VidTest.avi
Once you’ve executed the uploader script, you should receive an email with a link to the video on Google Drive (assuming it’s enabled for your Gmail account) and the image as an attachment:
Now the various pieces are in place, it should be a simple matter of getting and adjusting the Motion configuration file. To get the one that I have working with my webcam, you can:
cd /etc/motion
sudo wget "http://through-the-interface.typepad.com/files/motion.conf"
To run Motion simply type “sudo motion” at the command-line. The configuration I’ve provided will run it in daemon (i.e. as a background service) mode, but if you hit problems you may want to run it in interactive mode, or even with the –s flag. A couple of handy features provide the ability to change configuration options at runtime via a URL (in my case this is http://192.168.1.110:7071) and to view the live webcam output via another (http://192.168.1.110:7070).
If all is working well, you should start to get emails with detected motion events:
Once you’re ready to have it enter daemon mode on boot, you can edit the /etc/rc.conf file (using sudo nano …) to add it to the list of startup daemons on the very last line of the file.
One thing to note about this particular configuration: as mentioned, we save a single .jpg to accompany the .avi file that gets recorded (both files will appear in the same /home/pi/motion folder with the same name). The uploader script gets called when the .avi gets saved but assumes the .jpg will be there.
These files get created once motion has fully stopped (and there’s a configurable 60 delay to make sure that’s the case) which means that at some point we’ll want to change the configuration to have Motion take more regular snapshots – and use a different naming convention, as we’ll have more .jpg files per .avi – as that will allow us to run them through the facial recognition system and present the results without waiting for 60 seconds after the person has left. A change will also be needed for the uploader module, of course. But all that’s for another day and another series of posts. :-)
Update:
Alex Fielder reminded me that the uploader will look for a folder called "motion" in your Google Drive - be sure to make that folder before you try uploading. Thanks, Alex! :-)