CN106154688B - Automatic focusing method and device - Google Patents

Automatic focusing method and device Download PDF

Info

Publication number
CN106154688B
CN106154688B CN201510160558.0A CN201510160558A CN106154688B CN 106154688 B CN106154688 B CN 106154688B CN 201510160558 A CN201510160558 A CN 201510160558A CN 106154688 B CN106154688 B CN 106154688B
Authority
CN
China
Prior art keywords
focusing
focus
steps
gray contrast
value
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201510160558.0A
Other languages
Chinese (zh)
Other versions
CN106154688A (en
Inventor
慕千里
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
ZTE Corp
Original Assignee
ZTE Corp
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by ZTE Corp filed Critical ZTE Corp
Priority to CN201510160558.0A priority Critical patent/CN106154688B/en
Priority to PCT/CN2015/086686 priority patent/WO2016161734A1/en
Publication of CN106154688A publication Critical patent/CN106154688A/en
Application granted granted Critical
Publication of CN106154688B publication Critical patent/CN106154688B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G03PHOTOGRAPHY; CINEMATOGRAPHY; ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ELECTROGRAPHY; HOLOGRAPHY
    • G03BAPPARATUS OR ARRANGEMENTS FOR TAKING PHOTOGRAPHS OR FOR PROJECTING OR VIEWING THEM; APPARATUS OR ARRANGEMENTS EMPLOYING ANALOGOUS TECHNIQUES USING WAVES OTHER THAN OPTICAL WAVES; ACCESSORIES THEREFOR
    • G03B13/00Viewfinders; Focusing aids for cameras; Means for focusing for cameras; Autofocus systems for cameras
    • G03B13/32Means for focusing
    • G03B13/34Power focusing
    • G03B13/36Autofocus systems

Abstract

The invention provides an automatic focusing method and device, wherein the automatic focusing method comprises the following steps: acquiring a fuzzy diameter value of an image sensor of a terminal, an aperture value of a lens and a motion parameter of a motor; calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor; eliminating the steps of which the object distance range is within the object distance range of other steps in the steps; acquiring gray contrast values of corresponding positions of all steps left after elimination; and determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus. The problem of among the prior art because the fixed of speed, the step length etc. of motor can not focus accurately, cause the formation of image quality poor is solved, realized quick auto focus, can not influence its formation of image quality yet, promoted user experience.

Description

Automatic focusing method and device
Technical Field
The invention relates to the technical field of digital image processing, in particular to an automatic focusing method and device.
Background
In recent years, with the progress and development of technology, electronic photographing devices (terminals) have become an indispensable part of life of people, particularly smart phone tablet computers and the like, and the life style of people is changed. The method and the device for terminal auto-focusing are one of the most important factors for determining the terminal imaging quality.
According to the optical principle, to shoot a clear image, the focal length (f), the object distance (u) and the image distance (v) of the lens need to satisfy the following conditions:
Figure GDA0002519149920000011
when the image is clear, the sharpness and the details of the image are rich, and the image is represented in a spatial domain that the gray contrast value of the adjacent pixel points is maximum. According to this principle, the gray contrast value of an image in a focused state is maximized by extracting the gray contrast values of the contour and the edge of the focusing window of the image. Therefore, the motor drives the lens to move, the image distance is changed, meanwhile, the gray contrast value of the image is obtained through real-time calculation, and the position with the maximum gray contrast value is the focus position.
As shown in fig. 1, which is a two-dimensional graph of gray contrast and image distance in the prior art, it can be obtained from fig. 1 that the gray contrast curve has three characteristics, 1) unimodal, that is, only one gray contrast maximum; 2) monotonicity, namely that on two sides of the maximum value of the gray contrast, the gray contrast curve is monotonously decreased or decreased; 3) and polarity, whether the current focusing position is in front of focus or behind focus can be judged.
In the prior art, to achieve focusing, the lens moves from the starting position to the ending position, and the whole stroke is completed according to a fixed speed, a fixed step length and a fixed number of steps, because the object distance and the image distance of the lens are not linear, as shown in fig. 2. This method has the following drawbacks: if the step size is small, the number of steps increases, resulting in too long focusing time, and if the step size is large, resulting in inaccurate and unstable focusing.
Disclosure of Invention
The invention provides an automatic focusing method and device, which solve the problem of poor imaging quality caused by the fact that the speed, step length and the like of a motor cannot be accurately focused in the prior art.
In order to solve the problems, the invention adopts the following technical scheme:
a method of auto-focusing, comprising:
acquiring a fuzzy diameter value of an image sensor of a terminal, an aperture value of a lens and a motion parameter of a motor;
calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor;
eliminating the steps of which the object distance range is within the object distance range of other steps in the steps;
acquiring gray contrast values of corresponding positions of all steps left after elimination;
and determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus.
Further, determining a step position from the remaining steps as a focus of focusing according to the gray contrast value comprises: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000021
when n is2>When i is, An=XiAnd the step left after the elimination is used as a first focusing step; the motor is controlled to move to push a focusing window to focus on the positions corresponding to the first focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focus step, i and n are positive integers.
Further, when the inflection point appears in the gray contrast value at the position corresponding to three consecutive steps in the first focus step, the method further includes: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000022
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; the motor is controlled to move to push the focusing window to focus on the position corresponding to the second focusing step from far to near, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the second focusing step, any position corresponding to the two steps with the larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnFor a second focus step.
Further, when the gray contrast values at the positions corresponding to three consecutive steps in the second focus step have inflection points, the method further includes: selecting to satisfy:
Figure GDA0002519149920000031
is left after eliminationThe lower step is used as a third focusing step; the motor moves to push a focusing window to focus the third focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBThe number of the determined closest step of the second focus steps.
Further, the gray contrast value of one position where the gray contrast values of the positions corresponding to the three consecutive steps in the first focus step appear an inflection point is determined as a first threshold, the gray contrast value of one position where the gray contrast values of the positions corresponding to the three consecutive steps in the second focus step appear an inflection point is determined as a second threshold, the gray contrast value of the focus is greater than the second threshold, and the second threshold is greater than the first threshold; acquiring a gray contrast value of a current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of a focus, executing a step of selecting a third focusing step; if the current gray contrast value is larger than the first threshold value and smaller than the second threshold value, executing a step of selecting a second focus step; the step of selecting the first focus step is performed if the current grey contrast value is smaller than a first threshold value.
Further, the speed of the motor motion is controlled according to the distance between two adjacent focal points.
An autofocus device comprising:
the parameter acquisition module is used for acquiring a fuzzy diameter value of an image sensor in the terminal, an aperture value of a lens and a motion parameter of a motor;
the object distance range calculation module is used for calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor;
the stepping eliminating module is used for eliminating steps of which the object distance range is within the object distance range of other steps in the stepping process;
the gray contrast acquisition module is used for acquiring the gray contrast value of the corresponding position of each step left after the elimination;
and the focus determining module is used for determining a stepping position from the remaining steps after the elimination according to the gray contrast value to be used as a focusing focus.
Further, the focus determination module includes: a first focus step selection submodule for selecting a focus step that satisfies the following formula:
Figure GDA0002519149920000041
when n is2>When i is, An=XiAnd the step left after the elimination is used as a first focusing step; the first focus determining submodule is used for pushing a focusing window to focus on the position corresponding to the first focusing step from near to far by controlling the motor to move, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focus step, i and n are positive integers.
Further, the focus determination module further comprises: the second focusing step selection submodule is used for selecting the gray contrast values at the positions corresponding to three continuous steps in the first focusing step to meet the following formula after inflection points appear in the gray contrast values:
Figure GDA0002519149920000042
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; a second focus determining submodule for controlling the motor to move to drive the focusing window to focus on the position corresponding to the second focus step from far to near, when the focusing window is focused onWhen inflection points appear in the gray contrast values of the positions corresponding to the continuous three steps in the second focusing step, selecting any position corresponding to two steps with larger gray contrast values in the positions corresponding to the continuous three steps as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnFor a second focus step.
Further, the focus determination module further comprises: a third focusing step selection submodule, configured to select a gray contrast value at a position corresponding to three consecutive steps in the second focusing step, which satisfies:
Figure GDA0002519149920000051
the step left after the elimination is used as a third focusing step; the third focus determining submodule is used for pushing a focusing window to focus on the third focusing step from near to far through the movement of a motor, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBThe number of the determined closest step of the second focus steps.
Further, still include: a threshold determination module, configured to determine, as a first threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the first focus step have inflection points, and determine, as a second threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the second focus step have inflection points, where the grayscale contrast value of the focus is greater than the second threshold, and the second threshold is greater than the first threshold; the processing module is used for acquiring the gray contrast value of the current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of the focus, a trigger starting instruction is sent to the third focusing step selection submodule; if the current gray scale contrast value is larger than a first threshold value and smaller than a second threshold value, sending a trigger starting instruction to the second focus stepping selection submodule; and if the current gray contrast value is smaller than a first threshold value, sending a trigger starting instruction to the first focusing stepping selection submodule.
The invention has the beneficial effects that:
the invention provides an automatic focusing method and device, which are characterized in that the object distance range of each step of a motor is calculated by acquiring the fuzzy diameter value of an image sensor of a terminal, the aperture value of a lens and the motion parameter of the motor, the steps of the object distance range in the object distance range of other steps are eliminated, and the gray contrast value of the corresponding position of each step left after elimination is acquired; and determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus. This scheme is through rejecting in the step-by-step of other step-by-step object distance within ranges for can not coincide between the step-by-step object distance scope that newly obtains, reduced the number of times that the motor removed, and the removal step length of motor has also changed, thereby realized quick auto focus, can not influence its imaging quality yet, promoted user experience.
Drawings
FIG. 1 is a two-dimensional plot of gray scale contrast and image distance in a terminal;
FIG. 2 is a graph of image distance versus object distance;
FIG. 3 is a flowchart of an auto-focusing method according to an embodiment of the present invention;
FIG. 4 is a detailed flowchart of a method for automatic multi-focusing according to an embodiment of the present invention;
FIG. 5 is a graph of image distance and gray scale contrast according to an embodiment of the present invention;
fig. 6 is a schematic structural diagram of an auto-focusing apparatus according to a second embodiment of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the following detailed description and accompanying drawings.
The first embodiment is as follows:
fig. 3 is a flowchart of an auto-focusing method according to an embodiment of the present invention, please refer to fig. 3,
s301: acquiring a fuzzy diameter value of an image sensor of a terminal, an aperture value of a lens and a motion parameter of a motor;
the terminal of the invention comprises: mobile phones, tablets, palm top computers, cameras, video cameras, etc.; the motion parameters of the motor include: the motor stroke and the oscillation frequency and the oscillation time when the motor drives the lens to move; in the embodiment, a fuzzy diameter value of the image sensor, an aperture value of the lens, a motor stroke and an oscillation frequency and an oscillation time when the motor drives the lens to move are obtained by reading parameters written in a terminal memory; the oscillation frequency and the oscillation time of the motor during movement can also be obtained by measuring through a special measuring instrument;
s302: calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor;
it should be noted that, in the image sensor of the terminal, the length and speed of each step of the motor are set according to the blur diameter value, the aperture value of the lens and the motion parameters of the motor; the relationship between motor stroke and length of step is:
Figure GDA0002519149920000071
wherein S is the motor stroke and u is the length of the step; different motors are matched with different lenses, and the motor oscillation frequency and the motor oscillation time are different; the relationship between the movement speed of the motor and the oscillation time is vi=f'.F(tf),viAs the speed of movement, tfF 'is oscillation time, and f' is oscillation frequency; for each step of the motor, the range of object distances corresponding to each step comprises: near object distance Limit (Near Focus Limit):
Figure GDA0002519149920000072
and Far Focus Limit (Far Focus Limit):
Figure GDA0002519149920000073
wherein H is the hyperfocal distance,
Figure GDA0002519149920000074
a is a lens aperture value, and d is an image sensor fuzzy diameter; calculating the corresponding u after each step of the motorNAnd uF
S303: eliminating the steps of which the object distance range is within the object distance range of other steps in the steps;
specifically, the object distance ranges of adjacent steps can be obtained by pairwise comparison: comparing u in adjacent stepsNAnd uFThe step which can cover other focusing object distance is selected, namely, the step of which the object distance range is in other object distance ranges is removed, so that the distance of the adjacent step is not the same in the rest steps, the moving distance of each step of the motor is not the same, but the step can cover the object distance range which can be covered by the step, and in the step, the redundant steps are removed; for example, in this embodiment, assuming that the new moving step of the motor is Xi, where Xi is the step left after the elimination, and i is a positive integer, that is, the motor will move according to the position corresponding to the new step Xi, the number of steps moved to complete the formation of the whole motor will be reduced;
s304: acquiring gray contrast values of corresponding positions of all steps left after elimination;
when the motor moves one step each time, a corresponding gray contrast value exists in the position corresponding to the step; obtaining the gray contrast value of each step corresponding position, generally moving to the step corresponding position by controlling a motor, and focusing the position to obtain the gray contrast value of a pixel point in the focusing window;
s305: determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus;
in this embodiment, the motor is controlled to focus the corresponding position of each step left after the elimination, so as to obtain the gray contrast value corresponding to each step, and the position of the step corresponding to the value with the largest gray contrast is selected as the focus of focusing, or the position of the step corresponding to the gray contrast value belonging to the range satisfying the high-definition imaging is selected as the focus of focusing. In the embodiment, the repeated steps in the object distance range with other steps are eliminated, so that the moving times of the motor are reduced, the imaging quality is not reduced, the possibility of quick focusing can be achieved, and the use experience of a user is improved.
Preferably, the step S305 of determining a position of one step from the remaining steps as a focus of focusing according to the gray contrast value includes: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000081
when n is2>When i is, An=XiAnd the step left after the elimination is used as a first focusing step; the motor is controlled to move to push a focusing window to focus on the positions corresponding to the first focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focusing step, i and n are positive integers; in this embodiment, steps satisfying the above formula are selected as first focus steps, only the selected first focus step is focused, and the gray contrast values at the positions of the corresponding steps are calculated from near to far, and when the gray contrast values at the positions corresponding to three consecutive steps in the first focus step have inflection points, it is not necessary to focus the positions of other first focus steps, but only the positions of the three consecutive steps are focusedAny position corresponding to two steps with larger gray contrast values in the positions corresponding to the steps is used as a focusing focus; the any position comprises a position corresponding to any step between two steps with larger gray contrast values, or a position corresponding to any step left after elimination between two steps with larger gray contrast values; the focusing method has the advantages that the focusing accuracy and clear imaging can be realized by selecting any position as the focusing focus, and in the focusing process, the focusing does not need to be continued only after inflection points appear in the gray contrast values of the positions corresponding to three continuous steps, so that the focus can be found more quickly, and the focusing possibility can be realized.
In this embodiment, since the position between two steps obtained by the first focus is larger, the focus relative error obtained by selecting the focus is also larger, and in order to more accurately obtain the position of the focus, the selected range needs to be narrowed, and the step of narrowing the selected range includes: when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, selecting the gray contrast values which satisfy the following formula:
Figure GDA0002519149920000091
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; the motor is controlled to move to push the focusing window to focus at the position corresponding to the second focusing step from far to near, namely in the process of focusing, after the focusing of the first focusing step is stopped, namely when an inflection point appears in the gray contrast value in the first focusing step; when inflection points appear in the gray contrast values of the positions corresponding to the continuous three steps in the second focusing step, selecting any position corresponding to two steps with larger gray contrast values in the positions corresponding to the continuous three steps as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnA second focus step; in the present embodiment, bySelecting the steps meeting the formula as second focusing steps, focusing only the selected second focusing steps, calculating the gray contrast values of corresponding stepping positions from far to near, and only needing to use any position corresponding to two steps with larger gray contrast values in the positions corresponding to the continuous three steps as a focusing focus without focusing the positions of other second focusing steps after the gray contrast values of the positions corresponding to the continuous three steps in the second focusing steps have inflection points; similarly, the any position includes a position corresponding to any step between two steps with a larger gray contrast value, or a position corresponding to any step left after rejection between two steps with a larger gray contrast value; selecting either position as the focus of focusing further makes it possible to achieve the accuracy of focusing.
Further, in order to make the determined range of the position of the focused focal point more accurate, when the gray contrast values of the positions corresponding to three consecutive steps in the second focus step have inflection points, the method further includes: selecting to satisfy:
Figure GDA0002519149920000101
the step left after the elimination is used as a third focusing step; the motor moves to push a focusing window to focus the third focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBA number for a determined closest one of the second focus steps; controlling the motor to move from near to far, from far to near and from near to far respectively through the three steps, focusing respectively to obtain the gray contrast value of each stepping position, and finally obtaining the most accurate stepping position of the gray contrast value in the terminal, so that the gray contrast value is compared with the stepping positionThe value is compared with the currently acquired grey scale contrast value to find how the motor movement should be controlled to optimize the quality of the picture obtained from the current shot.
The method for focusing the target needing to be shot at present specifically comprises the following steps: firstly, determining the gray contrast value of one position where the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step appear inflection points as a first threshold, determining the gray contrast value of one position where the gray contrast values of the positions corresponding to the three continuous steps in the second focusing step appear inflection points as a second threshold, and taking the maximum gray contrast value of the position where the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step appear inflection points as the gray contrast value of a focus, wherein the gray contrast value of the focus is greater than the second threshold, and the second threshold is greater than the first threshold; acquiring a gray contrast value of a current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of a focus, executing a step of selecting a third focusing step so as to obtain accurate focusing for shooting a current target; if the current gray contrast value is larger than the first threshold value and smaller than the second threshold value, executing the step of selecting the second focusing step, and similarly, after the step of executing the second focusing step is finished, continuing to execute the step of performing the third independent angle step for the accuracy of focusing, so that the determined focusing focus is more accurate; if the current grey contrast value is less than the first threshold value, a step of selecting the first focus step is performed, which is similar to the above-described case and will not be described again here.
It should be noted that, in the terminal, the speed of the motor movement is controlled according to the distance between two adjacent steps. In order to reduce the disturbances caused by inertia and by the oscillation of the motor itself, the speed of the motor is also varied during the above-described determination of the gray contrast value for each focus step. For example, for the determination of the position gray contrast value for the first focus step, the scanning speed is x1For the determination of the position gray contrast value for the second focus step, the scanning speed isx2For the determination of the position gray contrast value for the third focus step, the scanning speed is x3(ii) a Wherein the following conditions exist: x is the number of1=x2k1=x3k2,0<k2<k1<1。
For example, the following detailed description explains a method for automatically completing multiple focusing in the present embodiment, as shown in fig. 4, which is a detailed flowchart of an automatic multiple focusing method provided by an embodiment of the present invention, please refer to fig. 4 and 5,
s401: reading the fuzzy diameter of an image sensor, the aperture of a lens, the stroke of a motor and the oscillation frequency and the oscillation time when the motor drives the lens to move, wherein the fuzzy diameter is written in a memory of the terminal;
s402: calculating the corresponding object distance range of each step of the motor after moving according to the fuzzy diameter, the aperture of the lens, the stroke of the motor and the oscillation frequency and the oscillation time when the motor drives the lens to move;
s403: comparing the object distance ranges of the positions of the adjacent steps, eliminating the object distance ranges in the steps contained in the object distance ranges of other steps to obtain the steps left after elimination, and setting the position corresponding to the step as Xi
S404: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000111
when n is2>When i is, An=XiAnd the step left after the elimination is used as a first focusing step; focusing positions corresponding to the first focusing steps from near to far respectively, when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing steps, selecting the position corresponding to the two steps with larger gray contrast values in the positions corresponding to the three continuous steps as a focus range, and selecting the gray contrast value of the position corresponding to the larger step as a first threshold value Y1;
s405: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000121
when 3N is less than or equal to NAWhen, Bn=X1When the gray contrast values of the positions corresponding to the three continuous steps in the second focusing step have inflection points, selecting the position corresponding to the two steps with larger gray contrast values in the positions corresponding to the three continuous steps as a focus range, and selecting the gray contrast value of one position corresponding to the larger step as a second threshold value Y2;
s406: selecting a composition that satisfies the following formula:
Figure GDA0002519149920000122
taking the rest steps after the elimination as third focusing steps, respectively focusing positions corresponding to the third focusing steps from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing steps, selecting the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps as a focusing focus, and taking the gray contrast value corresponding to the focus as Yf to finish focusing;
s407: after t ms, acquiring a gray contrast value Y of the current focusing window;
s408: judging whether Y2< Y1< Yf is met, if yes, turning to S406; if not, turning to S409;
s409: judging whether Y1< Y1< Y2 is met, if yes, turning to S405; if not, go to S404.
The embodiment realizes the possibility of continuous focusing, can quickly and accurately realize focusing, improves the imaging quality, saves the focusing time and improves the user experience.
Example two:
as shown in fig. 6, which is a schematic structural diagram of an auto-focusing apparatus according to a second embodiment of the present invention, please refer to fig. 6, wherein the auto-focusing apparatus 60 includes: a parameter obtaining module 601, an object distance range calculating module 602, a stepping eliminating module 603, a gray scale contrast obtaining module 604 and a focus determining module 605; the parameter obtaining module 601 is configured to obtain a blur diameter value of an image sensor in the terminal, an aperture value of a lens, and a motion parameter of a motor; the object distance range calculation module 602 is configured to calculate an object distance range of each step of the motor according to the blur diameter value, an aperture value of the lens, and a motion parameter of the motor; the step elimination module 603 is configured to eliminate steps whose object distance ranges are within the object distance ranges of other steps in the step; the gray contrast obtaining module 604 is configured to obtain a gray contrast value of each step corresponding to the removed step; the focus determining module 605 is configured to determine a step position from the remaining steps after the elimination according to the gray contrast value as a focus for focusing. In the embodiment, the repeated steps in the object distance range with other steps are eliminated, so that the moving times of the motor are reduced, the imaging quality is not reduced, the possibility of quick focusing can be achieved, and the use experience of a user is improved.
In an embodiment, the focus determination module 605 includes: a first focus step selection submodule for selecting a focus step that satisfies the following formula:
Figure GDA0002519149920000131
when n is2>When i is, An=XiAnd the step left after the elimination is used as a first focusing step; the first focus determining submodule is used for pushing a focusing window to focus on the position corresponding to the first focusing step from near to far by controlling the motor to move, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focus step, i and n are positive integers.
Further, the focus determination module 605 further comprises: second focusing step selectionThe selecting module is used for selecting the gray contrast values at the positions corresponding to the three continuous steps in the first focusing step to meet the following formula after inflection points appear in the gray contrast values at the positions corresponding to the three continuous steps:
Figure GDA0002519149920000132
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; the second focus determining submodule is used for pushing a focusing window to focus on the position corresponding to the second focusing step from far to near by controlling the motor to move, and when inflection points appear in the gray contrast values of the positions corresponding to three continuous steps in the second focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnA second focus step;
preferably, the focus determination module 605 further comprises: a third focusing step selection submodule, configured to select a gray contrast value at a position corresponding to three consecutive steps in the second focusing step, which satisfies:
Figure GDA0002519149920000141
the step left after the elimination is used as a third focusing step; the third focus determining submodule is used for pushing a focusing window to focus on the third focusing step from near to far through the movement of a motor, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBA number for a determined closest one of the second focus steps;
the auto-focusing apparatus 60 further includes: a threshold determination module, configured to determine, as a first threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the first focus step have inflection points, and determine, as a second threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the second focus step have inflection points, where the grayscale contrast value of the focus is greater than the second threshold, and the second threshold is greater than the first threshold; the processing module is used for acquiring the gray contrast value of the current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of the focus, a trigger starting instruction is sent to the third focusing step selection submodule; if the current gray scale contrast value is larger than a first threshold value and smaller than a second threshold value, sending a trigger starting instruction to the second focus stepping selection submodule; and if the current gray contrast value is smaller than a first threshold value, sending a trigger starting instruction to the first focusing stepping selection submodule.
The invention provides an automatic focusing method and device, wherein the step elimination of a step object distance range in other step object distance ranges is performed, and the gray contrast value of each step corresponding position left after the elimination is obtained; and determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus. This scheme is through rejecting in the step-by-step of other marching step-by-step object distance within ranges for can not coincide between the step-by-step object distance scope that newly obtains, reduced the number of times that the motor removed, and the step-by-step distance of the removal of motor has also changed, thereby has realized quick auto focus, can not influence its imaging quality yet, has promoted user experience.
The foregoing is a more detailed description of the present invention that is presented in conjunction with specific embodiments, and the practice of the invention is not to be considered limited to those descriptions. For those skilled in the art to which the invention pertains, several simple deductions or substitutions can be made without departing from the spirit of the invention, and all shall be considered as belonging to the protection scope of the invention.

Claims (9)

1. An auto-focusing method, comprising the steps of:
acquiring a fuzzy diameter value of an image sensor of a terminal, an aperture value of a lens and a motion parameter of a motor;
calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor;
eliminating the steps of which the object distance range is within the object distance range of other steps in the steps;
acquiring gray contrast values of corresponding positions of all steps left after elimination;
determining a stepping position from the steps left after the elimination according to the gray contrast value to be used as a focusing focus; the step of determining a step position from the rest steps according to the gray contrast value as a focusing focus comprises: selecting a composition that satisfies the following formula:
Figure FDA0002835744040000011
when n is2When > i, An=XiAnd the step left after the elimination is used as a first focusing step; the motor is controlled to move to push a focusing window to focus on the positions corresponding to the first focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focus step, i and n are positive integers.
2. The method of claim 1, wherein when the inflection point occurs in the gray contrast values at the position corresponding to three consecutive steps in the first focus step further comprises: selecting a composition that satisfies the following formula:
Figure FDA0002835744040000012
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; the motor is controlled to move to push the focusing window to focus on the position corresponding to the second focusing step from far to near, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the second focusing step, any position corresponding to the two steps with the larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnFor a second focus step.
3. The method of claim 2, wherein when the gray contrast values at the positions corresponding to three consecutive steps in the second focus step have inflection points, the method further comprises: selecting to satisfy:
Figure FDA0002835744040000021
the step left after the elimination is used as a third focusing step; the motor moves to push a focusing window to focus the third focusing step from near to far, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBThe number of the determined closest step of the second focus steps.
4. The auto-focusing method according to claim 3, wherein the gray contrast value of one of the positions corresponding to the consecutive three steps in the first focus step where the inflection point appears is determined as a first threshold, and the gray contrast value of one of the positions corresponding to the consecutive three steps in the second focus step where the inflection point appears is determined as a second threshold, the gray contrast value of the focus being greater than the second threshold, and the second threshold being greater than the first threshold; acquiring a gray contrast value of a current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of a focus, executing a step of selecting a third focusing step; if the current gray contrast value is larger than the first threshold value and smaller than the second threshold value, executing a step of selecting a second focus step; the step of selecting the first focus step is performed if the current grey contrast value is smaller than a first threshold value.
5. The method of auto-focusing according to any one of claims 1 to 4, wherein the speed of the motor movement is controlled according to the distance between two adjacent steps.
6. An autofocus device, comprising:
the parameter acquisition module is used for acquiring a fuzzy diameter value of an image sensor in the terminal, an aperture value of a lens and a motion parameter of a motor;
the object distance range calculation module is used for calculating the object distance range of each step of the motor according to the fuzzy diameter value, the aperture value of the lens and the motion parameter of the motor;
the stepping eliminating module is used for eliminating steps of which the object distance range is within the object distance range of other steps in the stepping process;
the gray contrast acquisition module is used for acquiring the gray contrast value of the corresponding position of each step left after the elimination;
the focus determining module is used for determining a stepping position from the remaining steps after the elimination according to the gray contrast value to be used as a focusing focus; the focus determination module includes: a first focus step selection submodule for selecting a focus step that satisfies the following formula:
Figure FDA0002835744040000031
when n is2When > i, An=XiAnd the step left after the elimination is used as a first focusing step; the first focus determining submodule is used for pushing a focusing window to focus on the position corresponding to the first focusing step from near to far by controlling the motor to move, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the first focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; xiFor the rest of the step, AnFor the first focus step, i and n are positive integers.
7. The autofocus apparatus of claim 6, wherein the focus determination module further comprises: the second focusing step selection submodule is used for selecting the gray contrast values at the positions corresponding to three continuous steps in the first focusing step to meet the following formula after inflection points appear in the gray contrast values:
Figure FDA0002835744040000032
when 3N is less than or equal to NAWhen, Bn=X1And the step left after the elimination is used as a second focusing step; the second focus determining submodule is used for pushing a focusing window to focus on the position corresponding to the second focusing step from far to near by controlling the motor to move, and when inflection points appear in the gray contrast values of the positions corresponding to three continuous steps in the second focusing step, any position corresponding to two steps with larger gray contrast values in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; n is a radical ofANumber of the farthest step determined in the first focusing step, BnFor a second focus step.
8. The autofocus apparatus of claim 7, wherein the focus determination module further comprises: a third focusing step selection submodule, configured to select a gray contrast value at a position corresponding to three consecutive steps in the second focusing step, which satisfies:
Figure FDA0002835744040000033
the step left after the elimination is used as a third focusing step; the third focus determining submodule is used for pushing a focusing window to focus on the third focusing step from near to far through the movement of a motor, and when inflection points appear in the gray contrast values of the positions corresponding to the three continuous steps in the third focusing step, the position corresponding to the step with the largest gray contrast value in the positions corresponding to the three continuous steps is selected as a focusing focus; otherwise, selecting the position corresponding to the step with the maximum gray contrast value as a focusing focus; cnFor the third focusing step, NBThe number of the determined closest step of the second focus steps.
9. The autofocus apparatus of claim 8, further comprising: a threshold determination module, configured to determine, as a first threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the first focus step have inflection points, and determine, as a second threshold, a grayscale contrast value of one of the positions where the grayscale contrast values of the positions corresponding to three consecutive steps in the second focus step have inflection points, where the grayscale contrast value of the focus is greater than the second threshold, and the second threshold is greater than the first threshold; the processing module is used for acquiring the gray contrast value of the current focusing window, and if the current gray contrast value is larger than a second threshold value and smaller than the gray contrast value of the focus, a trigger starting instruction is sent to the third focusing step selection submodule; if the current gray scale contrast value is larger than a first threshold value and smaller than a second threshold value, sending a trigger starting instruction to the second focus stepping selection submodule; and if the current gray contrast value is smaller than a first threshold value, sending a trigger starting instruction to the first focusing stepping selection submodule.
CN201510160558.0A 2015-04-07 2015-04-07 Automatic focusing method and device Active CN106154688B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201510160558.0A CN106154688B (en) 2015-04-07 2015-04-07 Automatic focusing method and device
PCT/CN2015/086686 WO2016161734A1 (en) 2015-04-07 2015-08-11 Autofocusing method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201510160558.0A CN106154688B (en) 2015-04-07 2015-04-07 Automatic focusing method and device

Publications (2)

Publication Number Publication Date
CN106154688A CN106154688A (en) 2016-11-23
CN106154688B true CN106154688B (en) 2021-04-16

Family

ID=57071784

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201510160558.0A Active CN106154688B (en) 2015-04-07 2015-04-07 Automatic focusing method and device

Country Status (2)

Country Link
CN (1) CN106154688B (en)
WO (1) WO2016161734A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108234876B (en) * 2018-01-22 2020-10-16 努比亚技术有限公司 Tracking focusing method, terminal and computer readable storage medium
CN109087354A (en) * 2018-08-29 2018-12-25 浙江霖研精密科技有限公司 A kind of position algorithm of the best object distance of automatic search and image distance
CN109307970A (en) * 2018-11-22 2019-02-05 成都市鹰诺实业有限公司 A kind of automatic focusing method of camera
WO2021102959A1 (en) * 2019-11-29 2021-06-03 深圳市大疆创新科技有限公司 Focus adjustment method, camera module, and computer readable storage medium
CN111654637B (en) * 2020-07-14 2021-10-22 RealMe重庆移动通信有限公司 Focusing method, focusing device and terminal equipment

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104038666A (en) * 2014-04-22 2014-09-10 深圳英飞拓科技股份有限公司 Video shielding detection method and video shielding detection device
CN104103063A (en) * 2013-04-10 2014-10-15 江南大学 No-reference noise image quality evaluation method based on automatic focusing principle
CN104459940A (en) * 2013-09-25 2015-03-25 北京环境特性研究所 Quick self-adaptation automatic focusing method

Family Cites Families (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2002122776A (en) * 2000-10-17 2002-04-26 Sharp Corp Autofocus controller, digital still camera and digital video camera equipped with the same, autofocus control method and recording medium having autofocus control program recorded thereon
JP3902492B2 (en) * 2002-03-13 2007-04-04 株式会社リコー Imaging device
JP2003315665A (en) * 2002-04-23 2003-11-06 Nikon Gijutsu Kobo:Kk Camera
CN100357822C (en) * 2002-05-31 2007-12-26 金宝电子工业股份有限公司 Automatic focusing method cooperated with depth of field
CN100424579C (en) * 2004-03-08 2008-10-08 普立尔科技股份有限公司 Quick focusing method for digital camera
JP2007025381A (en) * 2005-07-19 2007-02-01 Alps Electric Co Ltd Optical device
JP2007148249A (en) * 2005-11-30 2007-06-14 Canon Inc Automatic focusing device
CN100407038C (en) * 2005-12-19 2008-07-30 佛山普立华科技有限公司 Automatic focusing method for digit imaging system
CN101071251B (en) * 2006-05-11 2010-09-22 致伸科技股份有限公司 Method for estimating automatic focusing least effective sampling points
CN101995640A (en) * 2010-09-30 2011-03-30 镇江中信科技开发有限公司 Coarse adjustment and fine adjustment combined rapid interpolation focus exploration algorithm
US9030595B2 (en) * 2010-10-14 2015-05-12 Lensvector Inc. In-flight auto focus method and system for tunable liquid crystal optical element
US9160917B2 (en) * 2013-07-09 2015-10-13 Htc Corporation Handheld electronic apparatus and image capturing apparatus and focusing method thereof
JP5868109B2 (en) * 2011-10-12 2016-02-24 キヤノン株式会社 Optical apparatus, lens barrel, and automatic focusing method
CN103513395B (en) * 2012-06-15 2018-05-04 中兴通讯股份有限公司 A kind of passive auto-focusing method and device
CN103728813B (en) * 2012-10-15 2016-10-26 浙江大华技术股份有限公司 A kind of method of synchronizing focus during zoom
CN103945126B (en) * 2014-04-21 2015-03-04 中国人民解放军国防科学技术大学 Automatic focusing and locating method

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104103063A (en) * 2013-04-10 2014-10-15 江南大学 No-reference noise image quality evaluation method based on automatic focusing principle
CN104459940A (en) * 2013-09-25 2015-03-25 北京环境特性研究所 Quick self-adaptation automatic focusing method
CN104038666A (en) * 2014-04-22 2014-09-10 深圳英飞拓科技股份有限公司 Video shielding detection method and video shielding detection device

Also Published As

Publication number Publication date
WO2016161734A1 (en) 2016-10-13
CN106154688A (en) 2016-11-23

Similar Documents

Publication Publication Date Title
CN106154688B (en) Automatic focusing method and device
US10129455B2 (en) Auto-focus method and apparatus and electronic device
CN107395993B (en) Full-automatic focusing method and system
WO2019105214A1 (en) Image blurring method and apparatus, mobile terminal and storage medium
TWI538512B (en) Method for adjusting focus position and electronic apparatus
TWI471677B (en) Auto focus method and auto focus apparatus
TWI511081B (en) Image capturing device and method for calibrating image deformation thereof
TWI515470B (en) Auto-focus system for multiple lens and method thereof
WO2017167116A1 (en) Automatic-focus method and automatic-focus device
JP5453573B2 (en) Imaging apparatus, imaging method, and program
CN107465877B (en) Track focusing method and device and related media production
CN107800951B (en) Electronic device and lens switching method thereof
CN106031148B (en) Imaging device, method of auto-focusing in an imaging device and corresponding computer program
CN108702457B (en) Method, apparatus and computer-readable storage medium for automatic image correction
CN104102068A (en) Automatic focusing method and automatic focusing device
CN107534723B (en) Automatic focusing method, device and equipment
CN114339042A (en) Image processing method and device based on multiple cameras and computer readable storage medium
TWI515471B (en) Auto-focus system for multiple lens and method thereof
EP3218756B1 (en) Direction aware autofocus
CN109698902B (en) Synchronous focusing method and device
JP2013195577A (en) Imaging device, imaging method, and program
US9300861B2 (en) Video recording apparatus and focusing method for the same
US10051173B2 (en) Image pick-up apparatus and progressive auto-focus method thereof
CN116233605B (en) Focusing implementation method and device, storage medium and image pickup equipment
CN113191349B (en) Control method and device for focusing motor, storage medium and electronic device

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant