Camera Focus Behavior
This page describes how the camera focus works in the Anyline Mobile SDK for iOS, helping you understand what your users will experience when scanning.
Overview
The Anyline Mobile SDK for iOS provides an intelligent camera focus system that combines automatic focus with manual tap-to-focus functionality, designed to provide optimal scanning performance while giving users control when needed.
Focus Modes
The SDK uses two focus modes that work together:
Continuous Autofocus (Default)
-
What it does: The camera continuously adjusts focus automatically as the scene changes
-
When it’s active: This is the default mode when the camera starts and after tap-to-focus times out
-
Best for: General scanning scenarios where users are moving the device or scanning at different distances
Tap-to-Focus
-
What it does: The camera focuses on a specific point when the user taps the screen. This feature can be disabled if not needed for your use case.
-
When it’s active: Immediately after a user taps anywhere on the camera preview
-
Best for: Precise focusing on specific areas or when automatic focus is struggling
Configuration
The camera focus behavior can be customized using the following cameraConfig
parameters in your JSON configuration:
-
enableTapToFocus
(boolean, default:true
): Enables or disables the tap-to-focus functionality. Set tofalse
to disable manual focus. -
tapToFocusTimeoutMs
(integer, default:5000
): The timeout in milliseconds after which the camera returns to continuous autofocus.
The |
Focus Behavior Sequence
Here’s what happens when users interact with the camera:
-
Camera starts: Continuous autofocus is active by default
-
User taps screen: Camera immediately focuses on the tap location and switches to manual focus mode
-
5-second timeout: After 5 seconds, the camera automatically returns to continuous autofocus mode
-
Multiple taps: If the user taps again during the 5-second period, the timer resets and starts over
Best Practices
When to Encourage Tap-to-Focus
Inform your users that tap-to-focus is helpful in these situations:
-
Difficult lighting conditions: When automatic focus struggles with low light or high contrast
-
Specific document areas: When focusing on a particular part of a document or object
-
Close-up scanning: When scanning small text or details that require precise focus
-
Struggling autofocus: When the continuous autofocus appears to be "hunting" or unstable
When to Rely on Continuous Autofocus
For most scanning scenarios, continuous autofocus works well:
-
General scanning: When users are moving the device naturally during scanning
-
Multiple objects: When scanning multiple items in sequence
-
Variable distances: When the scanning distance changes frequently
Troubleshooting
Focus Appears Not to Work
-
Ensure there’s sufficient light for the camera to determine focus
-
Check that the scanning area is not too close (closer than ~10cm) or too far (farther than ~1m) from the optimal focus range
-
Some very reflective or low-contrast surfaces may be difficult for any autofocus system
Important Notes
The focus behavior described here is the default setting. It can be configured using the parameters described in the Configuration section. The SDK automatically optimizes the specific focus mode based on device capabilities. |