Long-Distance QR Code Scanning: Why Scanning Fails and How Zoom Helps
Have you had such an experience that you need to scan a QR code displayed on a screen in the front of a meeting room, but you sat in the back? You opened the barcode scanning app and aimed it at the code, but it just couldn’t read the code. Of course, it is better to make the QR code big enough for long-range scanning. But in many cases, the size is limited.
This article is Part 1 in a 1-Part Series.
We generalized that there are two aspects to which we can pay attention to improve long-range barcode scanning:
- Zoom-in
- A higher resolution
We will discuss them in two articles. In this article, we will talk about how to optimize the performance of scanning QR codes at a distance via zoom-in.
What you’ll learn: why a QR code that is far away stops decoding, how digital zoom and refocusing enlarge the code on the sensor, how to control the zoom factor programmatically, and how the built-in auto-zoom of Dynamsoft Camera Enhancer zooms into detected-but-undecoded barcode zones.
Key Takeaways
- A distant code fails to decode when its modules become smaller than what the camera sensor and the decoder can resolve; zooming in enlarges the code and removes surrounding interference.
- Manual zoom is one API call:
mCamera.setZoomFactor(factor)with a factor between1.0fand the device maximum fromgetCapabilities().maxZoomFactor. - Instead of hand-rolling zoom from localization results, the current Dynamsoft Camera Enhancer provides
EF_AUTO_ZOOM: it zooms into the un-decoded barcode zone automatically and zooms out after a successful decode (a valid license is required). - Digital zoom magnifies and can blur the image, so refocusing on the region of interest after zooming matters; optical zoom gives lossless results but is harder to access from apps.
An Android barcode scanning app using Dynamsoft Barcode Reader is made for illustration as shown below (In the image, the app finds the code, zooms in, and runs super resolution to achieve successful decoding).

We can zoom in for a close-up of QR codes. The code can become clearer and it will take a larger portion of the image so that there will be less interference. There are two kinds of zoom: optical zoom and digital zoom.
Why It Fails
When you sit far from a screen, the QR code shrinks to a few hundred pixels on the sensor, and each black or white module spans less than one pixel row. The decoder then cannot distinguish modules reliably, and motion blur or a slightly defocused lens makes it worse. The obvious fix is to make the code occupy more pixels - either by moving closer or by zooming in - which is what the rest of this article covers.
Digital Zoom
Digital zoom uses image processing algorithms to achieve the zoom-in effect. It is available on every modern mobile device. This is not lossless so the image will become blurry. Refocusing at the region of interest will be easier after digital zoom. So it is a bit different from cropping images already taken.
One of the top phone manufacturers boasts a 100x state-of-art digital zoom.
Zoom In to Better Find a Region of Interest
In the current version of Dynamsoft Camera Enhancer, whose camera is built on CameraX, zoom can be controlled using the following code:
mCamera.setZoomFactor(2.0f);
The zoom factor ranges from 1.0f to the maximum zoom factor of the device camera. We can get the max zoom factor using getCapabilities().maxZoomFactor.
Try it yourself with a 30-day free trial license.
Auto Zoom to a Region of Interest
Barcode scanning can be divided to two steps: detection of barcode zones and decoding of these possible barcodes. Even though a code is not read successfully, we can use the detection result to perform digital zoom afterward.
Earlier versions of Dynamsoft Barcode Reader stored intermediate results like the localization results of detected barcodes so that developers could zoom in on the detected-but-undecoded barcode zones by themselves.
In the current version, Dynamsoft Camera Enhancer provides auto zoom as a built-in feature: the camera zooms in automatically towards the un-decoded barcode zone and zooms out after the barcode is decoded.
Enable the auto zoom feature with the following code:
// A valid license is required to enable the auto zoom feature.
mCamera.enableEnhancedFeatures(EnumEnhancerFeatures.EF_AUTO_ZOOM);
If a code is detected but not successfully decoded, the camera will zoom in for a better scanning success rate.
Before auto zoom:

After auto zoom:

Optical Zoom
Optical zoom gives a lossless result since it directly manipulates rays of light.
Some smartphones, like iPhone 7 Plus, have built-in optical zoom. The magnification factor supported by different devices can range from 2x to 10x.

Image Source: https://osxdaily.com/2016/12/27/use-optical-zoom-lens-iphone-plus-camera/
But not all devices have the optical zoom feature. Although there are accessories which can bring optical zoom to phones without it built-in, it is not convenient.

Image Source: https://www.amazon.com/Youniker-Telephoto-Including-Aluminum-Telescope/dp/B06XPYKXNK/
It is not easy to utilize the phone’s optical zoom ability in our own applications since it may rely on the OEM’s SDK. A multi-camera API is introduced in Android 9, making it possible to use all the physical cameras, as phones with the optical zoom feature have multiple cameras with various focal lengths. We can achieve an optical zoom effect by switching to the long focal length camera. (See the official doc for details)
The phone camera technology is evolving. Some phone manufacturers have adopted liquid lens to achieve optical zoom and make macro shots with one single camera. Optical zoom may become more available in the future.
Next: resolution.
Real-World Constraints
- Digital zoom is lossy. Magnifying the preview or the frames can blur the code; the article’s demo refocuses on the zoomed region to recover sharpness.
- Zoom capability varies by device. The maximum zoom factor depends on the hardware; one manufacturer’s 100x digital zoom is marketing range, not usable scanning range.
- Optical zoom is rarely app-accessible. Accessing the telephoto lens usually relies on OEM SDKs; on Android 9+ the multi-camera API makes switching to a longer focal length camera possible in principle.
- Auto zoom needs a valid license.
EF_AUTO_ZOOMis a licensed feature of Dynamsoft Camera Enhancer; without a valid license the camera does not zoom automatically.
Common Issues & Edge Cases
- Zooming in makes the preview blurry. Digital zoom magnifies the image; tap to refocus on the code after zooming (the demo shows a long-press refocus flow).
- The auto-zoom feature does nothing. Check that the feature was enabled with
enableEnhancedFeatures(EnumEnhancerFeatures.EF_AUTO_ZOOM)and that the license initialized successfully; the sample’s seek bar still allows manual zoom in that case. - Scanning still fails at maximum zoom. When zoom alone is not enough, move to the next technique in this series: capture a high-resolution photo and enhance the image (see the resolution article below).