Linux Format

Build a pinhole camera

Interchang­eable lenses enable us to experiment with that historical curiosity, the pinhole camera, Mike Bedford shows you how.

- Mike Bedford likes to engage in unusual forms of photograph­y, but he has to admit that the pinhole approach is one of the strangest, but no less interestin­g for that.

Interchang­eable lenses help us to experiment with that historical curiosity, the pinhole camera. Mike Bedford shows you how.

The pinhole camera might date back to 1856, but it would be wrong to think it predated cameras with lenses. Instead, it seems that the idea of a lens-less camera was always intended as a curiosity, not a serious suggestion for a practical camera. It has been used as such by enthusiast­s, but in the main pinhole cameras have been employed as teaching aids. Irrespecti­ve of whether you want to learn more about optics and photograph­y by experiment, or take some shots with a rather unique look, if you have a healthy curiosity we’re confident that you’ll enjoy trying our various hands-on exercises.

A pinhole camera can be nothing more complicate­d than a cardboard box, as we demonstrat­e with our first experiment. While it might seem incongruou­s to mix old and new technology in this way, we then bring the concept up to date by showing you how to use a Raspberry Pi HQ Camera as a pinhole camera. This isn’t just a desktop exercise though – we also provide some guidance on how to make that pinhole camera portable so you can use in the great outdoors.

Because pinhole photos aren’t always perfect as they come out of the camera, we’ll offer some brief thoughts on photo processing. Finally, to round off our look at this primitive form of photograph­y, we also take a look at pinhole photograph­y with a DSLR.

Illuminati­ng in a cardboard box

Right at the start we have to come clean and admit that you’re probably not going to take a photo with our first pinhole camera, even though it’s quite feasible to do so.

Instead, the real purpose of this experiment is to demonstrat­e how simple a pinhole camera can be – after all, this one is just a cardboard box – and to give you a better feel for what’s happening when we get embroiled in high-tech pinhole cameras.

First of all you need to find a cardboard box. The size isn’t critical, but we suggest going not much larger than the one in the photo, bottom left. Paint it matt black, inside and out, and when the paint has dried, glue a piece of white paper to the inside of one of the smaller faces. Now, using a sharp object like a small bradawl, make a small hole about 1-2mm in diameter through the face opposite the one with the white paper. In picking the faces to which you’ll stick the white paper and make the pinhole, make sure that one of the other two faces can be opened. Congratula­tions, you’ve made your first pinhole camera.

To see it in action, take it into a dark room and find something that emits its own light as the photograph­ic subject, say a candle or a bare lightbulb. Place your camera on a flat surface such as the floor or a table, and place that object close to the box facing the pinhole. Now turn off the lights and take a look at the white paper through the opening in the box, and you should see an upside-down image of the light-emitting object. If you don’t see the image, try adjusting the angle of the box to better frame the shot and/or try moving it closer

to or further from the object.

Now, to take a photo, having set up the camera and the object, just remove the piece of tape from the pinhole for the exposure period. Of course, you’d need to prepare your camera in total darkness, or in red light if you’re using photograph­ic paper as opposed to film. You’d need to develop it afterwards, and you’d need to experiment with exposure times. We suspect few of you will choose to try that, so let’s move on to some more practical ways of taking real pinhole photos.

A Pi-hole camera

First we’re going to see how to build an experiment­al pinhole camera using a RPi HQ Camera, and then we’ll move on to consider how to make it more practical for portable use. For the first step, until you’re sure everything’s working okay we suggest that you use a Raspberry Pi attached to the HQ Camera on a tripod facing outside through a window, and with the usual keyboard, mouse, monitor and power supply attached.

However, we’re not going to be using the camera with one of its normal lenses attached. Instead, we’ll be using a pinhole, so let’s see how to make one. Take the body cap that will have been fitted to the HQ Camera when you first took it out of its box, and drill a hole about 10mm in diameter through the middle. Now take a piece of aluminium cooking foil and make a small pinhole in it, using a sewing needle – see the box below for informatio­n on pinhole diameter.

Alternativ­ely, you might do better using thicker foil, such as that used for some takeaway or freezer-food containers. The advantage of the thicker foil is that you can sand it down with very fine sandpaper to remove any burr. Cut out the pinhole so that the piece of foil completely covers the hole in the body cap and secure it in place using tape, ensuring that no light can leak through the cap except through the pinhole. Finally, screw the body cap and its pinhole onto the HQ Camera, using the C-CS adapter that you’d use with the longer of the two official lenses. This will provide you with a focal length of about 16mm – see the box on page 50 for informatio­n on focal lengths.

Now try taking your first photo using the raspistill command line utility. The chances are that the result won’t be the sharpest photo imaginable – and that’s an understate­ment – so you’ll probably have to try a few pinholes until you get one you’re happy with. A pinhole will never compete with a lens, but the imperfect look is part of the appeal of pinhole photograph­y to its adherents, and it is quite amazing that you can get an image at all with no lens. For best performanc­e, though, you might want to abandon the idea of making your own hole in a piece of foil and invest in a profession­ally made pinhole. These are available in a range of sizes for £17

from pinholesol­utions.co.uk. Another issue you’ll invariably notice with your first photos is lots of blurred dots which are actually specks of dust on the camera’s sensor. Because of a pinhole’s extremely large depth of field, those specs are almost in focus while, with an ordinary lens, they’d be so out-of-focus as to be invisible. To reduce this, you might want to carefully brush the sensor (actually, the filter that covers the sensor) with a small, brand new, perfectly clean brush with very soft bristles.

Going portable

Having got a pinhole that you’re happy with, it’s time to turn the HQ Camera into a portable camera so you’re not limited to shooting through your window.

First of all, because you’re not going to want to have to connect a keyboard and mouse to your portable camera, you’ll need some software that starts when the Raspberry Pi boots and is controlled by one or more pushbutton­s. We used just the one pushbutton, and also a piezo electric sounder for audible feedback connected to GPIO pins. The main reason for omitting the LCD screen is that pinholes don’t allow much light through, so if you were to use an LCD panel as a viewfinder you’d probably struggle to see the image in even moderately bright daylight.

We’ve created Python code (here https://textbin. net/lfylfhigwz) for this project available from www. linuxforma­t.com/archives. We suggest that you make sure the software is working correctly while you still have a keyboard, mouse and monitor attached, before building everything into a box.

Because the code starts when you boot the Raspberry Pi – there are lots of ways to do that, but we’ll leave you to read up on it – the code starts by sounding three short bleeps to indicate that it’s booted and is waiting for you to take a photo. Pressing the pushbutton momentaril­y causes a photo to be taken, something we do by calling raspistill. As soon as you press the button the sounder bleeps to confirm that, and when the photo has been taken, it sounds again.

With the default raspistill settings there’ll be quite a gap between the two bleeps because it shows a preview for five seconds, and you might choose to reduce or eliminate that if you don’t add an LCD panel as a viewfinder. The filename of the image is assembled using the date and time and, although the date and time won’t be correct if the Raspberry Pi isn’t connected to the internet, it’ll ensure that filenames are unique.

Because it’s not advisable to turn off a Raspberry Pi by just removing the power cable, the code also allows it to be shut down. This is done by pressing the button while the second bleep you hear while taking a photo is sounding, and is confirmed by three short bleeps, indicating that it’ll be safe to remove the power after another few seconds.

We’re not going to give a blow-by-blow account of how to build your camera as a portable unit (but see the photo), although we’ll give a bit of guidance. We recommend using a smallish plastic box of the type sold by electronic component suppliers, into which you screw the Raspberry Pi and the HQ Camera.

You’ll need a large hole through which you can screw the pinhole (or a lens if you want) onto the camera. You’ll also need a hole for the camera’s tripod socket because, with pinhole exposure times being so long, you’re going to need to use the camera on a tripod. We recommend using a USB power bank as the power supply, mounting it on the outside of the plastic box, so you don’t need to open it up to charge it.

This being the case, you’ll need a hole adjacent to the Raspberry Pi’s power socket through which you can pass a USB to Micro-USB lead. The push-button could be mounted on the box, but we put it on a flying lead rather like a camera cable release, so you’ll need a hole through which you can thread that lead.

If you do use a flying lead, be sure to provide some

form of strain relief so you don’t risk pulling the lead off the Raspberry Pi’s GPIO pins. The other thing you’ll need to give some thought to is how to get the photos out of the camera without plugging in a monitor, keyboard, mouse and USB drive, which would require you either to use a very much oversized box or to make lot of extra holes in the box.

There are lots of options, but we took the simple approach of cutting a slot in the box adjacent to the microSD card so we could remove and replace it using a pair of tweezers. This then allows you to copy the files onto any Linux PC with a suitable microSD card slot. If you use this method, do make sure the slot is oversized, otherwise you might snap the microSD card – and we speak from experience.

Finally we come to the viewfinder. The simple solution we used is two ‘windows’, one behind the other, that you look through. The windows are the same aspect ratio as the sensor, and the one further from your eye is larger than the closer one. If the sizes and their separation are correct – you’ll need to draw it out on paper or with a vector graphics package to determine this – when you move your eye closer to or further from the nearest window, it’ll coincide with the more distant window when you’re seeing the same angle of view as the pinhole.

For the PRi HQ Camera 16mm pinhole, that angle is about 22 degrees. The only snag with this approach is that you get a parallax error if you’re photograph­ing close-up, which means that you’ll see a different scene to the camera.

Image processing

Photo processing, using a photo manipulati­on package such as GIMP, is highly recommende­d even if you’re using a lens on your camera. With just a pinhole, though, it can make even more of a difference because, putting it politely, pinhole photos need all the help they can get.

For a start you might find that your photos are underexpos­ed. We assume it’s some sort of issue with the camera’s metering with unusually low light levels, and while it would be better to correct that when taking the photo, you won’t always get it right. Next up, we discovered that pinhole photos benefit more from using GIMP’s Levels and Curves tools than regular shots. Also, given the somewhat inaccurate nature of the viewfinder, you might need to crop your results too. And finally, you might choose to use the Clone facility to reduce the impact of all those out-of-focus dust specs.

The DSLR option

Realistica­lly, you’ll struggle to totally prevent those blobs on your RPi pinhole photos, which result from the pinhole’s extremely large depth of field which causes specs of dust on the sensor to become visible. Depth of field doesn’t depend only on the aperture though, it also depends on the focal length – the real focal length, that is, not the 35mm equivalent.

In particular, the smaller the focal length the greater the depth of field, and our pinhole has a focal length of just 16mm (see the box on the opposite page). And it gets worse. Because the RPi HQ Camera has a small 1/2.3-inch sensor, many times smaller than that in a DSLR, any specs of dust on it will appear much larger as a percentage of the sensor size, and hence also as a percentage of the image size.

Bearing in mind that a DSLR will produce better images, even with a lens, if you have a DSLR you might like to try it for your pinhole photograph­y. The procedure is much the same as with the RPi HQ Camera although, as discussed in our look at pinhole size, you’ll need a larger pinhole for optimal results. If you can’t find your camera’s body cap – and we’re sure that many people don’t keep them because they expect there’ll always be a lens on their DSLR – you really ought to buy a new one rather than trying a makeshift solution such as taping the pinhole directly onto the camera body.

Other than this brief bit of advice on DSLR pinhole photograph­y – surely the ultimate bizarre combinatio­n of low- and high-tech – we suggest that you just aim to get lots of experience to see what works and what doesn’t as you hone your skills.

If you’re still not convinced and you want to see what’s possible, we suggest you take a look at the incredible pinhole photograph­y of Cameron Gillie, albeit using a large-format film camera, these are impressive results to see at https://thepinhole­thing. com/pinhole-photograph­y.

 ??  ?? Here we’re putting the final touches to the incredibly simple cardboard pinole camera, and real photos can be taken on a barely more sophistica­ted variant.
Here we’re putting the final touches to the incredibly simple cardboard pinole camera, and real photos can be taken on a barely more sophistica­ted variant.
 ??  ?? The first photo on our HQ Camera pinhole camera, before we made it portable, was shot out of the window. The pinhole was imperfect, the sizing was largely guesswork, and dust specs are clearly visible, but it’s quite an eye opener given the lack of a lens.
The first photo on our HQ Camera pinhole camera, before we made it portable, was shot out of the window. The pinhole was imperfect, the sizing was largely guesswork, and dust specs are clearly visible, but it’s quite an eye opener given the lack of a lens.
 ??  ??
 ??  ?? Details will differ depending on what size box you get, but our layout should give you some ideas about how to build a portable HQ Camera-based pinhole device.
Details will differ depending on what size box you get, but our layout should give you some ideas about how to build a portable HQ Camera-based pinhole device.
 ??  ?? Our camera might not look too impressive – after all, its lens is made of nothing (well, air, actually) – but its simplicity is surely part of the appeal of pinhole photograph­y.
Our camera might not look too impressive – after all, its lens is made of nothing (well, air, actually) – but its simplicity is surely part of the appeal of pinhole photograph­y.
 ??  ?? If you can’t stand all those dust blobs on your photos with the HQ Camera pinhole solution, fitting a DSLR with a pinhole will provide significan­tly better results, as this shot of an antique door knocker on a panelled door shows.
If you can’t stand all those dust blobs on your photos with the HQ Camera pinhole solution, fitting a DSLR with a pinhole will provide significan­tly better results, as this shot of an antique door knocker on a panelled door shows.
 ??  ?? This was one of our best photos taken on the RPi HQ Camera pinhole camera, using a pinhole from pinholesol­utions.co.uk. We found that scenes with bold shapes worked better than pure landscapes.
This was one of our best photos taken on the RPi HQ Camera pinhole camera, using a pinhole from pinholesol­utions.co.uk. We found that scenes with bold shapes worked better than pure landscapes.

Newspapers in English

Newspapers from Australia