Macro filming and photography with the camera board

Although the lens on the Raspberry Pi camera board is nominally fixed-focus, we’ve found that with a bit of hackery, you can gently unscrew it from its mount and change the focal depth. This isn’t what the package is designed to do, so if you do break yours doing this, it’s at your own risk and you won’t be able to send it back for a replacement. But if you’re careful, you’re unlikely to break anything, and you’ll get some really impressive results.

Here’s Gordon (who is too shy to speak on camera, so he’s doing the demo in stoic silence while Rob and I narrate) showing you how it works. Look out for the incredibly sharp image of the little balls of solder that fit between the processor and RAM chips.

The lens is attached to the rest of the unit by a screw thread, and glue is applied to the thread in the factory that makes the lens/sensor package to keep it in place. (We buy these as a sealed unit which we then mount on the camera board; they’re the same as the business end of camera unit you might find on a mobile phone camera.) The glue that is used is quite brittle, so you can break it out of place with care, and the lens unit will then move freely on the screw thread. We used pliers for the initial unscrewing, but we have heard from people in the community who have pressed down on the top of the lens unit with a soft pencil eraser, and twisted, which has applied enough gentle force to snap the dried glue.

When you’ve released the unit from the glue, just screw it out so that the lens is as far from the sensor as you can get it. You’ll notice that anything that isn’t very, very close to the lens will be blurry, but you’ll be able to get a very sharp picture of anything you hold it close to. And the resolution’s fantastic.

55 comments

Avatar

Excellent. If you’re not quite bold enough to make permanent mods (breaking the glue seal) you can achieve some measure of macro capability by adding +2D, +4D, +10D etc. lenses in front of the camera module to reduce the close focus distance, with pretty good results. Not quite as close as that though :)

Avatar

never head liz speak before mhm.

Avatar

To be totally honest, I’m quite camera-avoidant too!

Avatar

It wouldn’t seem so in this video…

Avatar

You should underline the bit in bold. There are many idiots out there…

Avatar

Great! So now I can build my own version of Kinograph to digitize my father’s old 8mm films!

Avatar

Or just buy macro lens that are designed for smartphones and clip it on.

Avatar

But where’s the fun in that?

Avatar

I agree. Thant’s just boring. And it sucks.

Avatar

Ha! just in time. I had issues with the focal length before where I wanted to take pictures of a sensor that the PI is attached to (oil tank swimmer level, because I am OCD and want a second opinion apart from the Reed switch array connected to the GPIOs). I “solved that problem by hanging a mirror at about 30 cm distance from the camera and taking a picture through that (which gives half way acceptable picture virtually 60 cm away). Having the macro function will greatly simplify the setup and get me much better resolution of the actual gauge.

Avatar

There’s nothing wrong with getting a second opinion.

Anyone want to back me up on that?

Avatar

O_bsessive C_offee D_ependency?
Thats a reason for a second opinion?

Avatar

That’s very cool, love macro photography. An alternative is to grab an old (broken!) CD player and use the lens off of that. I’ve done that with my phone before, more suited home brew than buying phone lenses!

Avatar

Just to note, this was actually P33M’s idea first. I’ve just been playing around seeing what fun stuff I can take photos of!

Need to tidy my desk again, it’s been three months now…

Gordon

Avatar

Oh and I was trying really hard to get some cool macro photo’s of my eye (the most complex thing I could think of that should look really cool under a macro!)

Tried with lots of different lighting but doesn’t quite work out…

Be careful though don’t wanna go dropping that lens into your eye!

Gordon

Avatar

Great, now I can’t get the image of you staring down a camera module out of my head.

It was more accidental discovery rather than idea though…

Avatar

Glad to see this highlighted on the blog. As with any macro photo setup, the more magnification you get, the more shallow the depth of field. So anything subject that isn’t flat and parallel to the sensor, will get fuzzy except for one small region in focus…. see also http://en.wikipedia.org/wiki/Depth_of_field

Avatar

We really need to consider just what is being revealed here.

Absolutely nobody else never ever tells the public or customer base how to destructively modify their product out of design spec.

And then have the maturity of confidence in us by saying ” But if you’re careful, you’re unlikely to break anything..”

Unheard of.

This is telling of the intelligence behind the both the product and the support organisation behind it not to dumb us down with “..don’t think for yourself darling, and don’t ever do it without us or certified counsel..”

Success comes not only to those who have the ability or alignment of happenstance, but also the have cheek and dare to be unfettered by conforming other’s sense of safety.

Sorry if that’s a bit wordy, but it’s why the whole raspberry pi thing will have longevity, even in the face of eventual copycats.

Avatar

Hi RobV, thanks for the kind (and perceptive) words — you’ve sussed us of course :). It comes from the fact that we all love what we do and we love what we make, and when we find out that you can do a particularly cool and useful thing with the Raspberry Pi it would be unthinkable not to share it!

From an educational point of view, hardware hacking is something to be encouraged, and breaking the glue seal on a camera with a pair of pliers is potentially the start of an amazing journey…

Avatar

I’ll echo that: thank you! We’re in the very fortunate position of being a tiny company full of people who share a philosophy about making, learning and hacking, and I love the culture that we’ve grown in our offices. Being unafraid to experiment is what Raspberry Pi is about; it’d be extraordinarily boring if we slapped unnecessary safety warnings all over things, and boring doesn’t make for good learning.

Plus, there’s a real kick you can get out of adapting something and making it yours. I wouldn’t want to deny that to someone for a moment. (In my *copious* spare time I am currently working on taking apart a vintage fountain pen and replacing its ink feed; much more fun than buying one that’s been reconditioned for me. It’s a pathology, I tell you.)

Avatar

I wanted to keep my comment from being too long, so i declined to say that in my old age I have an increasing interest in how the quality of leadership gets reflected in its organisation. Now there’s only so much i can discern from down in the antipodes, but the foundation has no leader in the normal sense. Eben is an often visible spokesman, but other founding members are equal to the role.

Now there are differing styles of leader, from ‘The Dominator’ all the way through to ‘The Servant Leader’, but in the absence of an identifiable person, I can only assume something else is in play. There is a business psychology law that goes along the lines of “..those who have the vision are the ones to lead the people”, and that’s what you are alluding to Clive, when you speak of the passion of pursuing and sharing what you do and what you make.

But what’s intriguing is there is always a ‘Storming Period’ in an organisation where disagreements between people are sifted through before the real progress is made. And that takes time. Yours ( The Foundation ) is a relatively short time since the the first idea was aired to where it is now.
( The cook must have “11 secret herbs and spices” she is not revealing. ) :)

Avatar

“…so if you do break yours doing this, it’s at your own risk and you won’t be able to send it back for a replacement…”

A good reason to buy them in pairs, then!

Avatar

I wonder if the manufacturer could be persuaded to produce batches without the blob of glue in the first place?

Is the glue absolutely necessary?

Avatar

We went over that a few times before but to rehash: they are mass-produced for the main market (mobile phones) for which no adjustment is possible, and the manufacturer does not offer such an option. At least not now. Maybe if the R-Pi foundation sold 100M of them, they would.

Avatar

I guess it is necessary to ensure that the focal length is sensible and uniform accross units intended for an unknon purpose.

I wonder if any one will make an auto focus by connecting the barrel to a servo controlled by the Pi once the glue is removed…?

Avatar

Having a version of the camera without the lens could be useful

Avatar

Can you screw the lens completely off this way?

Avatar

Yes you can…

Don’t screw it in too far though, you don’t want to damage the sensor or the gold bond wires…

Gordon

Avatar

I think Gordon actually removes it completely and holds it in his hand at the end of the video!

Avatar

It will impact the IR filter (mounted over the sensor) and stop before it does any damage. You’d have to have the fists of Ralph of the Wrecking fame to crack that thing…

Unfortunately there’s not much to be gained by screwing the lens *outward*. You can get slightly better infinite-distance images by screwing it out slightly as the lens appears to be set up for midrange images.

http://en.wikipedia.org/wiki/Hyperfocal_distance

Avatar

Im looking at using this camera for prime focus astrophotography. The whole lens needs to be removed to be able to do this (as the telescope effectively becomes the camera lens).

Avatar

It’s hard to know what “unsrew it from its mount” looks like without a zoom-in.
Maybe you could show the mod in close-up using another macro camera!

Avatar

It’s really obvious when you look at the camera – you don’t really need a zoomed shot.

Avatar

Can create a new video on Monday showing me ‘modifying’ one using one of the others!

Gordon

Avatar

Yay recursion ;-)

Avatar

Unfortunately in the process of trying to show people how to do it I damaged one of the bits of plastic lens!

Be very careful how you do this!

Gordon

Avatar

They don’t call it close-up work for nothing!
I for one would love to see micro-machines heat up 0.1mm plastic cubes before putting them in place (with their little arms!) to do a different kind of 3D print.

Avatar

Any idea why I am seeing the Kinograph film in place of the one everyone else is obviously watching?

Avatar

None at all! Try clearing your browser cache and trying again.

Avatar

Well, that got rid of the wrong video, now all I get is blank… probably has something to do with the fact that Google, ajax.googleapis, twitter, zslide, and Facebook all try to track and/or run Javascript here… (I’ve allowed you guys and Vimeo and vimeocdn to run javascript; the freeloaders can do without. Not the first site I’ve had this trouble with… But no biggie, this stuff usually turns up on YouTube eventually…

Avatar

It’s a YouTube vid – you can watch it in situ at http://www.youtube.com/watch?feature=player_embedded&v=FPv1sMk_fv4 if you’re still stuck.

Avatar

Thanks! I enjoyed the link, and other Pi goodies I found there!

Avatar

Can you put up some stills from the macro setting so we can appreciate the talked about quality

Avatar

second that – can’t get videos at work…

Avatar

No need – just tried it myself, with excellent results!

Well done guys, what a brilliant idea.

I managed to get a lovely shot of the Raspberry Pi logo on the board itself, that fills the whole screen. If only I could figure out how to post it here…

Avatar

This is a great discovery. I’m in the process of making a camera rail for macrophotography, but the RP was only intended to control the movement of a usb microscope. Using the RP camera will cut another $45 from that project cost! Thanks!

We’ll have to make a few of these to use in our soldering workshops at FamiLAB. We currently use other usb microscopes connected with a laptop to project the instructors pcb while soldering…

Avatar

Could this be used to remove the IR filter at all?

Avatar

Nope, but that is detailed in a separate blog post :-)
http://www.raspberrypi.org/archives/4088

Avatar

There is also a solution for the depth of field issue by using image stacking. see the blog post by Dave Hunt here:
http://www.raspberrypi.org/archives/3068

Avatar

a non-pi way to do this is using chdk and a cannon camera: http://chdk.wikia.com/wiki/DoF_Stacking

Avatar

Other simple obvious ideas: digiscoping (place the lens on a telescope eyepiece) and attaching the camera to a microscope.

Avatar

You could put a tiny dab of paint or correction fluid across the joint between the lens and its mount *before* you unscrew it. That way you have a chance to put it back almost as it was.

Avatar

My first “real” digital camera was a fixed-focus 2.8MP Concord. It taught me a lot about digital photography (What is this “white balance” stuff?) but its lack of macro capability drove me nuts(er). Nutsier? Anyway I came up with two solutions. The first involved a lens from a cheap pair of reading glasses (1.75 or 2.00 correction AIRC) and a piece of elastic string. Drill four small holes in the lens, use the string to hold the lens in front of the camera lens. Gives sharp images from about 17″ plus-or-minus 1″. The second was a combination of luck and Yank ingenuity; I found a magnifying glass attached to a frame designed for coin and stamp collectors at the local 99-cent store. The frame was cheap plastic and would not support the camera but the lens was good glass. I took two of the translucent covers from 50-packs of CD-Rs, cut 2″ round holes in the tops, and set the glass in the top of one. Slide the other underneath so that the two of them “telescope” and play with the focus until the picture is sharpest; mark it there, your depth-of-field is maybe 2mm. Excellent for pics of coins, jewelry.

I still have that rig, and if they ever get the camera boards back in stock, I’m looking forward to playing with it again!

Avatar

Perhaps a stupid question… but how does the camera board look as a possibility as a “book reader”, in terms of resolution, etc.? I just wasted money buying a wand scanner that would *not* work on paperbacks, period. Exclamation point, even! It wouldn’t read anywhere *near* the “gutter” of the book. And was slow, slow… and I had to use Autostitch to get an OCR’able page together, so I said “forget it!” If Ion Audio hadn’t canceled their Booksaver, I’d have books galore on my tablet…

Avatar

Can you be more specific about how you got it off? I’ve tried everything but mine won’t budge. I have the Pi NoIR varient. I’m worried about damaging it.

Leave a Comment

Comments are closed