User avatar
alexeames
Forum Moderator
Forum Moderator
Posts: 2869
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
Contact: Website

Re: Camera focus distance and macro lenses

Fri Jun 07, 2013 8:41 pm

+3 gets you about 15cm away (from memory). I think you need a clip-on macro lens like Mike posted about earlier in the thread.
Alex Eames RasPi.TV, RasP.iO

HowardP
Posts: 8
Joined: Fri Jun 07, 2013 6:45 pm

Re: Camera focus distance and macro lenses

Fri Jun 07, 2013 8:41 pm

jbeale wrote:Despite their name "All Electronics" [ ... ]
Great find, jbeale ! Thanks ... another cool gadget / gizmo store bookmarked ... Those lens look pretty similar to the lens in the cheapo magnifying glasses I mentioned.

One more question, please:

Since you jumped right to " +3 diopter " based on my simple specs, I assume there is a clear calculation, something along the lines of: " given a focal length of X, subject at focus plane distance Y, lens of +Z is required. " I'm not asking that you give the explanation, per se, rather a link to an overview of how to learn this... I tried wiki and google, but probably searched for the wrong things.

thanks again !
- H
[Edit:] thanks too for the reply, alexeames, our posts crossed in the mail. Excellent - I was wondering about that.

User avatar
rkinch
Posts: 72
Joined: Sun Jun 02, 2013 7:19 am
Location: Palm Beach County, Florida USA
Contact: Website

Re: Camera focus distance and macro lenses

Fri Jun 07, 2013 9:38 pm

If you tape or otherwise attach this fine bit of well-corrected optics to the front of the camera module lens, it will make an excellent close-up lens:

http://www.surplusshed.com/pages/item/pl1047.html

This specimen is an f=25mm lens, which is to say, it will present objects 25mm from the lens as if at infinity, which is to say, where the camera lens is focused.

The Raspberry Pi camera is basically an emmetropic but complete presbyope who needs reading glasses or a magnifier to see anything close clearly. Good vision, but stuck at infinity.

Regarding coupling the camera to eyepieces of microscopes, telecopes, etc., you essentially need merely to hold the camera such that the entrance pupil of the camera is at the location of the exit pupil of the eyepiece. On a typical microscope this exit pupil is about 18mm above the vertex of the eyepiece. Holding the camera closer or further away will cause vignetting, just like with your eye. The exit pupil is the waist of the cone you see as a small disc of light when holding a white card up not quite up to the eyepiece. Focus the microscope eyepiece view at infinity, as is the proper technique.

http://en.wikipedia.org/wiki/Exit_pupil
http://www.truetex.com/micad.htm

User avatar
jbeale
Posts: 3630
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Camera focus distance and macro lenses

Fri Jun 07, 2013 9:49 pm

HowardP wrote:Since you jumped right to " +3 diopter " based on my simple specs, I assume there is a clear calculation, something along the lines of: " given a focal length of X, subject at focus plane distance Y, lens of +Z is required. " I'm not asking that you give the explanation, per se, rather a link to an overview of how to learn this... I tried wiki and google, but probably searched for the wrong things.
I did not mean that it was exactly what you needed, but only that they sell cheap optics, including at the moment, a magnifying lens. "Diopter" is just inverse of focal length in meters. So a +3 lens has a focal length of 0.33 meters (33 cm). http://en.wikipedia.org/wiki/Dioptre

If you want your infinity-focus camera to focus at 4 cm, then you need to add a f=4 cm lens to it, which is more like a medium-power loupe, or a low-power microscope. Or a +25 Diopter lens, which I have never seen advertised as such. With a strong lens your depth of field is reduced. You mentioned "4 cm +/- 1 cm" but I don't know if you will have that much depth of field, without moving the lens.

HowardP
Posts: 8
Joined: Fri Jun 07, 2013 6:45 pm

Re: Camera focus distance and macro lenses

Sun Jun 09, 2013 1:39 am

rkinch wrote: [ ... ] an excellent close-up lens: http://www.surplusshed.com/pages/item/pl1047.html
jbeale wrote: [ ... ] a +3 lens has a focal length of 0.33 meters (33 cm). [Diopter:] http://en.wikipedia.org/wiki/Dioptre
Thanks ! Your links and explanations are the starting point I needed. Cool, this stuff's not rocket science after all !
The "infinity-focus " " Raspberry Pi camera: good vision, but stuck at infinity." OK, I assume the lens the camera has merely focuses the parallel (from-infinity) rays onto the surface of the sensor. If so, for my near-field application, would removing and replacing the stock lens with my own be more practical, as the object will always be at a fixed distance ? ( Removal / replacement is no hurdle. )
rkinch: Focus the microscope eyepiece view at infinity, as is the proper technique.
Is focusing at infinity effectively taking the microscope (a source device) out of the optical path - it appears to the camera (or next optical gadget) as if the source weren't there ? ( Ignoring optical loss, of course. )
jbeale: strong lens ... depth of field is reduced. You mentioned "4 cm +/- 1 cm" but I don't know if you will have that much depth of field, without moving the lens.
I guess it'd be clearer to say 3 to 4 cm with a depth of field of 1 cm.

"Surplus Shed" Nice - a triplet lens listed at $68 for only $15 ! Do you all think it would do the job ? I could also go with 4 - 8 cm, if that were needed to get the 1 cm depth, but prefer to keep it shorter, and not have to move the lens, as this is intended as a remote, telemetric gadget.

Thanks again for the assistance - very much appreciated !
- H

User avatar
jbeale
Posts: 3630
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Camera focus distance and macro lenses

Sun Jun 09, 2013 6:53 am

You can use this calculator to find depth of field: http://www.tawbaware.com/maxlyons/calc.htm

The R-Pi camera lens focal length is 3.6 mm with f-stop of 2.9 but you need two more numbers. If you plug in 3.4 cm for the focal distance (0.034 meters) and Circle of Confusion of 0.02 mm into the calculator, then you get near focus about 3 cm and far focus about 4 cm. This would correspond to adding an external lens with focal length 3.4 cm (probably a bit more in practice as that is measured from a lens principle plane, normally physically inside the lens, and you are probably measuring from the front surface of your optical element, or lens housing if that projects further.)

Remember that the R-Pi sensor pixels are only 1.4 microns on a side. So a Circle of Confusion of 20 microns means that you will have about 20/1.4 = 14 pixels of blur, at 3 and 4 cm, and sharpest focus at 3.4 cm. That is quite a lot of blur, so this is what I meant about shallow depth of field.

If you wanted to remove the built-in lens and substitute your own, you could in theory do that, but the same rules of optics apply. You get deeper depth of field by reducing f-stop, but at the cost of making everything more blurry due to diffraction! If you need high-resolution, crisply focused images throughout the 3 to 4 cm range, I think you should consider some mechanism to adjust focus or move the camera. I don't know how to achieve that depth of field all at once in a single exposure.

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: Camera focus distance and macro lenses

Sun Jun 09, 2013 8:02 am

It will be impossible to get that depth of field in one exposure. The thing to do is leave the lens in place and take several images where you move only the sensor, that way the magnification stays the same; if you move the lens you will change the magnification between images and you'll have problems stacking them together.

HowardP
Posts: 8
Joined: Fri Jun 07, 2013 6:45 pm

Re: Camera focus distance and macro lenses

Mon Jun 10, 2013 4:23 am

Interesting trade offs.

So imagine the camera pointed downward, parallel to the surface holding the object.

If a servo-motor or a stepper motor could move the whole camera assembly up and down, how many images do you think it would take, say, to move through that 1 cm field ? (That'd also determine the step size for the stepper.)

thanks!

- H

poing
Posts: 1132
Joined: Thu Mar 08, 2012 3:32 pm

Re: Camera focus distance and macro lenses

Mon Jun 10, 2013 4:44 am

My guess, from experience, would be about a dozen @ f/8 to get a tack sharp A4 print from a 12MP sensor and a high grade lens for your dimensions. But then you have f/2.9 and a 5MP sensor with a very cheap lens. It all depends on what you call 'sharp' (it's a relative concept, not absolute), the print size and the viewing distance. There's tons of info on the net, search 'focus stacking'. In the end you'll have to experiment. And please share what you find.

User avatar
jbeale
Posts: 3630
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Camera focus distance and macro lenses

Mon Jun 10, 2013 5:01 am

Ok, how about this. Using the DoF calculator and allowing 3.8 um of blur (about 3 pixels), I find that you get a depth of field of 1 cm while the focal point is set to 8 cm from the camera. That is, your "in-focus" area is about 7.5 to 8.5 cm. You can achieve that 8 cm focal length by unscrewing the stock lens just less than half a turn, or by adding an accessory close-up lens. With this camera and lens, the horizontal field of view is very nearly the same as the subject distance, so you will have an image that is about 8 cm wide, and each image pixel will be about 8 cm / 2592 pixels = 0.031 mm = 31 microns in size. That is a resolution of 32 pixels/mm or 820 pixels per inch (but remembering we allowed for up to 3 pixels of blur). If that's good enough, then you don't need to play with stepper motors, etc.

HowardP
Posts: 8
Joined: Fri Jun 07, 2013 6:45 pm

Re: Camera focus distance and macro lenses

Mon Jun 10, 2013 4:53 pm

Thanks poing and jbeale for the workable solutions and additional resources. Indeed it would be better to avoid a moving system. 8 cm might be OK; am still looking at options. Yes, I will have to fiddle with it, if we commit to the Pi / cam. combination.

I will certainly post my results !

I have another question concerning lighting at these distances - you think I should open another thread as it might wander off topic ?

cheers
- H

cauld
Posts: 1
Joined: Mon Aug 05, 2013 8:40 pm

Re: Camera focus distance and macro lenses

Mon Aug 05, 2013 8:44 pm

I ran into a similar issue this week. I need to focus on something roughly 20cm away. I bought a few different reading glasses to experiment with (+2.50 & +3.25). I found the +3.25 to work perfectly for my needs. Thanks for the tip!

slqa
Posts: 6
Joined: Tue Aug 13, 2013 8:06 am

Re: Camera focus distance and macro lenses

Tue Aug 13, 2013 8:22 am

Hello,

Is this camera have the autofocus or it is fixed?
I want to use this camera to take a picture from 5cm and I not sure is it possible.

Regards

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26023
Joined: Sat Jul 30, 2011 7:41 pm

Re: Camera focus distance and macro lenses

Tue Aug 13, 2013 8:41 am

Fixed focus. You can adjust the lens if you are willing to break the glue seal, and focus much closer. Read this thread.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“My wife said to me `...you’re not even listening`.
I thought, that’s an odd way to start a conversation.."

slqa
Posts: 6
Joined: Tue Aug 13, 2013 8:06 am

Re: Camera focus distance and macro lenses

Tue Aug 20, 2013 12:15 pm

Thanks for info.
So if i want to take a picture from 12cm, i must use +3 lens.
Regards Przemek

User avatar
jbeale
Posts: 3630
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Camera focus distance and macro lenses

Wed Aug 21, 2013 8:08 pm

Remember that Diopter = 1/f where f is focal length in meters. A +3 or 3 Diopter lens has a focal length of 0.33 meters or 33 cm. So if the RPi camera is nominally focused at infinity (usually not quite true), and you want to refocus it to 12 cm with an external close-up lens, you would need to add a 8.3 Diopter element. You could also stack together two +4 lenses and get pretty close. Or two +3 and one +2 lenses. The total Diopter value of a combined lens is the sum of the Diopter values of each component lens.

Generally speaking, the more optical elements you add, the lower your image contrast (reflections and scattering at each surface). The optically preferred solution is to simply unscrew the stock lens enough to move the focus in to where you want it. The RPi module wasn't designed to be refocused, so there is some risk of damage, but many people have done it.

slqa
Posts: 6
Joined: Tue Aug 13, 2013 8:06 am

Re: Camera focus distance and macro lenses

Thu Aug 22, 2013 10:23 am

Thanks for info.

I find a another topic with this info, and I do it, I refocused my camera and I have result which I want.

Regards

codingman
Posts: 33
Joined: Sun Dec 22, 2013 2:53 pm

Re: Camera focus distance and macro lenses

Tue Dec 31, 2013 5:00 pm

Which thread, jamesh?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26023
Joined: Sat Jul 30, 2011 7:41 pm

Re: Camera focus distance and macro lenses

Wed Jan 01, 2014 4:22 pm

codingman wrote:Which thread, jamesh?
This one!
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed. Here's an example...
“My wife said to me `...you’re not even listening`.
I thought, that’s an odd way to start a conversation.."

DAKworks
Posts: 1
Joined: Sat Jan 18, 2014 10:59 pm

Re: Camera focus distance and macro lenses

Sat Jan 18, 2014 11:04 pm

The board specs say that you can focus the (tiny) lens on the front:

Adjusting Lens Focus
The camera is fixed-focus (at infinity) as delivered. The thread-locking glue dots can be scraped off[24] allowing manual lens focus, as close as 2.5 cm. To change the focus to FL cm, unscrew the lens (turn counter-clockwise) by D degrees, where D = 360 * (3.5 cm / FL). For example, to focus at 10 cm, unscrew lens 360 * (3.5 / 10) = 126 degrees. Values are approximate[25]. The closest achievable focus is about 25 mm, after unscrewing the lens roughly 2 full turns.[26] At this point it is loose and must be held in place by other means.
Unscrewing more than 2 turns results in removal of the lens[27] allowing use of other optical systems. The lens thread size is believed to be M6 x 0.35[28].

User avatar
jbeale
Posts: 3630
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Camera focus distance and macro lenses

Mon Jan 20, 2014 4:30 am

DAKworks wrote:The board specs say that you can focus the (tiny) lens on the front
Ah, yes... that elinux wiki is a community effort, not any official "specs". I wrote that part of it, and I have adjusted the focus on several different cameras now. Actually I don't bother trying to scrape off any glue; you just grab the black square camera module with one set of pliers and the lens firmly but carefully with another set of pliers, and turn slowly. Some recommend using a rubber stopper pressed against the lens instead of pliers, to avoid marring the plastic lens assembly. Be sure to hold the camera module body and not the PCB; the camera is stuck to the PCB only weakly, with some rubbery material, and it can twist off the board easily.

AstroJohn
Posts: 14
Joined: Mon Feb 25, 2013 7:02 pm

Re: Camera focus distance and macro lenses

Thu Jul 31, 2014 7:50 pm

Probably a bit late but you can buy sets of 'cloeup filters' designed to screw in the front of camera lenses. the 37mm diameter sets are quite common and quite cheap. £13 for a set of 1,2,4 & 10 diopter. There should be mounts about that you can use else just glue one in a 37 plus a bit hole in a sheet of Aluminium or plastic.

John

Return to “Camera board”