Status: motion detection funktioniert bild wird noch nicht angezeigt
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
We’ll stay logged in as root, for now, as we still have some work to
do to get things ready to have effective use of the device as a standard
user.
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
Now you can use pacman to install the various packages we want to use. We’ll start with sudo (which stands for “
super-
user
do” rather than being a mis-spelling of “pseudo” :-), which will allow our pi user to perform operations as root.
It’s one thing to have sudo installed, it’s another to be able to use
it. You can edit the sudo privileges directly using this command, which
unfortunately uses the vi editor to open the file (I’ve mostly switched
over to the much more intuitive nano editor, at this stage):
visudo
# Scroll down to "root ALL=(ALL) ALL", i to insert:
pi ALL=(ALL) ALL
Esc ZZ # (to quite & save)
At this stage it’s worth logging out (you can type exit or logout to
do so) and logging back in via a new ssh session as the “pi” user:
One last step is helpful but not strictly necessary, in that it
enables command-completion via the Tab key when executing commands using
sudo:
sudo pacman -S bash-completion
Now we basically have our OS up and ready. If we were on “wheezy”
we’d now be thinking about installing (or building) a webcam driver.
That happens to be built into Arch Linux ARM, so we can skip on ahead to
installing Motion:
At this stage we have most of the packaged components in place that
we need to run our motion-detecting security cam. Now we’ll start
configuring 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
[As mentioned last time, it’s helpful – but not necessary –
to set up a killmotion script that uses this ID to kill the motion process
(which is really only for when you’re running in daemon mode). That
said, it’s also simple enough to run the “pstree –p” command to see the
running process tree with the IDs at each node, and then just use “kill
1234” (assuming the process ID is 1234).]
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
We’re going to ask Motion to save one frame per event – that we can
use as an email attachment in our email, to help recipients – especially
those on a mobile device – decide whether it’s worth watching the
uploaded video. Both the capture frame and the video will be stored to
/home/pi/motion, which we need to create:
We might also have kept the default location – which I believe is
under /var/tmp – but that’s a folder that gets cleared between sessions
(when the device is rebooted). When my device was regularly being reset –
back when I was using “wheezy” – I moved across to this folder, so I
could see when images/videos were captured successfully. So far I
haven’t seen the need to switch back.
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
You’ll also need an uploader.cfg file in the same location. The
simplest approach is to run “sudo nano uploader.cfg” and paste the
contents in (after having modified them with your login information, of
course):
[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
You should now be able to test the script, to see that it works:
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
[I had previously thought to post instructions to use fswebcam to
capture a still and ffmpeg to capture a video, but the former involved
installing an additional component and the latter didn’t actually work
when called directly on my Pi (even though Motion uses it successfully
to encode video, as far as I can tell)].
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"
Motion has a lot of settings that you may want to adjust – it’s a
really flexible, powerful component – but I won’t go into the details on
that, here.
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! :-)