CN112601015B - Automatic focusing method and automatic focusing system - Google Patents

Automatic focusing method and automatic focusing system Download PDF

Info

Publication number
CN112601015B
CN112601015B CN202011434865.0A CN202011434865A CN112601015B CN 112601015 B CN112601015 B CN 112601015B CN 202011434865 A CN202011434865 A CN 202011434865A CN 112601015 B CN112601015 B CN 112601015B
Authority
CN
China
Prior art keywords
value
image evaluation
evaluation value
motor
evaluation function
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
CN202011434865.0A
Other languages
Chinese (zh)
Other versions
CN112601015A (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.)
Iray Technology Co Ltd
Original Assignee
Iray Technology Co Ltd
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 Iray Technology Co Ltd filed Critical Iray Technology Co Ltd
Priority to CN202011434865.0A priority Critical patent/CN112601015B/en
Publication of CN112601015A publication Critical patent/CN112601015A/en
Application granted granted Critical
Publication of CN112601015B publication Critical patent/CN112601015B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/60Control of cameras or camera modules
    • H04N23/67Focus control based on electronic image sensor signals
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04NPICTORIAL COMMUNICATION, e.g. TELEVISION
    • H04N23/00Cameras or camera modules comprising electronic image sensors; Control thereof
    • H04N23/80Camera processing pipelines; Components thereof

Abstract

The invention discloses an automatic focusing method and an automatic focusing system, wherein the automatic focusing method comprises the following steps: s1: acquiring an initial position of a motor of a lens; s2: selecting an initial moving direction of the motor, and enabling the motor to move along the initial moving direction according to a preset step length; s3: acquiring a scene image, carrying out focusing operation, acquiring a definition evaluation function for evaluating the scene image, and terminating the focusing operation if the definition evaluation function has a trend of increasing gradually and then decreasing gradually and the increasing and decreasing times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the motor is switched to continue moving until a termination condition or a turning condition is achieved, and the focusing operation is terminated; s4: and controlling the motor to move to the position with the maximum value of the definition evaluation function. The method can focus at any position of the whole lens stroke, effectively shorten the focusing time, cross the fluctuation point and ensure the optimal focusing position.

Description

Automatic focusing method and automatic focusing system
Technical Field
The present invention relates to the field of lens devices, and more particularly, to an auto-focusing method. Furthermore, an autofocus system for carrying out the above autofocus method is also described.
Background
In the prior art, for an auto-focusing strategy of a lens with a long stroke, generally used methods are as follows: a whole-course searching and positioning method, a shot one-by-one calibration method and the like. The method for searching and positioning in the whole process is to search the whole stroke of the motor, find the optimal position in the stroke and move the optimal position to the position, but the method has the problems of long time consumption, poor experience, inaccurate positioning and the like. The method for calibrating the lenses one by one refers to the steps of manually observing the image definition, calibrating the searching range of the lenses, and then searching and positioning in the calibrating range.
In summary, how to improve the adaptability and speed of the lens focusing operation is a problem to be solved by those skilled in the art.
Disclosure of Invention
In view of the above, an object of the present invention is to provide an automatic focusing method, which can effectively improve the adaptability and speed of the focusing operation of the lens, that is, the method can realize the focusing operation at any position in the whole lens stroke, effectively shorten the focusing time, and ensure the best definition of the focusing position.
It is another object of the present invention to provide a focusing apparatus suitable for use in the above-mentioned auto-focusing method.
In order to achieve the above purpose, the invention provides the following technical scheme:
an auto-focusing method, comprising:
step S1: acquiring an initial position of a motor of a lens;
step S2: selecting an initial moving direction of the motor according to the initial position, and enabling the motor to move along the initial moving direction according to a preset step length;
step S3: in the moving process, a scene image is obtained, focusing operation is carried out, a definition evaluation function for evaluating the definition of the scene image is obtained, and if the definition evaluation function is in a trend of increasing in advance and then decreasing in decline and the increasing and decreasing times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the motor is switched to continue moving until a termination condition or a turning condition is achieved, and the focusing operation is terminated;
step S4: and controlling the motor to move to the position with the maximum value of the definition evaluation function.
Preferably, the step S1 includes: and acquiring the minimum position and the maximum position of the potentiometer value of the motor according to the structure of the lens, and acquiring the increasing and decreasing relation between the rotation direction of the motor and the potentiometer value.
Preferably, the step S2 includes: judging whether the distance between the initial position and the minimum potentiometer value position is smaller than the distance between the initial position and the maximum potentiometer value position; if so, controlling the motor to move towards the maximum potentiometer value position; and if not, controlling the motor to move towards the position with the minimum potentiometer value.
Preferably, the step S3 includes:
step S31: in the moving process, acquiring the scene image, carrying out focusing operation, and acquiring and recording an image evaluation value of the definition evaluation function;
step S32: comparing the current image evaluation value with the recorded maximum image evaluation value, if the current image evaluation value is larger than the recorded maximum image evaluation value, updating the maximum image evaluation value, and setting the position of the updated maximum image evaluation value as the best focusing position; if the current image evaluation value is smaller than the recorded maximum image evaluation value, the process proceeds to step S33;
step S33: comparing the current image evaluation value with the recorded minimum image evaluation value, and updating the minimum image evaluation value if the current image evaluation value is smaller than the recorded minimum image evaluation value; if the current image evaluation value is greater than the recorded minimum image evaluation value, the process proceeds to step S34;
step S34: comparing the current image evaluation value with the last recorded image evaluation value, if the current image evaluation value is greater than the last recorded image evaluation value, accumulating the continuous increasing times and clearing the continuous decreasing times, and returning to execute the step S31; if the current image evaluation value is smaller than the last recorded image evaluation value, the process proceeds to step S35;
step S35: accumulating the continuous reduction times, and calculating the probability value of the current position as the interference point;
step S36: comparing the probability value with a probability threshold, and accumulating termination condition counts if the probability value is less than or equal to the probability threshold; clearing the termination condition count if the probability value is greater than the probability threshold;
step S37: judging whether the termination condition count is greater than or equal to a first value, judging whether the continuous reduction times are greater than or equal to a second value, and if one of the two values is positive, entering step S38; if not, returning to execute the step S31;
step S38: judging whether the continuous increasing times is larger than or equal to the difference value between the second value and the first value, if so, entering the step S4; if not, go to step S39;
step S39: judging whether the motor is rotated to the end of the stroke or whether the number of times of circulating operation reaches a circulating threshold value, if so, entering a step S4; if not, the rotation direction of the motor is reversed, the step length is initialized, and the step S31 is executed in a returning mode.
Preferably, in step S3, if the sharpness evaluation function presents an increasing trend, the step size of the motor is decreased; and if the definition evaluation function is in a decreasing trend, increasing the step length of the motor.
Preferably, the step S4 includes: after the focusing operation is terminated, the motor is rotated to the scanned optimal position, and the final positioning direction of the motor is consistent with the direction of the scanned optimal position.
An auto-focus system comprising:
the moving device is used for driving the lens to move and focus;
position acquisition means for acquiring an initial position of the mobile device;
a sharpness calculation device for acquiring a sharpness evaluation function for evaluating sharpness of the scene image acquired by the lens;
the controller is used for selecting the initial moving direction of the moving device according to the initial position and enabling the moving device to move along the initial moving direction according to a preset step length; the sharpness evaluation function is used for acquiring the sharpness evaluation function of the sharpness calculation device, and if the sharpness evaluation function is in a trend of increasing gradually and then decreasing gradually, and the increasing and decreasing times of the sharpness evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the mobile device is converted to continue moving until a new termination condition or a turning condition is achieved, and the focusing operation is terminated; and for controlling the moving means to move to a position where the value of the sharpness evaluation function is maximum after the focusing operation is terminated.
Preferably, the position acquiring means is configured to acquire a potentiometer value minimum position and a potentiometer value maximum position of the mobile device, and acquire an increasing/decreasing relationship between a rotation direction of the mobile device and a potentiometer value.
Preferably, the controller includes a judging module, and the judging module is configured to judge whether a distance between the initial position and the minimum potentiometer value position is smaller than a distance between the initial position and the maximum potentiometer value position; if so, controlling the mobile device to move towards the maximum potentiometer value position; if not, controlling the moving device to move towards the position with the minimum potentiometer value.
It should be noted that, the number of loop operations is accumulated every time the loop operation is performed, so as to determine whether the number of loop operations reaches the loop threshold.
Compared with the prior art, the automatic focusing method provided by the invention can realize the focusing operation at any position in the whole lens stroke by controlling the motor to move for focusing operation, overcomes the problem that the position outside the calibration range in the method for calibrating the lens one by one cannot be focused, and can effectively shorten the focusing time by adjusting the focusing operation in real time according to the definition evaluation function of a scene image when the method is used for focusing operation without searching the whole stroke of the motor. In addition, the invention utilizes the definition evaluation function of the lens image as the basis for selecting the focusing position, thereby effectively ensuring the best definition of the focusing position.
And when the definition evaluation function is in a trend of increasing first and then decreasing, and the increasing and decreasing times of the definition evaluation function meet the preset conditions, the termination condition is achieved, and the focusing operation is terminated, so that the fluctuation point can be effectively crossed, and the local optimum is avoided.
In summary, the auto-focusing method provided by the present invention can effectively improve the adaptability and speed of the lens focusing operation, that is, the method can realize the focusing operation at any position in the whole lens stroke, can effectively shorten the focusing time, and can cross the fluctuation point, avoid falling into the local optimum condition, and is favorable for ensuring the definition of the final focusing position to be optimal.
In addition, the invention also provides an automatic focusing system for implementing the automatic focusing method.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the provided drawings without creative efforts.
FIG. 1 is a flow chart illustrating an auto-focusing method according to the present invention;
fig. 2 is a flowchart of step S3.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
The core of the invention is to provide an automatic focusing method, which can effectively improve the adaptability and speed of the focusing operation of the lens, namely the method can realize the focusing operation of any position in the whole lens stroke, can effectively shorten the focusing time, can cross the fluctuation point, avoid falling into the condition of local optimum, and is beneficial to ensuring the definition of the final focusing position to be optimal.
Another core of the present invention is to provide an auto-focusing system for implementing the above auto-focusing method.
Referring to fig. 1 and fig. 2, fig. 1 is a schematic flow chart of an auto-focusing method according to the present invention; fig. 2 is a flowchart of step S3.
The present embodiment provides an auto-focusing method, including:
step S1: acquiring an initial position of a motor of a lens;
step S2: selecting the initial moving direction of the motor according to the initial position, and enabling the motor to move along the initial moving direction according to a preset step length;
step S3: in the moving process, acquiring a scene image and carrying out focusing operation, acquiring a definition evaluation function for evaluating the definition of the scene image, and if the definition evaluation function is in a trend of increasing gradually and then decreasing gradually and the increasing and decreasing times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved, terminating the focusing operation; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the motor is switched to continue moving until a termination condition or a turning condition is achieved, and the focusing operation is terminated;
step S4: and controlling the motor to move to the position with the maximum value of the definition evaluation function.
Compared with the prior art, the automatic focusing method provided by the invention can realize the focusing operation at any position in the whole lens stroke by controlling the motor to move for focusing operation, overcomes the problem that the position outside the calibration range in the method for calibrating the lens one by one cannot be focused, and can effectively shorten the focusing time by adjusting the focusing operation in real time according to the definition evaluation function of a scene image when the method is used for focusing operation without searching the whole stroke of the motor. In addition, the invention utilizes the definition evaluation function of the lens image as the basis for selecting the focusing position, thereby effectively ensuring the best definition of the focusing position.
And when the definition evaluation function is in a trend of increasing and decreasing first and then decreasing, and the increasing and decreasing times of the definition evaluation function meet the preset conditions, the termination condition is reached, and the focusing operation is terminated, so that the fluctuation point can be effectively crossed, and the local optimum is avoided.
It should be noted that step S3 includes the following cases, if the sharpness evaluation function only shows an increasing trend, indicating that the sharpness is higher and higher, the motor may be moved in the moving direction until the end of the stroke of the motor is reached, and then the focusing operation is terminated.
If the definition evaluation function decreases gradually and then increases gradually, the adjustment is needed according to the decreasing amplitude, if the decreasing amplitude is larger, the movement direction of the motor can be converted and then the motor continues to move, and the focusing operation is terminated until a termination condition or a turning-around condition is achieved; if the decreasing amplitude is smaller, the step length of the motor can be adjusted, and the motor is continuously moved along the moving direction until a termination condition or a U-turn condition is achieved, and the focusing operation is terminated.
In summary, the auto-focusing method provided by the present invention can effectively improve the adaptability and speed of the lens focusing operation, that is, the method can realize the focusing operation at any position in the whole lens stroke, can effectively shorten the focusing time, and can cross the fluctuation point, avoid falling into the local optimum condition, and is favorable for ensuring the definition of the final focusing position to be optimal.
On the basis of the above embodiment, preferably, step S1 includes: and acquiring the minimum position and the maximum position of the potentiometer value of the motor according to the structure of the lens, and acquiring the increasing and decreasing relation between the rotation direction of the motor and the potentiometer value.
The lens structure acquires the minimum potentiometer value position and the maximum potentiometer value position of the motor, and acquires the increasing and decreasing relation between the motor rotation direction and the potentiometer value. The purpose is to effectively judge the position of the lens in the initial state and obtain the moving effect when the motor rotates in the forward direction and in the reverse direction, for example, when the motor rotates in the forward direction, the potentiometer value is increased or decreased, and then the moving operation of the motor is conveniently adjusted according to the increasing and decreasing relation.
Preferably, step S2 includes: judging whether the distance between the initial position and the minimum potentiometer value position is smaller than the distance between the initial position and the maximum potentiometer value position; if yes, controlling the motor to move towards the position with the maximum potentiometer value; if not, the motor is controlled to move towards the position with the minimum potentiometer value.
That is, after the current motor position is obtained, the motor rotation direction is determined according to the motor position, when the initial position of the motor is closer to the minimum position of the potentiometer value, the motor is controlled to move towards the direction of the maximum position of the potentiometer value, otherwise, the motor moves towards the direction of the minimum position of the potentiometer value, so that the motor can move towards the middle position of the potentiometer, the motor moves towards the direction of a larger stroke, and the best position for focusing is easier to scan.
It should be noted that, after steps S1 and S2 are finished, the search for the best position of focus may be started during the movement of the motor, that is, the best position may be obtained by acquiring and determining the sharpness evaluation function of the lens image. However, the focusing operation is stopped when the motor position reaches the end of the stroke or the number of cycles has exceeded the cycle threshold.
Preferably, step S3 includes:
step S31: in the moving process, acquiring a scene image, carrying out focusing operation, collecting and recording an image evaluation value of a definition evaluation function;
step S32: comparing the current image evaluation value with the recorded maximum image evaluation value, if the current image evaluation value is larger than the recorded maximum image evaluation value, updating the maximum image evaluation value, and setting the position of the updated maximum image evaluation value as the best focusing position; if the current image evaluation value is smaller than the recorded maximum image evaluation value, the process proceeds to step S33;
step S33: comparing the current image evaluation value with the recorded minimum image evaluation value, and updating the minimum image evaluation value if the current image evaluation value is smaller than the recorded minimum image evaluation value; if the current image evaluation value is greater than the recorded minimum image evaluation value, the process proceeds to step S34;
step S34: comparing the current image evaluation value with the last recorded image evaluation value, if the current image evaluation value is greater than the last recorded image evaluation value, accumulating the continuous increasing times and clearing the continuous decreasing times, and returning to execute the step S31; if the current image evaluation value is smaller than the last recorded image evaluation value, the process proceeds to step S35;
step S35: accumulating the continuous reduction times, and calculating the probability value of the current position as the interference point;
step S36: comparing the probability value with a probability threshold, and accumulating the termination condition counts if the probability value is less than or equal to the probability threshold; if the probability value is larger than the probability threshold value, clearing the termination condition count;
step S37: judging whether the end condition count is greater than or equal to a first value, judging whether the continuous reduction times are greater than or equal to a second value, and if one of the two values is positive, entering step S38; if not, returning to execute the step S31;
step S38: judging whether the continuous increasing times is larger than or equal to the difference value between the second value and the first value, if so, entering the step S4; if not, go to step S39;
step S39: judging whether the motor is rotated to the end of the stroke or whether the number of circulating operations reaches a circulating threshold value, if so, entering a step S4; if not, the rotation direction of the motor is reversed, the step length is initialized, and the step S31 is executed again.
Preferably, in step S3, if the sharpness evaluation function exhibits an increasing trend, the step size of the motor may be decreased; if the definition evaluation function is in a decreasing trend, the step length of the motor can be increased so as to improve the efficiency of the process of searching the best position of focusing and shorten the time for searching the best position of focusing. When the step length of the motor is adjusted, it is required to ensure that the minimum step number is not less than the initial step number value.
Note that, in step S35, the probability value of the interference point is calculated, and the probability value is expressed by p ═ f (deltaS/T), where T ═ maxS-minS +1, maxS is the maximum image evaluation value, minS is the minimum image evaluation value, and deltaS is the difference between the current image evaluation value and the last image evaluation value. If the probability value is smaller than the probability threshold value, accumulating the times of termination conditions; and if the probability value is greater than the probability threshold value, clearing the termination condition count so as to facilitate the next operation. By calculating the probability value of the interference point, some fluctuation points can be effectively eliminated, the situation of falling into local optimum is avoided, and the accuracy of the best focusing position is ensured.
Wherein, the steps S37, S38 and S39 are used to determine whether the end condition of searching the focus optimum position is achieved, that is, when the number of consecutive decreases or the end condition count is achieved, it is determined whether the number of consecutive increases is achieved: if so, terminating the whole process of searching the best focusing position; if not, the motor is rotated reversely, and the optimal focusing position is continuously searched until the next termination condition is reached or the loop of searching the optimal focusing position exits. Preferably, the first value may be set to 3, and the second value may be set to 7, that is, when the termination condition count is greater than or equal to 3 or the number of consecutive decreases is greater than or equal to 7, and the number of consecutive increases is greater than or equal to 4, the whole process of searching for the best position of focus may be terminated, and the motor may be rotated to the scanned best position.
The automatic focusing method provided by the invention can realize the focusing operation of any position in the whole lens stroke, overcomes the problem that the focusing operation cannot be carried out outside the calibration range in a manual calibration method, and can realize the focusing operation only by acquiring the stroke range once when the lens is adapted, so that the operation process is simpler, and the algorithm of the invention is relatively easy to realize without carrying out a large amount of calculation operations when calculating the definition function and carrying out cyclic judgment, can be realized in most embedded devices and is favorable for popularization and use.
The method improves the focusing method, can realize focusing operation without searching all strokes of the lens, and effectively shortens focusing time. Theoretically, the larger the lens stroke, the more significant the shortening of the focusing time. The focusing time is short near the clear point of the image, and the focusing time near the non-clear point does not exceed the time of searching and positioning in the whole process, so the method can effectively improve the focusing operation efficiency.
Preferably, based on the above embodiment, step S4 includes: after the focusing operation is terminated, the motor is rotated to the scanned optimum position, and the direction in which the motor is finally positioned coincides with the direction of the scanned optimum position. The optimum position is a position at which the image evaluation value of the sharpness evaluation function is maximum.
It should be noted that some lenses may cause a phenomenon that an optimal imaging position acquired by a motor from a forward direction is different from an optimal imaging position acquired from a reverse direction due to manufacturing errors of gear engagement or other structures. That is, when the motor rotates in the forward direction and in the reverse direction, the optimal imaging position obtained by the motor is different when the lens is at the same position.
Therefore, the direction of the final positioning of the motor of the present invention is consistent with the direction of the scanned optimal position, so as to effectively avoid the above problems. Namely: if the direction when the maximum position (optimal position) of the image evaluation value is obtained is the direction in which the potentiometer value is changed from small to large, the motor is firstly slid to a position smaller than the optimal position, then final positioning operation is carried out, and the motor is finally positioned to the optimal position from the position, so that the final positioning direction of the motor is ensured to be consistent with the direction of the scanned optimal position, and the problem of inaccurate positioning caused by structural errors of the lens is effectively solved.
It should be noted that the first value and the second value mentioned in the present application document are only for distinguishing the difference of the numerical values and are not sequentially divided.
In addition to the above-mentioned auto-focusing method, the present invention also provides an auto-focusing system comprising:
the moving device is used for driving the lens to move and focus;
position acquisition means for acquiring an initial position of the mobile device;
the definition calculating device is used for acquiring a definition evaluation function for evaluating the definition of the scene image acquired by the lens;
the controller is used for selecting the initial moving direction of the moving device according to the initial position and enabling the moving device to move along the initial moving direction according to a preset step length; the device is used for acquiring a definition evaluation function of the definition calculation device, and if the definition evaluation function is in a trend of increasing gradually and then decreasing gradually, and the increasing and decreasing times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the mobile device is converted to continue moving until a termination condition or a turning condition is achieved, and the focusing operation is terminated; and for controlling the moving means to move to a position where the value of the sharpness evaluation function is maximum after the focusing operation is terminated.
Preferably, the position acquiring means is configured to acquire a potentiometer value minimum position and a potentiometer value maximum position of the mobile device, and acquire an increasing/decreasing relationship between a rotation direction of the mobile device and the potentiometer value.
Preferably, the controller includes a judging module for judging whether a distance between the initial position and the minimum position of the potentiometer value is smaller than a distance between the initial position and the maximum position of the potentiometer value; if yes, controlling the moving device to move towards the position with the maximum potentiometer value; if not, the mobile device is controlled to move towards the position with the minimum potentiometer value.
For the structure of other parts of the focusing device, please refer to the prior art, and the description is omitted here.
The embodiments in the present description are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other. Any combination of all embodiments provided by the present invention is within the scope of the present invention, and details are not described herein.
The automatic focusing method and the automatic focusing system provided by the invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, without departing from the principle of the present invention, it is possible to make various improvements and modifications to the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (8)

1. An auto-focusing method, comprising:
step S1: acquiring an initial position of a motor of a lens;
step S2: selecting an initial moving direction of the motor according to the initial position, and enabling the motor to move along the initial moving direction according to a preset step length;
step S3: in the moving process, a scene image is obtained and focusing operation is carried out, a definition evaluation function for evaluating the definition of the scene image is obtained, if the definition evaluation function is in a trend of increasing gradually and then decreasing gradually, and the increasing and decreasing times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the motor is switched to continue moving until a termination condition or a turning condition is achieved, and the focusing operation is terminated;
step S4: controlling the motor to move to the position with the maximum value of the definition evaluation function;
the step S3 includes:
step S31: in the moving process, acquiring the scene image, carrying out focusing operation, and acquiring and recording an image evaluation value of the definition evaluation function;
step S32: comparing the current image evaluation value with the recorded maximum image evaluation value, if the current image evaluation value is larger than the recorded maximum image evaluation value, updating the maximum image evaluation value, and setting the position of the updated maximum image evaluation value as the best focusing position; if the current image evaluation value is smaller than the recorded maximum image evaluation value, the process proceeds to step S33;
step S33: comparing the current image evaluation value with the recorded minimum image evaluation value, and updating the minimum image evaluation value if the current image evaluation value is smaller than the recorded minimum image evaluation value; if the current image evaluation value is greater than the recorded minimum image evaluation value, the process proceeds to step S34;
step S34: comparing the current image evaluation value with the last recorded image evaluation value, if the current image evaluation value is greater than the last recorded image evaluation value, accumulating the continuous increase times, clearing the continuous decrease times, and returning to execute the step S31; if the current image evaluation value is smaller than the last recorded image evaluation value, the process proceeds to step S35;
step S35: accumulating the continuous reduction times, and calculating the probability value of the current position as the interference point;
step S36: comparing the probability value with a probability threshold, and accumulating termination condition counts if the probability value is less than or equal to the probability threshold; clearing the termination condition count if the probability value is greater than the probability threshold;
step S37: judging whether the termination condition count is greater than or equal to a first value, judging whether the continuous reduction times are greater than or equal to a second value, and if one of the two values is positive, entering step S38; if not, returning to execute the step S31;
step S38: judging whether the continuous increasing times is larger than or equal to the difference value between the second value and the first value, if so, entering the step S4; if not, go to step S39;
step S39: judging whether the motor is rotated to the end of the stroke or whether the number of times of circulating operation reaches a circulating threshold value, if so, entering a step S4; if not, the rotation direction of the motor is reversed, the step length is initialized, and the step S31 is executed in a returning mode.
2. The auto-focusing method according to claim 1, wherein the step S1 includes: and acquiring the minimum position and the maximum position of the potentiometer value of the motor according to the structure of the lens, and acquiring the increasing and decreasing relation between the rotation direction of the motor and the potentiometer value.
3. The auto-focusing method according to claim 2, wherein the step S2 includes: judging whether the distance between the initial position and the minimum potentiometer value position is smaller than the distance between the initial position and the maximum potentiometer value position; if so, controlling the motor to move towards the maximum potentiometer value position; and if not, controlling the motor to move towards the position with the minimum potentiometer value.
4. The auto-focusing method according to any one of claims 1 to 3, wherein in the step S3, if the sharpness evaluation function exhibits an increasing trend, the step size of the motor is decreased; and if the definition evaluation function is in a decreasing trend, increasing the step length of the motor.
5. The auto-focusing method according to claim 4, wherein the step S4 includes: after the focusing operation is terminated, the motor is rotated to the scanned optimal position, and the final positioning direction of the motor is consistent with the direction of the scanned optimal position.
6. An auto-focus system, comprising:
the moving device is used for driving the lens to move and focus;
position acquisition means for acquiring an initial position of the mobile device;
a sharpness calculation device for acquiring a sharpness evaluation function for evaluating sharpness of the scene image acquired by the lens;
the controller is used for selecting the initial moving direction of the moving device according to the initial position and enabling the moving device to move along the initial moving direction according to a preset step length; the sharpness evaluation function is used for acquiring the sharpness evaluation function of the sharpness calculation device, and if the sharpness evaluation function is in a trend of increasing gradually and then decreasing gradually, and the increasing and decreasing times of the sharpness evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the definition evaluation function only presents a descending trend and represents that the turning condition is achieved, the moving direction of the mobile device is converted to continue moving until a new termination condition or a turning condition is achieved, and the focusing operation is terminated; and for controlling the moving means to move to a position where the value of the sharpness evaluation function is maximum after the focusing operation is terminated;
the step of obtaining the definition evaluation function of the definition computing device, wherein if the definition evaluation function is in a trend of increasing gradually and then decreasing gradually, and the increase and decrease times of the definition evaluation function meet a preset condition, representing that a termination condition is achieved, the focusing operation is terminated; if the sharpness evaluation function only shows a descending trend, which represents that the turning condition is achieved, the moving direction of the mobile device is switched to continue moving until a new termination condition or turning condition is achieved, and the focusing operation is terminated, and the method comprises the following steps:
step S31: in the moving process, acquiring the scene image, carrying out focusing operation, and acquiring and recording an image evaluation value of the definition evaluation function;
step S32: comparing the current image evaluation value with the recorded maximum image evaluation value, if the current image evaluation value is larger than the recorded maximum image evaluation value, updating the maximum image evaluation value, and setting the position of the updated maximum image evaluation value as the best focusing position; if the current image evaluation value is smaller than the recorded maximum image evaluation value, the process proceeds to step S33;
step S33: comparing the current image evaluation value with the recorded minimum image evaluation value, and updating the minimum image evaluation value if the current image evaluation value is smaller than the recorded minimum image evaluation value; if the current image evaluation value is greater than the recorded minimum image evaluation value, the process proceeds to step S34;
step S34: comparing the current image evaluation value with the last recorded image evaluation value, if the current image evaluation value is greater than the last recorded image evaluation value, accumulating the continuous increasing times and clearing the continuous decreasing times, and returning to execute the step S31; if the current image evaluation value is smaller than the last recorded image evaluation value, the process proceeds to step S35;
step S35: accumulating the continuous reduction times, and calculating the probability value of the current position as the interference point;
step S36: comparing the probability value with a probability threshold, and accumulating termination condition counts if the probability value is less than or equal to the probability threshold; clearing the termination condition count if the probability value is greater than the probability threshold;
step S37: judging whether the termination condition count is greater than or equal to a first value, judging whether the continuous reduction times are greater than or equal to a second value, and if one of the two values is positive, entering step S38; if not, returning to execute the step S31;
step S38: judging whether the continuous increasing times is larger than or equal to the difference value between the second value and the first value, if so, entering the step S4; if not, go to step S39;
step S39: judging whether the motor is rotated to the end of the stroke or whether the number of circulating operations reaches a circulating threshold value, if so, entering a step S4; if not, the rotation direction of the motor is reversed, the step length is initialized, and the step S31 is executed in a returning mode.
7. The autofocus system of claim 6, wherein the position acquiring means is configured to acquire a potentiometer value minimum position and a potentiometer value maximum position of the moving means, and acquire an increasing/decreasing relationship between a rotational direction of the moving means and a potentiometer value.
8. The autofocus system of claim 7, wherein the controller includes a determining module configured to determine whether a distance between the initial position and the position at which the potentiometer value is minimum is smaller than a distance between the initial position and the position at which the potentiometer value is maximum; if so, controlling the mobile device to move towards the maximum potentiometer value position; if not, controlling the mobile device to move towards the position with the minimum potentiometer value.
CN202011434865.0A 2020-12-10 2020-12-10 Automatic focusing method and automatic focusing system Active CN112601015B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011434865.0A CN112601015B (en) 2020-12-10 2020-12-10 Automatic focusing method and automatic focusing system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011434865.0A CN112601015B (en) 2020-12-10 2020-12-10 Automatic focusing method and automatic focusing system

Publications (2)

Publication Number Publication Date
CN112601015A CN112601015A (en) 2021-04-02
CN112601015B true CN112601015B (en) 2022-08-05

Family

ID=75191727

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011434865.0A Active CN112601015B (en) 2020-12-10 2020-12-10 Automatic focusing method and automatic focusing system

Country Status (1)

Country Link
CN (1) CN112601015B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112055155B (en) * 2020-09-10 2022-03-11 中科微至智能制造科技江苏股份有限公司 Self-learning-based industrial camera automatic focusing method, device and system
CN113794828A (en) * 2021-07-27 2021-12-14 广西电网有限责任公司电力科学研究院 Automatic focusing method and system
CN114302053B (en) * 2021-11-24 2023-12-05 影石创新科技股份有限公司 Lens focusing method and device of image pickup apparatus, image pickup apparatus and storage medium
CN114422660A (en) * 2021-12-06 2022-04-29 江苏航天大为科技股份有限公司 Imaging focusing system of designated monitoring area
CN114422690B (en) * 2021-12-16 2022-12-20 北京波谱华光科技有限公司 Control method and device for automatic focusing, electronic equipment and storage medium
CN114460791A (en) * 2022-03-07 2022-05-10 合肥英睿系统技术有限公司 Focusing method and device, electronic equipment and storage medium
CN115546172B (en) * 2022-10-19 2023-06-30 广州纳动半导体设备有限公司 Chip carrier plate-substrate near zero clearance measurement method based on machine vision
CN116600201B (en) * 2023-07-17 2023-11-03 北京中科科仪股份有限公司 Automatic focusing method and device based on scanning electron microscope

Family Cites Families (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7502065B2 (en) * 2004-06-16 2009-03-10 Hoya Corporation Focus detection method and focus detection apparatus
CN102419505B (en) * 2011-12-06 2014-08-06 深圳英飞拓科技股份有限公司 Automatic focusing method and system and integrated camera
CN103945126B (en) * 2014-04-21 2015-03-04 中国人民解放军国防科学技术大学 Automatic focusing and locating method
CN104284095B (en) * 2014-10-28 2017-07-14 福建福光股份有限公司 The fast automatic focusing method and system of a kind of long-focus visible ray industrial lens
CN104580917A (en) * 2015-01-29 2015-04-29 广东本致科技有限公司 Automatic fast focusing method and automatic fast focusing device
CN105430279B (en) * 2015-12-23 2019-02-12 北京奇虎科技有限公司 Camera fast automatic focusing method and device
CN107079102B (en) * 2016-09-26 2019-02-22 深圳市大疆创新科技有限公司 Focusing method, photographic device and unmanned plane
CN111432125B (en) * 2020-03-31 2022-04-05 合肥英睿系统技术有限公司 Focusing method and device, electronic equipment and storage medium
CN111580271B (en) * 2020-06-24 2022-02-18 哈工大机器人(中山)无人装备与人工智能研究院 Self-adaptive aberration correction method and light sheet microscopic imaging device based on same
CN111757008B (en) * 2020-07-10 2021-12-31 普联技术有限公司 Focusing method, device and computer readable storage medium

Also Published As

Publication number Publication date
CN112601015A (en) 2021-04-02

Similar Documents

Publication Publication Date Title
CN112601015B (en) Automatic focusing method and automatic focusing system
CN105430279B (en) Camera fast automatic focusing method and device
CN107395993B (en) Full-automatic focusing method and system
CN101494737B (en) Integrated camera device and self-adapting automatic focus method
CN106324795B (en) A kind of automatic quick focusing method in more visuals field of detector microscope
CN106534676A (en) Automatic focus adjustment method for zoom camera systems
CN105527778A (en) Automatic focusing method for electric adjustable liquid lens
CN107664899B (en) Automatic focusing method, device and system
CN106341596B (en) A kind of focus method and device
JPH0774856B2 (en) Automatic focus adjustment method
CN102419505B (en) Automatic focusing method and system and integrated camera
CN103945133B (en) Auto-focus device and method for visible light lens
CN113109936B (en) Microscope automatic focusing method and device based on image definition evaluation
CN108881729A (en) A kind of Atomatic focusing method of endoscope
CN108259753A (en) A kind of camera auto-focusing method and device that climbing method is improved based on defocus estimation
CN110324536B (en) Image change automatic sensing focusing method for microscope camera
CN112203012B (en) Image definition calculation method, automatic focusing method and system
CN105430277B (en) Autofocus control method and device
CN104580917A (en) Automatic fast focusing method and automatic fast focusing device
CN105554387A (en) Zoom tracking curve correction method and device
CN108254995B (en) Automatic focusing method and system for large zoom lens
CN114460791A (en) Focusing method and device, electronic equipment and storage medium
US8417107B2 (en) Image pickup apparatus and lens position adjustment method
CN111432129B (en) Automatic focusing hill climbing searching method based on threshold value method and local maximum value
CN103414849A (en) Infrared thermal imager focusing method and device

Legal Events

Date Code Title Description
PB01 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