TinyBarcodeDecoding Sample
View the sample
When processing a small-sized barcode or a barcode that is localized far away, the following factors might cause the low performance:
- The module size of the barcode is too small.
- The image quality of the barcode zone is too low.
TinyBarcodeDecoding
is the sample to tell you how Dynamsoft Barcode Reader is designed to process the tiny barcodes.
Zoom Control
Set the Zoom Factor
Generally, control the camera to zoom-in has better effect than approaching to the target because some device have difficulty on close-up focus.
Close-up vs camera zoom. The focus is much easier when using camera zoom.
Here is the sample code to enlarge the zoom factor:
import DynamsoftCameraEnhancer
var dce:CameraEnhancer! = nil
var dceView:CameraView! = nil
func configurationDCE() {
dceView = CameraView(frame: self.view.bounds)
self.view.addSubview(dceView)
dce = CameraEnhancer.init(view: dceView)
dce.setZoom(3.0)
}
Enable Auto-zoom
Auto-zoom is another way for you to change the zoom factor. When the auto-zoom feature is enabled, the camera will zoom-in automatically when a barcode is located be not decoded. The auto-zoom-out will be triggered when barcode is decoded successfully.
Close-up vs camera zoom. The focus is much easier when using camera zoom.
// Include DynamsoftCameraEnhancer library and initialize an instance of DCE
import DynamsoftCameraEnhancer
...
var dce:CameraEnhancer! = nil
var dceView:CameraView! = nil
...
func configurationDCE() {
dceView = CameraView(frame: self.view.bounds)
self.view.addSubview(dceView)
dce = CameraEnhancer.init(view: dceView)
dce.enableEnhancedFeatures(.autoZoom)
}
Note: A valid license is required to use auto-zoom feature.
Focus Control
Select a suitable focus mode can help you further improve the read-rate and accuracy when processing small-size barcodes.
When your device is stable, you can lock the focal length after focusing is complete.
// Include DynamsoftCameraEnhancer library and initialize an instance of DCE
import DynamsoftCameraEnhancer
...
var dce:CameraEnhancer! = nil
var dceView:CameraView! = nil
...
func configurationDCE() {
dceView = CameraView(frame: self.view.bounds)
self.view.addSubview(dceView)
dce = CameraEnhancer(view: dceView)
let focusPoint = CGPoint(x:0.5, y:0.5)
dce.setFocus(focusPoint, subsequentFocusMode:EnumFocusMode.FM_LOCKEDD)
}
If your device is not stable, you can replace the last line with the following code to keep the continuous auto focus mode.
dce.setFocus(focusPoint, subsequentFocusMode:EnumFocusMode.FM_CONTINUOUS_AUTO)