Dealing with Defocus and Tilt: How Barcode Scanners Handle Blurry, Skewed, and Off-Angle Labels |
Subtitle: A Deep Dive into Depth of Field, the Scheimpflug Principle, and the Algorithms That Straighten Out a Crooked Barcode - with Real-World Examples from Symbol, Zebra, Honeywell, Datalogic, Cognex, and Keyence |

|
Opening Summary |
Not every barcode is presented to the scanner perfectly flat, perfectly aligned, and perfectly in focus. In the real world, barcodes are printed on curved cans, crumpled boxes, shiny foil, and uneven surfaces. They are scanned at angles, from distances that vary, and through scratched or dirty windows. The result is defocus - a blurring of the barcode's edges - and tilt - a skewing of the barcode's pattern. Both defocus and tilt can cause the decoder to misread the barcode, leading to failed scans and frustrated users. |
This article is dedicated to defocus and tilt - the challenges they pose and the solutions that engineers have developed to overcome them. We will explore the physics of defocus, the concept of depth of field, and the trade-offs between aperture, focal length, and depth of field. We will examine the Scheimpflug principle for handling tilt. We will look at hardware solutions, such as variable focus lenses and telecentric optics, and software solutions, such as digital deblurring, perspective correction, and advanced decoding algorithms. We will see how major companies have addressed defocus and tilt in their products. We will examine Symbol's (now Zebra's) use of a large depth of field in their laser scanners. We will explore Honeywell's use of a variable aperture in their imagers. We will look at Cognex's advanced algorithms for handling tilted barcodes. We will also examine Keyence's use of telecentric optics for high-precision reading. |
By the end of this journey, you will understand that defocus and tilt are not just nuisances but fundamental optical challenges that require a combination of optical, mechanical, and software engineering to overcome. |

|
Full Article |
Section 1: The Problem - When the Barcode Is Not Perfectly Flat |
In a perfect world, every barcode would be printed on a flat, matte surface, and it would be presented to the scanner at exactly the right distance and at a perfect right angle. In the real world, barcodes are on curved soda cans, wrinkled shipping boxes, glossy magazine covers, and flexible plastic bags. They are scanned by users who hold the scanner at various angles and distances. The result is a barcode image that is either blurred (defocused) or distorted (tilted) or both. |
Defocus occurs when the barcode is not at the focal plane of the lens. The image is blurred, and the sharp edges of the bars and spaces are softened. Tilt occurs when the barcode is not perpendicular to the scanner's optical axis. The barcode appears skewed, and the bar widths are distorted. |
Section 2: Defocus - The Blurred Edge |
Defocus is caused by the lens projecting an image of the barcode that is either in front of or behind the sensor plane. Instead of a sharp line, the edge of a bar is blurred into a gradual transition from dark to light. This blurring makes it difficult for the decoder to accurately measure the bar widths. |
The amount of defocus depends on two factors: the distance from the focal plane and the aperture of the lens. A larger aperture (lower f-number) gives a shallower depth of field, meaning that defocus occurs more quickly with distance. A smaller aperture (higher f-number) gives a deeper depth of field, but reduces the light intensity. |

|
Section 3: Depth of Field - The Range of Focus |
Depth of field is the range of distances over which the image is acceptably sharp. For a barcode scanner, the depth of field is the range of distances at which the scanner can read the barcode. A larger depth of field is desirable because it allows the scanner to read barcodes over a wider range of distances. |
The depth of field is determined by the lens aperture, the focal length, and the acceptable blur circle. A smaller aperture, a shorter focal length, and a larger acceptable blur circle all increase the depth of field. |
Section 4: Symbol's Laser Scanner - A Large Depth of Field |
Symbol's laser scanners, like the LS2208, have a relatively large depth of field. The laser beam is focused to a small spot, but the depth of field is extended by the use of a small aperture and a focused beam. The LS2208 can read barcodes from about 5 cm to 30 cm away. |
The large depth of field is one of the reasons why laser scanners were so popular. |

|
Section 5: Tilt - The Skewed Barcode |
Tilt occurs when the barcode is not perpendicular to the scanner's optical axis. The barcode appears skewed in the image. The bars on the side of the barcode that is closer to the scanner appear wider than the bars on the side that is farther away. This distortion can cause decoding errors. |
Tilt is a particular problem for imaging scanners, which capture a 2D image of the barcode. |
Section 6: The Scheimpflug Principle - Tilting the Lens |
The Scheimpflug principle is a geometric rule that describes how to tilt the lens or the sensor plane to keep a tilted object in focus. By tilting the lens or the sensor, the plane of focus can be aligned with the tilted object. This is used in some specialized scanners to handle tilted barcodes. |
The Scheimpflug principle is more common in machine vision than in consumer scanners. |
Section 7: Perspective Correction - Straightening the Skew |
Perspective correction is a software technique that straightens a tilted image. The algorithm detects the edges of the barcode and applies a geometric transform to correct the perspective distortion. The transform maps the skewed barcode to a rectangular image. |
Perspective correction is used in many advanced barcode decoders. |

|
Section 8: Honeywell's Variable Aperture - Adjusting the Depth of Field |
Honeywell's 1900 imager uses a variable aperture. The aperture can be adjusted to change the depth of field. For a close-up scan, the aperture can be opened to gather more light. For a distance scan, the aperture can be stopped down to increase the depth of field. |
The variable aperture is controlled by the scanner's firmware. |
Section 9: Cognex's Advanced Algorithms - Handling Tilted Barcodes |
Cognex, a leader in machine vision, has developed advanced algorithms for handling tilted barcodes. The algorithms use a combination of edge detection, perspective correction, and robust decoding to read barcodes that are presented at extreme angles. |
Cognex's DataMan series includes these advanced algorithms. |
Section 10: Keyence's Telecentric Optics - Orthogonal Projection |
Keyence, a Japanese manufacturer of industrial sensors, uses telecentric optics in some of their scanners. A telecentric lens provides an orthogonal projection. The image is not distorted by perspective. This eliminates the tilt distortion. |
The telecentric lens is more expensive than a conventional lens. |

|
Section 11: The Impact of Defocus on the Edge |
Defocus softens the edges of the barcode. The sharp transition from white to black becomes a gradual ramp. The comparator's threshold is crossed at a different point, causing the measured bar width to be incorrect. |
The defocus effectively shifts the edge, causing an error in the bar width measurement. |
Section 12: The Impact of Tilt on the Bar Widths |
Tilt causes the bar widths to vary across the barcode. The bars on one side appear wider than the bars on the other side. This variation can cause the decoder to misread the barcode. |
The tilt distortion must be corrected before the barcode can be decoded. |
Section 13: The Impact of Defocus on the Adaptive Threshold |
The adaptive threshold is not directly affected by defocus. The adaptive threshold tracks the average level of the signal. The defocus reduces the signal amplitude, but the adaptive threshold adjusts. |
However, a severe defocus can reduce the amplitude so much that the comparator cannot distinguish between black and white. |

|
Section 14: The Impact of Defocus on the Hysteresis |
The hysteresis is not directly affected by defocus. The hysteresis suppresses noise. The defocus does not cause noise; it causes a smearing of the signal. |
Section 15: The Impact of Tilt on the Decoder |
The tilt distortion must be corrected by the decoder. The decoder must detect the tilt and apply a correction. If the decoder does not correct for tilt, the barcode will be misread. |
Section 16: The Depth of Field and the Aperture |
The aperture is a fundamental parameter of the lens. A smaller aperture gives a larger depth of field but reduces the light intensity. A larger aperture gives a smaller depth of field but increases the light intensity. |
The aperture is a trade-off between depth of field and light sensitivity. |

|
Section 17: The Depth of Field and the Focal Length |
The focal length is another fundamental parameter of the lens. A shorter focal length gives a larger depth of field but a smaller image. A longer focal length gives a smaller depth of field but a larger image. |
The focal length is a trade-off between depth of field and magnification. |
Section 18: The Depth of Field and the Pixel Size |
The pixel size of the sensor affects the depth of field. A smaller pixel size gives a higher resolution but a smaller depth of field. A larger pixel size gives a lower resolution but a larger depth of field. |
The pixel size is a trade-off between resolution and depth of field. |
Section 19: The Depth of Field and the Module Width |
The module width of the barcode affects the depth of field requirements. A smaller module width requires a smaller blur circle, which means a smaller depth of field. A larger module width allows a larger blur circle, which means a larger depth of field. |

|
Section 20: The Depth of Field and the Scanning Distance |
The scanning distance is the distance between the scanner and the barcode. The depth of field must cover the expected range of scanning distances. |
Section 21: The Defocus and the Lens Aberrations |
Lens aberrations, such as spherical aberration and chromatic aberration, can also cause defocus. The lens aberrations cause the image to be blurred even when it is in focus. |
High-quality lenses minimize the aberrations. |
Section 22: The Tilt and the Decoder's Tolerance |
The decoder has a tolerance for tilt. A small amount of tilt can be tolerated. A large amount of tilt will cause a decoding error. |

|
Section 23: The Tilt and the Perspective Correction |
Perspective correction is a software technique for correcting tilt. The perspective correction algorithm detects the tilt and applies a geometric transform. |
Section 24: The Tilt and the Lens Distortion |
Lens distortion, such as barrel distortion and pincushion distortion, can also cause the barcode to appear distorted. The lens distortion must be calibrated and corrected. |
Section 25: The Defocus in Honeywell's 1900 |
Honeywell's 1900 imager uses a variable aperture to handle defocus. The variable aperture adjusts the depth of field to the scanning distance. |

|
Section 26: The Tilt in Cognex's DataMan |
Cognex's DataMan uses advanced algorithms to handle tilt. The algorithms include perspective correction and robust decoding. |
Section 27: The Defocus and Tilt in Keyence's Scanners |
Keyence's scanners use telecentric optics to eliminate the tilt distortion and provide a large depth of field. |
Section 28: The Defocus and Tilt in Zebra's Scanners |
Zebra's scanners use a combination of optical and software techniques to handle defocus and tilt. |

|
Section 29: The Defocus and Tilt in Datalogic's Scanners |
Datalogic's scanners also use a combination of optical and software techniques. |
Section 30: The Future - Liquid Lenses for Focus Control |
Liquid lenses are an emerging technology that can change their focal length by applying a voltage. Liquid lenses can be used for automatic focus control. The scanner can automatically focus on the barcode. |
Section 31: The Future - Depth from Defocus |
Depth from defocus is a technique that uses the amount of defocus to estimate the distance to the barcode. The estimated distance can be used to set the focus and to decode the barcode. |

|
Section 32: The Future - AI for Deblurring and Correction |
Artificial intelligence is being used to deblur and correct distorted barcodes. A deep learning model can be trained to recognize distorted barcodes and to correct them. |
Section 33: The Defocus and Tilt in Microchip's Reference Design |
Microchip's reference design does not specifically address defocus and tilt. The reference design is a basic decoder. |
Section 34: The Defocus and Tilt in NXP's Reference Design |
NXP's reference design also does not specifically address defocus and tilt. |

|
Section 35: The Defocus and Tilt - A Summary of Best Practices |
Based on our exploration, let us summarize the best practices for handling defocus and tilt in a barcode scanner: |
1. Use a Small Aperture: A smaller aperture increases the depth of field. |
2. Use a Short Focal Length: A shorter focal length increases the depth of field. |
3. Use a Variable Aperture: A variable aperture allows the scanner to adjust the depth of field. |
4. Use Telecentric Optics: Telecentric optics eliminate perspective distortion. |
5. Use Perspective Correction: Perspective correction software straightens a tilted barcode. |
6. Use Advanced Decoding Algorithms: Advanced algorithms can handle defocus and tilt. |
7. Consider a Liquid Lens: A liquid lens provides automatic focus control. |

|
Final Summary |
Defocus and tilt are significant challenges in barcode scanning. Defocus occurs when the barcode is not at the focal plane, causing the edges to be blurred. Tilt occurs when the barcode is not perpendicular to the scanner's optical axis, causing the barcode to be skewed. |
We have seen how major companies have addressed defocus and tilt. Symbol's laser scanners have a large depth of field. Honeywell uses a variable aperture. Cognex uses advanced software algorithms. Keyence uses telecentric optics. Each technique has its own strengths. |
Defocus and tilt are not insurmountable problems. With a combination of optical, mechanical, and software engineering, they can be effectively managed. |