from pixbuf_camera import PixbufCamera time_lapse = 60 * 60 * 4 # Take pictures over a 4 hour period freq = 120 # Take them every 2 minutes camera = PixbufCamera () for i in range(0, time_lapse/freq): pixbuf = camera.takePicture () pixbuf.save ("series/test_%04i.jpg" % i, 'jpeg') time.sleep (freq)Using this program on the XO I captured this outside my window today (and scp'd it to my computer): I'd like to add video support and expose a bunch of gstreamer properties so you could create a time-lapse Ogg Theora video instead of JPGs. Perhaps eventually this camera API could be used by the Record activity itself. I really need to buy some mirror fragments and build a clip-on device for XOs so you can photograph things in front of it (meaning you can film something and use the computer simultaneously).
Tuesday, November 13, 2007
One Laptop Per Photographer
Jon Trowbridge gave me a B4 OLPC XO the other day, and I'm absolutely loving it. It is so much faster than my old B2, and with the latest softare it is rocking. Harper and I were chatting and collaboratively editing a document from across Chicago with zero setup. There is a relatively new activity called Pippy that includes many Python scripts that are simple (hello world, etc), fun (random pitch/sound generator), and educational. Coupled with a Run button it is a simple interactive console. It doesn't have anything for using the XO's built in camera, so I dove in to figure out what I could do. I looked at the Record activity but found its gstreamer/picture taking code very tied to how it did stuff, dependent on Gtk, etc. So using it as an example I wrote a simple Camera class that returns the raw RGB buffer, and a PixbufCamera subclass that has the exact same interface but returns a Gdk.Pixbuf. With these two classes we can write awesome, Pippy-ish scripts, like a time-lapse photography program: