Saturday, January 16, 2010

Tonight's Photobomb Feature: WebCam Support

Last week Seb128 uploaded pygame 1.9.1 to Lucid universe. This was great for me, because pygame 1.9 has fun and easy webcam support.

So today, while lying around recovering from a bit of jet lag, I created a widget that wraps up the pygame webcam support with pygtk. So the contents of the Web Cam tab in the screen shot above is actually from Quidgets, quidgets.widgets.CameraButton. (probably not the best name, but it when I started it, it was just a button that you clicked on, without other controls.

There are a few steps to using CameraButton:

1. Create it and connect to the "picture_taken" event:
     cb = CameraButton()
cb.connect("picture_taken",self.add_image_from_pixbuf)
2. Start it capturing:
 cb.set_capture(True)
3. Respond to picture_taken events and use the supplied pixbuf. So really, it's about 3 lines of code to get web cam support set up with quidgets.

After you have the pixbuf from the camera, you are on your own to do with it what you will. For me, it was easy, as already had code for handling pixbufs read from the disk, so I just needed to do a bit of refactoring and it worked without new code.

It's fresh, barely tested, code. You can get it from the trunk if you want to play with it.

About Quidgets
Quickly + Widgets = Quidgets
There is a Launchpad Project for Quidgets
The most up to date changes are in the Quidgets Trunk Branch

2 comments:

  1. Bloody awesome, so it replaces f-spot and cheese now :) Photobomb for lucid+1 :D

    ReplyDelete
  2. It's looking really good,

    Do you need any icons or branding for the project? something "photoish" and "bombish"

    ReplyDelete