Assembly: Cognex.VisionPro.Core (in Cognex.VisionPro.Core.dll) Version: 73.0.0.0
Parameters
- lowLimit
- Type: System Int32
The minimum input value to evaluate.
- highLimit
- Type: System Int32
The maximum input value to evaluate.
- tolerance
- Type: System Int32
When the maximized value can not be increased except by changing the input value by less than tolerance, this function returns.
Return Value
Type: Int32The value, in the range from lowLimit through highLimit, that produced the highest value from the Evaluate event handler that you implement.
| Exception | Condition |
|---|---|
| ArgumentException | highLimit is less than or equal to lowLimit. |
| ArgumentException | highLimit–lowLimit is greater than 701408733. |
| ArgumentException | Tolearance is less than or equal to 0. |
| CogMaximizerCancelledException | The Evaluate event sink did not set Continue to true. |
Empirically determines the input value that maximizes a function's output value. This function works by firing the Evaluate event. You supply a handler for this event that takes an input value and produces an output value; this function invokes that event handler repeatedly with a variety of input values until it determines which input value produces the maximum output value.
In addition to providing the event handler, you also supply this function with values for the lowLimit and highLimit of the range of values to evaluate. You also provide a tolerance value that controls the granularity with which this function adjusts the input value.
If the function being maximized is strictly unimodal (has only one maximum) and has no plateaus, then the maximization algorithm will compute the true global maximum for the function. If these conditions are not met, then the algorithm may compute a local but not a global maximum.
A typical application for the maximizer function is automatically focusing a camera. You would specify the minimum and maximum focus positions as the lowLimit and highLimit parameters, and your Evaluate event handler would take the supplied focus position value, adjust the focus accordingly, acquire an image, use the Image Sharpness tool to compute its sharpness score and return the sharpness score. The maximizer would invoke your event handler repeatedly with a variety of focus position values until it determined the focus position that produced the highest image sharpness score.
Note: Keep in mind that if the combination of the image sharpness method you select and the specific image content you are evaluating does not produce a strictly unimodal image sharpness graph, then this function may not determine the focus position that produces the sharpest image.