MAKE blogged about plants that notify the owner via text message or Twitter status update that they need water, and even thank their owners when they’re watered.
This got me thinking – why not a cat who sends a tweet when he’s eating? While I’m at it, why not toss in a video stream? After all, everyone loves videos of their cat. My ASUS eeePC runs eeexubuntu and has a webcam – all I would need to do to get my cat twittering is setup some motion sensing software that detects movement from the webcam, records a video, and upload to my server and then notifies me.
First, a proper “cat studio” is required. I picked up a laundry basket, some thin anti-slip mat and a couple of new food bowls for under $15 total. The laundry basked got a side removed by my trusty Dremel tool, and the anti-slip mat was cut to fit and hot-glued in place. After that was done, I had a spare light fixture with a clamp lying around to add to the mix for better lighting.
Motion is a great webcam application that fits my needs exactly. More specifically, when it detects motion, it records a video – think like a security camera, but way, way smarter. When Motion no longer senses any movement after a defined period of time, it encodes the captured video, and then it can run a script or set of commands afterwards. Bingo!
Here’s how I did it, after hours of trial and error:
1. Installed Motion 3.2.9
2. Configured and tweaked /etc/motion/motion.conf (probably still some changes needed)
3. Setup SSH to allow logins to my web server without a password.
4. Added the following to execute when a recording is finished:
Upload the file (using cat, of course!):
cat /tmp/motion/video.swf | ssh [email protected] cat ">" /home/fsckin/fsckin.com/bubba/video.swf
Update Twitter Status:
curl --basic --user "junglecrawler:password" --data-ascii "status=Done eating, humans were nice to me today." "http://twitter.com/statuses/update.json"
Remove the video off the local machine:
Here’s the end result:
Latest Video (15MBish)
This videos loop over and over. Also – if a video is uploading at the same time that someone is loading the page, it might break. If you don’t see video, just count to 10 and refresh the page. If you still get nothing, bookmark this on del.icio.us and come back later.
Note: Audio is not yet supported by Motion, however, an experimental patch enables this already and should be be in the next version. This is a proof of concept, and it will probably be running for at least the next week – after that, who knows. All I know is after I’m long forgotten, Bubba will live in perpetuity as truly the first cat who uploaded videos of himself eating and sending tweets to his human slaves.
Follow Bubba on Twitter. Or, follow his slave, Wayne.