Category Archives: Videos

Raspberry Pi Webcam Viewer

I finally got a chance to play with my RaspberryPi, so I threw together a quick experiment.

 

 

Update: A few people have asked me for a little more information. I’m happy to make the source code available, but it’s not very tidy and a bit specific to my situation… however, to answer some of the questions:

The enclosure for the Raspberry Pi comes from SK Pang Electronics, and it’s perfect for my needs. You can buy just the perspex cover, but they do a nice Starter Kit which includes the breadboard, some LEDs, resistors and the pushswitch. Definitely recommended.

For the graphics, I used the PyGame library, which has the advantage of being cross-platform: you can use it with a variety of different graphics systems on a variety of different devices. On most Linux boxes, you’d normally run it under X Windows, but I discovered that it has various drivers that can use the console framebuffer device directly. This makes for a quicker startup and lighter-weight system, though I imagine it probably has less access to hardware acceleration, so it’s probably not the way to go if your graphics need high performance. You can read about how to get a PyGame display ‘surface’ (something you can draw on) from the framebuffer, in a handy post here.

To load an image from a file in PyGame is easy: you do something like this:

            im_surf = pygame.image.load(f, "cam.jpg")

where ‘f’ is an open file, and the ‘cam.jpg’ is just an invented filename to give the library a hint about the type of file it’s loading.

Now, with a webcam, we need to get the image from a URL, not from a file. It’s easy to read the contents of a URL in Python. You just need something like:

            import urllib
            img = urllib.urlopen(img_url).read()

but that will give you the bytes of the image as a string. If we want to convert it into a PyGame surface, we need to make it look more like a file. Fortunately, Python has a module called StringIO which does just that: allows you to treat strings as if they were files. So to load a JPEG from img_url and turn it into a PyGame surface which you can blit onto the screen, you can do something like:

          f = StringIO.StringIO(urllib.urlopen(img_url).read())
          im_surf = pygame.image.load(f, "cam.jpg")

I’ll leave the remaining bits as an exercise for the reader!

If you like this, you might also like my CloudSwitch

Spinning Beachball

A TED speaker’s worst nightmare. Mac users will enjoy this…

Here it is on the TED site (also works for non-Flash users).

Lady WoofWoof – Bark This Way

I made a silly movie. Starring my dog. Yes, another one. My excuse is that it’s mostly for the benefit of distant friends and family.

Then, to compound my folly, I made a movie about how I’d made the movie, which is probably more interesting for most people!

Update: Thanks to Richard Morrison for pointing me at these instructions for making your own camera stabiliser – very nice!

Cashing in on Open Source

I’ve recently switched to using GnuCash to manage my accounts, and have been quite impressed with it. A friend recently asked about software for simple bookkeeping, and I wondered whether GnuCash might be appropriate, but I didn’t find an introduction that took someone unfamiliar with accounting software through the absolute basics. So here’s my attempt to do so. It’s 26 minutes long.

Direct link.

Not your average Scottish cycling holiday…

I’d love to see the out-takes…

Alright, Mr. DeMille, I’m ready for my close-up.

OpenCV is a wonderfully full-featured computer vision library. I’ve just written a very simple demo of the built-in face recogniser. It finds a face and scales it to a fixed size. If you watch my eyes in the viewfinder window, you’ll see they stay pretty much in the same place however I move around the room.

All sorts of things could be done to improve the frame-rate if needed, but this was just a quick test I put together over a couple of hours while learning about the library. Back in ancient history, when I did my PhD, this kind of thing would have taken weeks… The title of this post, if you’re not familiar with it, is from the famous closing scene of Sunset Boulevard, which you can see here. Of course, as soon as I thought of using this title, I realised that I could also grant Gloria Swanson’s greatest wish. So here’s my version…

It needs some smoothing, but still quite fun.

The birth of a shed

In November 2009, we had a new studio built in our back garden. I had a webcam pointing at it.

Last Bank Holiday, I finally got around to doing something with the nearly two million images it had captured.

Except for those directly involved, I doubt many will want to spend 16 minutes watching this! But it might be fun to skim through!

Many thanks to the good folks at Croft Design and Build. We’re very pleased with the results.

Bubble, bubble, toil and… jolly good fun!

As if it weren’t cold enough already at the moment, some friends and family gathered last week at my brother’s place to make ice cream. Not being advocates of the Slow Food movement, though, we did it with liquid nitrogen…

I’m on a horse

The real interest of the Superbowl is not, for me, the sport, but the creativity that goes into the phenomenally expensive commercial breaks. The most famous example is Apple’s 1984 ad that introduced the Macintosh, but there have been many others.

This year’s most talked-about ad was from Old Spice, and I think it’s brilliant.

These days one immediately assumes that it’s all green-screen and CGI, but in fact there is almost no ‘trickery’. Isaiah Mustafa maintains this running commentary while bits of scenery move around him, and it’s a trolley, on which he sits part-way through, that transports him and deposits him on the horse. And he maintains this focus even though they eventually used something like the 57th take…

Leo Laporte interviewed the guys behind it, if you’d like to find out more….

Up periscope

As a small puppy, our English Cocker Spaniel, Tilly, used to like running through long grass, and occasionally through crops.

But the grasses grew faster than she did, which left her with a navigation problem…

Literal Videos

Many thanks to Andy Stanford-Clark for getting me searching YouTube for ‘literal music videos’. Some of them are brilliant, and your appreciation for each one probably depends on your generation… Here’s the best I’ve seen so far. Bonnie Tyler tells it like it is. Update 2012: you can now find it here . Here’s Penny Lane, for even older readers…

Telling it like it is…

I loved the Homeopathic A&E sketch from Mitchell & Webb. Dara O’Briain makes some similar points rather nicely here:

© Copyright Quentin Stafford-Fraser