Category Archives: Camera

RasPi Time-lapse Camera

Raspberry Pi Camera Board

Raspberry Pi Camera Board

I have had a Raspberry Pi camera board since they were first available in May 2013.

One of the big advantages of the Pi camera is that it can be program controlled.  That means you can write a program, in my case in Python, that can control when you take one or many photos.

I had seen a post on time-lapse photography and thought “I can build one of those“.  So I did.

 

I think it looks fantastic when it is finished. If you can’t wait, fast forward to 42″, and watch a rain shower followed by brilliant blue sunshine. Don’t forget to watch in 1080p if you can.

It took about 75 lines of python code and now I have a time-lapse camera program. Thanks for the inspiration and example code link here.

Well, I have the program which takes the pictures. The images then need to be stitched together. And finally converted to something like an MP4 file.

Why 75 lines? Sounds like a lot?  I wanted the program to be variable, so using inputs I can decide how many shots to take, and how far apart the shots are taken. This allows me to do a trial shot. Look at the results, check that the camera is pointing in the right direction, then go for the full run, for example 2,400 shots at a 6 seconds delay. Most of the code actually sorts out file names and directories. Just to be difficult I decided to use numbers for my file names, not just a time date stamp, so a lot of the code enables that.  It is possible to write a much shorter program, or even just use the time-lapse feature in raspistill.

To make an 1080P HD movie you need to take 1920(w) * 1080(h) pictures, and stitch them together at 25 frames per second (in the UK).  So for 1 minute of video you need to take 25 * 60 = 1,500 pictures. At 6 seconds delay between shots this is going to take 2½ hours.

(You will need to set some times  aside to do this, make sure that the camera isn’t going to be moved, or become obstructed.  Tip: Start with shorter runs.)

Time-Lapse Camera

Time-Lapse Camera

My set-up is simple, a Pi, WiFi dongle, and an Duracell emergency mobile Phone charger battery. I run the Pi headless, which means without a monitor and keyboard. I connect through either my laptop or a tablet.  And if I am out and about then I can use open a hotspot on my phone.

I even bought a case for my Pi that looks like a camera. Not bad for about £10.

(Update: I have since added a magnetic lens, glued a washer to the front as a mount, and upgraded to a 12,000 mA-h PowerBank battery for even longer life. I am currently working on a tripod mount.)

Smart Pi Camera

Smart Pi Camera

I have recently bought a second camera case, a SmartPi, which has a GoPro tripod mount. This is designed for a B+ / B2. I have used a RasPi B+, which uses less power than the original B, and my PowerBank lasts even longer 🙂

(The SmartPi case has Lego mountings, which opens up a whole nother world of possibilities!)

Just a note: You can do all of the video encoding and conversion on the Pi, but I use my desktop PC. It is a lot quicker. For example 50 minutes+ on the pi = 5 minutes on the desktop! And all of the software is open source i.e. ‘free‘.  The only additional expense need be the RasPi Camera Board.

This is great, but I can do all this with my tablet and I don’t need to fiddle about with any of this Raspberry Pi stuff.”  Well, yes, you can.  But you are much less likely to stick your tablet in a Tupperware box, and leave it in the middle of a field for 24 hours, than you are with a Raspberry Pi. And where is the fun in using a tablet?  With the Pi you have the satisfaction of knowing that you ‘made it‘.

One more that I made earlier:

PS. Avoid the sun being in the shot for long periods as here. This shot burnt off the IR filter and left a blue line across every subsequent image.  The contrails look great though 🙂

RasPi ‘Selfie’ Tweet Cam

I recently ran a workshop, with my good friend Phill Isles, at the Test Management Summit. The subject was Testing the Internet of Things: The Dark and the Light.  One of the things that we wanted to do was demonstrate a live Internet of Things device, that the delegates could actually interact with, see how it works, and begin to understand what IoT means.

Tweet Cam

Tweet Cam

So I thought I would build a Raspberry Pi Tweet Cam, that the delegates could use to take selfie’s.

It would need a Pi Camera, obviously. Then a button to press to take the photo. An LED to show the user what was happening. And finally another button so that we could turn it off.

The aim was to run headless, i.e. no monitor, keyboard or mouse.

Finally it would be equipped with a Wi-Fi dongle, to enable it to connect to the internet and Tweet.

A fun Raspberry Pi project. I mostly used the instructions for Tweeting from Alex Eames RasPi.TV site (which I find extremely helpful). Details can be found here RasPi.TV Taking and Tweeting a Photo. Then added my own design and functionality.

I needed some parts:

  • Model B+ (Tick)
  • Pibow Coupé Case (Tick)
    The pi looks great in the coupé case.
  • Breadboard Base for Pibow
    Which replaces the bottom layer of the Pibow Coupé case and gives a larger platform onto which a half-size breadboard can be affixed.
  • Some buttons.
    I got ones with round and square tops.
  • An RGB LED.
    Why install three LEDs when you can fit one that does all three colours. You still need 3 input connections though – one per colour.
    (You can then mix the inputs to create additional colours – Tough to do in an individual bulb!)
  • Resistors (Tick)
    I didn’t quit have the right resistors. I managed to use two in parallel.  And ordered a jumbo multi-pack of 2,000.
TweetCam Top

TweetCam from above

The Build. Once all of the parts had arrived, I thought on the matter for a few days.  When I had a rough idea of what I was going to do I started the build.  I used a rapid prototyping approach.

First I assembled the Pi in the coupé case extended with the breadboard base. Connected the camera using a simple flexible mount which plugs in the audio socket. (The mount works, but is a little loose in the socket – holds the camera just fine though.)

I then added a resistor, button and some wiring to the breadboard, and some jumpers to connect the breadboard to the Pi. Wrote some code to detect the button press. Then added code to taka picture when the button was pressed.

Next step was to add the RGB LED. There were no instructions for the RGB LED on the vendors site. I e-mailed them, and they responded with a two page .pdf, which had the orientation, and forward voltage. Not all RGB LEDs are the same. A simple internet search shows that.

After following some on-line guidance I connected the RGB LED, adding a resistor to the Red bulb. Then wrote a simple LED test program. When that was working I updated the TweetCam code to turn the LED Green when Ready, Red when not – I had decided that the TweetCam would only take a photo every 2 minutes, so as not to spam the world. And the LED would flash Blue when it was taking a photo. Wrote the code and tested it.

TweetCam Instructions

TweetCam Instructions

Then I added a second button, which was used to shut-down the Pi, as it would be running headless and this is always a good thing to do when turning off a Pi.  And I made the LED flash Red whilst the Pi was shutting down.

Finally with the program doing everything but Tweet I added in the Tweet code. I followed the excellent instructions from Alex Eames.  And yes, it worked. I pressed the button, the Pi took a photo, flashed the LED, and tweeted the picture.

This is ‘Testing in Production’. It is difficult to test a tweeting program without getting comments! So I only tweeted a few photos. I actually created a version of the program with the Tweeting line of code commented out, so that I could test changes, without bombarding Twitter.

The build took 6 hours from start to finish. I was quite impressed with the speed at which a functional and usable IoT (Internet of Things) device could be built and tested.

And if you are wondering what the pictures looked like the ‘live‘ output can be seen here TweetCam Pictures

PostScript.
We used the device in sessions on two days. On the first day the internet was not working at the conference venue. It was a all a bit of a damp squib. We were though able to demonstrate the inner workings of the Tweet Cam to the delegates but were unable to Tweet. Day two was perfect. Press the Blue button and tweet a picture of yourself.