IDS peak AFL v1.8.0
Loading...
Searching...
No Matches

Automatic focus control for lens focus positioning and sharpness optimization. More...

Topics

 Skip frames
 Frame processing optimization by skipping frames to reduce computational load.
 
 Hysteresis
 Focus stability control to prevent hunting and oscillation.
 
 Limit
 Focus position range limits and boundaries.
 
 Weighted region of interest
 Multi-region focus evaluation with configurable weights.
 
 Region of interest presets
 Predefined region of interest configurations for focus control.
 
 Sharpness algorithm
 Sharpness measurement algorithms for focus evaluation.
 
 Mode
 Operation mode configuration for automatic control functionality.
 
 Peak search algorithm
 Focus search algorithms for optimal focus positioning.
 
 Callbacks
 Event notification callbacks for automatic control operations.
 

Detailed Description

Automatic focus control for lens focus positioning and sharpness optimization.

Auto focus

The autofocus controller will automatically adjusts the lens to focus on a subject.

Enabling and automatically disabling the control function

For ongoing adaptations the Continuous mode has to be used so that it responds to deviations from the target value. To disable the control functionality automatically once the target value has been reached, (approximately) use the Once mode.

Configuring the control functions

Skip frames

The Skip frames setting defines how many frames should be skipped between processing operations. This parameter strongly influences both control speed and system stability.

How Skip Frames Works

When skip frames is set to N, the controller will:

Example: Skip frames = 3 means process every 4th frame (process 1, skip 3, process 1, skip 3...)

Dynamic Adjustment

Skip frames can be adjusted dynamically based on conditions:

Note
For higher frame rates, a larger value should be used for the Skip frames parameter. This reduces the number of automatic adjustments and improves system stability.
Different controllers can have different skip frame settings optimized for their specific requirements.

Hysteresis

Defines the size of the interval range after which the algorithm terminates the search.

Limit

With the minimum and maximum limit the focus search range for the focus_algorithm can be limited. The focus_limit affects whether and where a maximum value is found.

Weighted region of interest

The Weighted Region of Interest (Weighted ROI) is a concept to prioritize certain areas of an image over others. In the context of autofocus systems, the Weighted ROI is used to assign more importance to specific regions of the image, such as where the main subject is likely located, to ensure optimal focus.

Note
  • Depending on the acquisition conditions, several "sharpness maximum values" may be possible in the ROI. This may result in an error in control, especially with Continuous mode.
  • Small ROIs can cause the focus to fluctuate constantly so that an optimal focus cannot be found.

Region of interest preset

In the context of autofocus, a Region of Interest (ROI) preset defines a specific, predefined area of the camera’s image where the autofocus algorithm should evaluate sharpness and adjust focus. Instead of manually specifying the ROI dimensions and location, ROI presets offer a convenient way to apply common autofocus patterns — reducing configuration time and promoting consistency across systems.

These presets are especially useful when the autofocus behavior needs to follow standard framing assumptions, such as focusing on the center of the image, which is typical in most photography and machine vision applications.

For example, the PEAK_AFL_CONTROLLER_ROI_PRESET_CENTER preset instructs the autofocus controller to evaluate and adjust focus based only on the central portion of the image. This is ideal when the primary subject is expected to appear near the center of the frame.

Sharpness algorithm

Sets the algorithm for the sharpness calculation.

Peak search algorithm

Sets the algorithm for the maximum value search.

Note
If no maximum value can be found after 300 iterations, the search is aborted and the focus value is reset to the previous value.

Callback

It is possible to be informed for specific events via callbacks. Callbacks provide real-time feedback about controller operations and enable responsive application behavior.

Available Callback Types

Finished Callback

Finished will be called when the controller has completed its operation and reached the target value.

When called:

Processing Callback

Processing will be called during image processing to provide real-time feedback.

When called:

Callback Threading Considerations

Important Threading Notes:

Note
The Finished callback will only be called when the controller runs in Once mode.

Examples

Note
For the automatic host control to work, the frames must be transferred to the manager. To reduce and simplify the sample code, the examples do not check the return values.
peak_afl_AutoFeatureManager_Create(&hManager, nodemapHandle);
// create a focus controller within our manager
peak_afl_controller_handle hController = 0;
// run in continuous mode
// submit the images
while (acquisitionRunning)
{
peak_afl_AutoFeatureManager_Process(hManager, imageHandle);
}