The invention provides a method for improving
AutoFocus performance, which comprises the following steps of: S1, extracting an edge value by a
sobel operator: extracting
image edge information through a cv2. Sobel () instruction, and representing as sobelx = cv2. Sobel (
img, cv2. CV32F, 1, 0) and sobely = cv2. Sobel (
img, cv2. CV32F, 0, 1); s2, solving a variance: af = (np.var (sobelx) + np.var (sobely)) * N, np.var is a function for solving the variance, the formula is that the sum of the variances of sobelx and sobely is multiplied by a coefficient N, and the obtained af is the definition value of the picture; pixel values obtained after
Sobel operator processing are distributed more dispersedly, so that the variance can be used as an evaluation criterion because the variance is the measure of the dispersion degree when a random variable or a group of data is measured. Compared with the prior art, the method has the advantages that the performance is improved while the effect is better than that of the prior art, the difference value between the
peak value and the peak valley of the optimized method is larger in the aspect of the effect, and therefore the
peak value can be found more easily, the calculation amount is small in the aspect of the performance, and the CPU
utilization rate and the memory use can be reduced.