- » View All
Simple FA Lens Selection
by Pete Kepf, CVP-A, Lens Business Development Executive - Computar Optics Group Posted 01/02/2017
Factory Automation (FA) lens applications differ from others that employ digital cameras, such as security or intelligent transportation systems (ITS) in that they are designed for high accuracy usually have controlled illumination and part location. Considering this accuracy need, little wonder, then, that megapixel cameras have gained rapid acceptance in this market. And, while the multitude of security and photography websites provide useful general information about the behavior of light through a lens to a medium, FA-specific information is not as common. This article describes a step-by-step process for selecting a lens for a camera in an FA application.
An FA (factory automation/ machine vision) application is like a stool. Just as each leg is correctly sized and shaped for the stool to function properly, so the lighting, optical system, and computer and software are carefully selected to maximize performance. Proper lighting is critical; the computer and software must be able to perform the required calculations and make a decision within the required time frame. The camera and lens make up the optical system; their capabilities must match one another. Overall system performance is limited by the weakest “leg”. In this article, the assumption is that lighting is controlled and computer and software have been optimized for the application. The discussion considers the optical system.
FA Application Considerations
There are many variables to consider for a machine vision application, the purpose of which is to transform the machine’s world “out there” into 1’s and 0’s “in here” so that it can make a good decision. The machine is accurate; it is repeatable; it is fast, but the quality of its decisions (output) depends on accurate information (input).
When beginning the application evaluation, the following questions are major considerations:
- Is the controlled illumination source visible light or another wavelength?
- Does the part move? If so, how fast?
- What is the size of the defect in units of measure (“no discernable scratches” is not a specification)?
- What is the size of the object (more specifically, what is the area of the object that will be viewed by the camera)?
- What is the distance between the object and the lens? What are the constraints due to machine access or real estate?
With answers to these questions we can begin to evolve a specification for the optical system with values for:
- Lens Composition
- Focal Length
- Sensor Format
Some of these are simple to address; others require some calculation and knowledge of how a camera and lens work together to make an optical system.
The composition of the lens is driven by the light source. The visible light spectrum is about 390 to 700 nm. Most FA applications use light in this portion of the spectrum. The proliferation of LED light sources in the UV and IR spectra, however, has enabled cost -effective object illumination for some FA applications where the material properties respond differently to different wavelengths such as plastics and fluorescent materials
Just as objects for inspection may respond differently based on wavelength, different lens materials refract or transmit light differently. For example, the silica used in the glass of most FA lenses will not refract IR. Manufacturers provide SWIR (800-1700 nm) and LWIR (8-12µm) lenses for applications such as these. For other applications, it may be useful to filter visible light for a certain color. In case, a filter thread on the outside of the lens is necessary (See Figure 1) to accommodate the appropriate filter
An excellent discussion about glass transmissivity can be found here (Galbraith, 2017)
F-Number refers to the speed of the lens. It is a ratio between the size of the aperture and the focal length of the camera. Lenses with smaller minimum f-numbers have larger apertures and are called “fast” lenses because images acquired at fast shutter speeds can receive more light than “slower” lenses.
As a rule, lower f-number lenses yield better results, especially for moving parts. A corollary rule is that more light and an aperture that is somewhat closed yields better results than low-light and a wide-open aperture. An excellent, non-technical discussion may be found at this website (Mansurov, 2015)
The focal length of the lens determines the magnification, the relationship between Working Distance and Field Of View (Figure 2).
It is defined as the distance over which initially collimated rays of light are brought to a focus (Wikipedia, 2016). Nominally, it is the distance between the optical center of the lens and the surface of the vision sensor chip. As this distance decreases the light is bent further providing a wider angle of view and increased distortion (wide angle); as this distance increases the light is bent less providing a narrower angle of view and decreased distortion (telephoto). Thus, for machine vision applications a greater Working Distance is preferable when accuracy is a consideration.
For machine vision applications, the required focal length may be approximated* using the following formula:
f = h x WD/ horizontal FOV
f = focal length in mm
h = horizontal dimension of the sensor in mm
WD = working distance in mm
horizontal Field Of View in mm
*This is an approximation because exact distances between optical center and sensor surface are often not readily available.
Sensor Dimension and Pixel Size
Before the use of current camera sensor chips with their smaller pixels, the number of pixels in the matrix determined optical system resolution; today, it is the size of the pixel. Then, only analog cameras with 525 lines at 30 frames per second were available for use in machine vision applications. These soon gave way to digital cameras with their improved 640 x 480-pixel resolution (VGA) and intuitive virtual superimposition of a grid over the object to be inspected. Lenses developed for CCTV applications were more than adequate to provide the image clarity required at this pixel resolution, from which the Field of View was calculated, for example, by:
Field Of View (mm) = Defect Size (mm/ pixel) x Number of Pixels or
6.4 mm FOV =. 01mm/ pixel x 640 pixels
Now, higher resolution cameras with smaller have pixels shifted the emphasis from pixel resolution to spatial resolution (See my article “ Is your Lens the Weakest Link in Your Megapixel Camera Inspection Application?”) (Kepf, 2016)).
Spatial resolution refers to the ability of the system to differentiate between two objects. In machine vision, it pertains to the smallest detectable defect. Smaller pixels imply the ability to resolve smaller defects. The required pixel size for a given defect size is calculated as:
Spatial Resolution = Defect Size/ Number of pixels across the defect
The number of pixels across the defect must be at least 2, and for some cameras may be 3 or 4. This is because defect detection depends on contrast or an edge. An edge is defined as a transition (light to dark; dark to light); by definition at least two pixels. Figure 2 illustrates a diagonal edge across a pixel matrix. Note contrast, dark to light, indicating the edge and requiring at least two pixels. (Note: Edge interpolation to less than a pixel can be performed with most image processing software, and often considers several pixels- in fact, the FOV calculation above requires “sub-pixel resolution”, a topic beyond the scope of this article).
As an example, a 0.01mm defect requires a 0.005mm, or 5µm or smaller pixel:
.005 mm/ pixel = 0.01mm/2 pixels
Today’s digital cameras have arrays greater than 24 megapixels and pixels smaller than 2µm. A search of one camera supplier for a sensor size <= 5µm yields a variety of matrix sizes and formats: 640 x 480 (VGA), 800 x 600 (SVGA), 1024 x 768 (XGA), 1280 x 960, 1280 x 1024 (SXGA), 1920 x 1200 (WUXGA), 2448 x 2048, 2592 x 2048, and 2560 x 2048. Also at that website, megapixel cameras are found with pixel sizes of 4.8 µm, 5 µm, and 6 µm, none of which is acceptable for the example application. Note that pixel size does not necessarily imply a megapixel camera and a megapixel camera does not necessarily imply required resolution. This has important lens considerations.
For our example, a 5-megapixel camera with a 2448 x 2048-pixel matrix is selected.
From the above, it is clear that “megapixel lens” is somewhat of a misnomer. The term refers to a lens’s ability to resolve smaller pixels whether the matrix is “megapixel” or not. In fact, a VGA camera with a 4.8µm pixel size may actually require a megapixel lens for reasons described below. There is no industry standard that defines a pixel size for a megapixel lens, but most manufacturers provide some data to match their lens to the appropriate pixel size.
Just as cameras possess spatial resolution, so too, do lenses. Recall that spatial resolution refers to the ability of a system to differentiate between two objects. For lenses, it is the contrast level at a certain spatial frequency, termed the Optical Transfer Function (OTF) or Modulus Transfer Function (MTF). An industry-standard spatial frequency is line pairs per millimeter (lp/mm). Essentially, OTF/ MTF describes the quality of the lens.
It is not a calculation, but rather a measurement resulting from a known target. The targets are used to determine the smallest transition from dark to light and vice versa that a system can detect. Figure 3 illustrates a line-pair target with images through a non-megapixel lens (orange, left) and a megapixel lens (blue, right). Note that there are both horizontal and vertical lines and targets at the center and four corners of the image. This allows measurement of the size and spacing range between the lines, large to small at a variety of locations and in both axes. Note, too, significant clarity improvement with the megapixel lens.
Spatial resolution calculations are complex and their results are often presented graphically in the form of a chart. The MTF chart plots percent contrast vs. lp/mm. Because the “perfect” lens is an abstraction, and because the manufacturing process introduces aberrations into the projection, several curves will be displayed corresponding to the distance from the center of the lens (where the fewest aberrations occur). The actual contrast requirement varies by application, but a range from 0.5 (conservative) to 0.2 (minimum) is acceptable.
Just as the sound from a great stereo may be compromised by poor speakers, a mismatch between the pixel and optical resolutions results in sub-optimal optical performance. To calculate the lp/mm for a given pixel size:
(1/ pixel size µm * 2 (line pair) * 1000
From the above example:
(1/3.45 *2 ) * 1000 = 144 lp/mm
The required 144 lp/mm at 0.2 to 0.5 MTF is not achievable with the lens described in Figure 4 (in fact, the sample chart is not for a megapixel lens).
Many manufacturers consider MTF information to be proprietary intellectual property, so it may not be readily available. To assist the specifier in lens selection, therefore, many manufacturers classify their lenses per the camera type. Thus, a 5-megapixel camera will use a matching 5-megapixel lens (Figure 5). However, there is no industry standard for such specifications. In practice, it is better to obtain the MTF chart or purchase from a reliable vendor who has performed actual product comparisons for any but the simplest applications.
Working Distance (WD)
Working distance is inversely proportional to Field of View. It is often a design constraint driven by machine space or plant floor real estate considerations. Generally, a greater Working Distance is preferred for accuracy since closer distances imply greater refraction angles and increased aberration.
This example shall assume a WD of 300mm.
Field Of View
It is preferable, though not always possible, to capture the entire object within the Field Of view of the camera. For example, a dimensional measurement is straightforward if the entire object is within the image to be processed. One may experiment with varying Fields of View for different lens focal lengths as follows:
F (mm) = h (mm) x WD (mm)/ horizontal FOV (mm)
Solving for horizontal sensor dimension given the pixel size and matrix from above:
3.45µm/ pixel * 2448 horizontal pixels * 1000 = 8.4mm
Our example did not specify an object size, however FOVs for alternative focal lengths are:
horizontal FOV (mm) = 8.4mm x 300/ f
315mm = 8.4mm x 300/ 8
210mm = 8.4mm x 300/ 12
157.5mm = 8.4mm x 300/ 16
100.8mm = 8.4mm x 300/ 25
50.4mm = 8.4mm x 300/ 50
25.2mm = 8.4mm x 300/100
It is useful to compare pixel resolution vs. optical resolution:
Pixel Resolution (mm/ pixel) = FOV (mm) / pixels
.128 mm/ pixel = 31 5mm/ 2448 pixels (8mm fl)
.020 mm/ pixel = 50.4 mm/2448 pixels (50mm fl)
Optical resolution = .0035 mm/ pixel
Therefore, for this example application, the lens is not the limiting factor.
Digital camera sensors are available in a variety of formats and sizes. Format refers to the ratio between the horizontal and vertical axis and the size refers to the dimension of the diagonal of the shape. The diagonal is referenced because it determines the smallest diameter of the image circle projected by the lens (Figure 6). It is important that the lens be compatible with the format of the sensor in order to maximize the available pixels and to avoid vignetting. In general, a larger sensor size lens may be used with a matching or smaller sensor (e.g. 2/3” to 2/3” and ½”).
The greater accuracy requirements of FA (machine vision) applications requires more attention to lens attributes than was previously. Smaller pixels in modern cameras prompt the consideration of the camera and lens as an optical system with its own spatial resolution determined by that of both the camera and the lens. This spatial resolution is often a function of pixel size, rather than the number of pixels.
Pete Kepf is a Lens Business Development Executive for CBC AMERICAS, Corp., Industrial Optics Division. Over his 30-year automation career, he has performed hundreds of machine vision installations and evaluations. Pete is a Certified Vision Professional-Advanced and a member of SPIE and MVA