Tuesday, August 30, 2011

Advice on selecting a lens


Choosing a lens depends on two things: the field of view you will be imaging and the size of the sensor in the camera you selected. (If you haven’t selected a camera, take a moment to read over “Advice on selecting a camera – how many pixels?” and “Advice on selecting a camera – sensor considerations”.)

The ratio of sensor size to field of view (which you might also think of as object size,) is the magnification required, but you’ll notice that lenses are rarely specified in terms of their magnification. More often, you’ll see focal length, which relates to magnification.

I’ll spare you all the mathematics (Wikipedia does a great job – just look up ‘focal length’) and cut to the chase by saying that the shorter the focal length, the more rays of light entering the lens are bent towards the center or axis of the lens. This means that a shorter focal length lens – like one of 8mm - bends light more than one of, say, 50mm. And the consequence of bending light more is that the lens ‘sees’ over a wider angle. Thus to image a small field of view that’s a long way off, use a long focal length lens.

Now given the working distance, (the distance from the front of the lens to the object you’re imaging,) and field of view, you could calculate the focal length, but why bother when other people have written software to do it for you? Just Google ‘machine vision lens calculator’, search my blog, or best of all, download the free MachVis lens software from Linos (now Qioptiq.)

A word of warning is in order though. The lens calculators are not 100% accurate. This stems from the manufacturing tolerances in both cameras and lenses. Plus, if you use the MachVis software its results are specific to their lenses. If you use lenses from another manufacturer distances will change slightly.

So how do you deal with this? Simple: ensure there’s a certain amount of adjustment in the height of your camera. That way you can vary the working distance until the image fills the sensor, with a border to accommodate optical distortion and light fall-off, then screw it down and put it to work.

No comments: