• Practice

    Practice

    Planning and realization of applications

Precise lens focusing

Initial situation

Often the camera is simply screwed on and the image detail is adjusted visually via the monitor by slightly moving and tilting the camera. Then any aperture is selected temporarily and the lens ring is rotated back and forth until the image seems to be sharp: and then the software programming of the camera starts. For not very challenging tasks, such as part presence applications, this may be sufficient.

When and why must the image be absolutely sharp?

Improper focusing leads to loss of contrast and sharpness, which can complicate the optical detection of defects by means of the machine vision system. The overall contrast decreases, and small details cannot be resolved any more. Especially measurement and surface inspection applications for the detection of finest details and defects become more unreliable in this way:

Sharp und blurry images

High contrasts with a sharp images

Decrease of contrast and loss of resolution of small details in the blurred image on the right

When may the image be slightly out of focus?

However, it should not be concealed that some applications are more robust if small interfering details are suppressed by blurring. The blurring has the same effect as, for instance, a mathematical low-pass filter. By smearing the pixel information onto neighbouring pixels, the image is slightly smoothened and blurred. Typical applications are OCR applications in which single frayed dots of the inkjet typeface or the variable edge of an embossed font can be depicted slightly blurred and are homogenised in this way. Any disturbing surface effects on metals, such as brushing structures, can possibly be moderated in this way, too. In principle, the image may be blurred if it is not used for measurements and if no larger structures must be found on a noisy, textured or distorted background.

Steps for correct focusing

The starting point for correct focusing is the fact that your camera is perfectly mounted in vertical position to your work surface. Otherwise tilting will automatically cause blurring at the margins. Please follow the instructions of the document "Perfect alignment of the camera system“.


Procedure:

  • Select a low gain setting to avoid excessive noise. The basic configuration of the camera should be ok in most cases.
  • Now open the lens aperture completely. The camera image will be very bright.
  • Adjust the exposure time and set a medium brightness again. Avoid over-exposure. Gray shades are otherwise overexposed, details are no longer visible.
  • Use a test chart with fine structural details, such as increasingly finer line pairs, the Siemens star or other simple objects with finest structures. The test pattern should be in the same plane as your part, or the surface to be tested.
  • Now focus exactly on the desired focus point using minimum depth of field (open aperture). From that point, the depth of field expands in both directions (towards the camera / away from the camera).

Small depth of field

Small depth of field with small f-stop

Tilted component, aperture fully open: minimum depth of field, ideal for focusing on the desired area.

Small depth of field

small depth of field

  • At the end adjust the exposure time again to achieve ideal brightness.

Large depth of field

large depth of filed with large stop-stop

Figure: Stop-downed lens, large depth of field, uniform expansion of the depth of field towards the camera / away from the camera:

Large depth of field

large depth of field

Test objects and test patterns for lens focusing

Images with extremely fine patterns and structures are particularly helpful to focus the lens. In order to determine the expansion of the depth of field, calibration blocks with a slope of 45 degree with a (perspectively corrected) scale are used.

DOF targets

test targets / objects for determing depth of field and telecentric range

Calibration objects with parallel lines help to calibrate applications using telecentric lenses. Within the telecentric range they are in focus and arranged absolutely in parallel. Outside the telecentric range, the lines diverge towards the camera, and converge into the depth of the room.


"Siemens star" test pattern
A particularly practical pattern is the Siemens star involving periodically arranged light and dark segments. If the image is sharp, the blurred area in the centre of the star is very small.

Siemens star

siemens stars patterns for exact focusing

More explanations on the Siemens star can be found in the document "Principles and use of Siemens star" in the "Service" section of this website.

Influence of optical errors on image sharpness

Almost all optical errors (chromatic aberration, coma, astigmatism, etc.) cause blurred, unsharp pictures. In particular classical lenses with spherical lens elements are subject to the phenomenon of field curvature (spherical aberration). The spherical surface of the lens has the effect that the image field is not a plain on the sensor in case of optimum sharpness in the image centre, but a curvature. This optical error can be compensated by lens manufacturers by means of aspherical lenses. Most optical errors increase towards the margin, which can be reduced by stopping down the lens a bit.
Particularly in case of fine structures and it can well be observed that your image has the highest sharpness and contrast in the centre of the image, but towards the margin the imaging quality is clearly reduced. Use high-quality lenses and, if required, a larger image circle diameter in such cases.


Tipp:
Further instructions, calibration charts, Siemens star, etc. can be found in the "Service" menu of this website for download.

Partner & Network

European Imaging Academy
Machine Vision
UKIVA
SpectroNet
Inspect
Machine Vision 4 Users