|Tonight, I’ll go for a very simple hack: connect a webcam, detect motions and stream a live feed over HTTP. Not sure how it’ll fit with Project “Jarvis”, but who knows …|
First things first: the hardware. For some reasons, the only webcam that I had was an old Apple iSight. You know, the old firewire one… Since there is no IEEE 1394A port on the Raspberry Pi, I had to buy a new one.
I settled for a Hewlett-Packard HD-2300 USB webcam. I took a chance, since it was not on hardware compatibility list, but it was available, reasonably priced for its category, and didn’t look like too bad (I know, it is silly, but it is actually one of my buying criteria):
Nevertheless, it appeared right away:
root@applepie /etc/motion # lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 050d:1102 Belkin Components F7D1102 N150/Surf Micro Wireless Adapter v1000 [Realtek RTL8188CUS] Bus 001 Device 005: ID 050d:0234 Belkin Components F5U234 USB 2.0 4-Port Hub Bus 001 Device 006: ID 04b8:0007 Seiko Epson Corp. Printer Bus 001 Device 007: ID 03f0:e207 Hewlett-Packardroot@applepie /etc/motion #
A subsequent “lsusb -v” command gave my nice details about the webcam. Cool 😎
Setting up “Motion”
Now, the software part. Motion is a nice piece of Open Source software that (among other thing):
- Does motion detection (and optionnaly record video and/or frames whenever a motion is detected)
- Takes timed snapshots regardless of motion detection.
- Lives video IP stream in MJPEG format.
The installation was pretty easy:
apt-get install motion
I only changed a a few settings. Namely:
- I turned “start_motion_daemon” to “yes” in /etc/default/motion to enable the daemon
- I switched “location” to “on” in /etc/motion/motion.conf to turn motion detection on
- I switched “webcam_localhost” to “off” in /etc/motion/motion.conf to enable access to live streams from anywhere on the LAN
- I tweaked the “text_left” setting to let the message “ApplePie” appear on the bottom left of the streams
I left all the other setting as they were (including frame rates and resolution, as it was only a matter of test), and fired up the daemon:
I set the Firefox’s URL to http://applepie:8081 (as 8081 is the default port used by motion), pointed the webcam at my “Forbidden Planet” poster and shook the cam a bit to simulate a motion:
Not bad It thought that Robby the robot moved. Now, that’s kinda cool 😎
I guess, that’s it for tonight (and was quite easy, as it was widely documented on many other web sites).
Note: for some reason, I have not received yet a password for my requested account on elinux.org wiki, even though I got the e-mail address confirmation message and activated the account. I guess I’ll update the Raspberry Pi compatibility list later.