[−][src]Function opencv::imgproc::corner_sub_pix
pub fn corner_sub_pix(
image: &dyn ToInputArray,
corners: &mut dyn ToInputOutputArray,
win_size: Size,
zero_zone: Size,
criteria: &TermCriteria
) -> Result<()>
Refines the corner locations.
The function iterates to find the sub-pixel accurate location of corners or radial saddle points, as shown on the figure below.
Sub-pixel accurate corner locator is based on the observation that every vector from the center to a point located within a neighborhood of is orthogonal to the image gradient at subject to image and measurement noise. Consider the expression:
where is an image gradient at one of the points in a neighborhood of . The value of is to be found so that is minimized. A system of equations may be set up with set to zero:
where the gradients are summed within a neighborhood ("search window") of . Calling the first gradient term and the second gradient term gives:
The algorithm sets the center of the neighborhood window at this new center and then iterates until the center stays within a set threshold.
Parameters
- image: Input single-channel, 8-bit or float image.
- corners: Initial coordinates of the input corners and refined coordinates provided for output.
- winSize: Half of the side length of the search window. For example, if winSize=Size(5,5) , then a search window is used.
- zeroZone: Half of the size of the dead region in the middle of the search zone over which the summation in the formula below is not done. It is used sometimes to avoid possible singularities of the autocorrelation matrix. The value of (-1,-1) indicates that there is no such a size.
- criteria: Criteria for termination of the iterative process of corner refinement. That is, the process of corner position refinement stops either after criteria.maxCount iterations or when the corner position moves by less than criteria.epsilon on some iteration.