Focusing method and device, computer equipment and storage medium
By establishing the fitting relationship between the lens motor position and clarity, calculating the stability coefficient, and adjusting the motor position, the problem of not being able to find the best clarity point in the CDAF focusing method is solved, and the focus success rate and clarity stability is improved.
Patent Information
- Application Number
- CN202310675659.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-08
- Publication Date
- 2024-12-10
AI Technical Summary
The existing CDAF focusing method cannot accurately find the best clear points during the focusing process, resulting in a reduced focus success rate.
Obtain actual clarity through multiple target positions of the lens motor during focusing, establish the fitting relationship between motor position and clarity, calculate the stability coefficient of predicted clarity and actual clarity, adjust the motor position until the clarity is stable, and determine Optimal clarity position.
Improves the focus success rate, ensures the stability of the lens's clarity during the focus process, and reduces focus failures caused by environmental interference or target movement.
Smart Images

Figure CN119110161A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communications, and in particular to a focusing method, apparatus, computer equipment, storage medium and computer program product. Background Art
[0002] Currently, autofocus technology has been applied to digital cameras, surveillance, mobile phones and other fields. The camera AF (Autofocus) function is the process of moving the motor to change the focal length to find the best clear point. There are many ways to implement AF, one of which is CDAF (Contrast detection auto focus). FV (Focus value) is a way to measure the clarity of an image. The larger the FV, the clearer the image.
[0003] The current CDAF focusing method has the problem of being unable to find the correct optimal clarity point when focusing, which reduces the success rate of focusing. Summary of the invention
[0004] Based on this, it is necessary to provide a focusing method, device, computer equipment, computer-readable storage medium and computer program product that can improve the focusing success rate in response to the above technical problems.
[0005] In a first aspect, the present application provides a focusing method. The method comprises:
[0006] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtaining a fitting relationship between the position and sharpness of the motor;
[0007] determining, according to the fitting relationship, a predicted clarity of the motor at the target position;
[0008] Calculating a clarity stability coefficient based on the plurality of predicted clarity and actual clarity;
[0009] Determining the stability of the clarity according to the stability coefficient of the clarity;
[0010] When the clarity stability does not meet the requirement, returning to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of multiple target positions of the lens motor during the focusing process, until the clarity stability meets the requirement;
[0011] When the stability of the resolution meets the requirements, the target position of the motor is determined.
[0012] In one of the embodiments, obtaining a fitting relationship between the position and clarity of the motor based on actual clarity of multiple target positions of the lens motor during the focusing process includes:
[0013] Control the motors to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor;
[0014] Selecting a preset number of target definitions including a maximum definition, and using the position of the motor corresponding to the target definition as the target position;
[0015] Curve fitting is performed according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor.
[0016] In one embodiment, the fitting relationship between the clarity and the position of the motor is a quadratic function relationship;
[0017] Performing curve fitting according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor includes:
[0018] Based on the quadratic function relationship between the clarity and the position of the motor, and at least four groups of the target positions and the target clarity, the quadratic function relationship is solved to obtain a quadratic equation representing the fitting relationship between the position and clarity of the motor.
[0019] In one embodiment, the calculation of the clarity stability coefficient according to the plurality of predicted clarity and actual clarity comprises:
[0020] Determine an average value of the actual definition according to the plurality of actual definition;
[0021] A clarity stability coefficient is obtained according to a difference between a plurality of the predicted clarity and an average value of the actual clarity, and a difference between the actual clarity and an average value of the actual clarity.
[0022] In one embodiment, the obtaining of the clarity stability coefficient according to the difference between the average value of the predicted clarity and the actual clarity, and the difference between the actual clarity and the average value of the actual clarity, comprises:
[0023] Calculating the difference between each predicted definition and the average value of the actual definition to obtain a plurality of first difference values;
[0024] Calculating the difference between each of the actual sharpnesses and the average value of the actual sharpnesses to obtain a plurality of second difference values;
[0025] A clarity stability coefficient is obtained according to a ratio of an accumulated value of the plurality of first differences to an accumulated value of the plurality of second differences.
[0026] In one embodiment, determining the clarity stability according to the clarity stability coefficient includes:
[0027] If the stability coefficient of the clarity is greater than or equal to a preset stability coefficient threshold, then the clarity is determined to be stable;
[0028] If the stability coefficient of the definition is less than the stability coefficient threshold, it is determined that the definition is unstable.
[0029] In one embodiment, when the stability of the clarity meets the requirement, determining the target position of the motor includes:
[0030] When the stability of the clarity meets the requirement, a maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity;
[0031] The motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0032] In one embodiment, when the clarity stability meets the requirement, determining the target position of the motor further includes:
[0033] When the stability of the definition meets the requirement, the actual maximum definition is determined as the optimal definition, and the motor position corresponding to the optimal definition is determined as the target position of the motor.
[0034] In a second aspect, the present application also provides a focusing device. The device comprises:
[0035] A fitting module, for obtaining a fitting relationship between the position and clarity of the motor based on actual clarity of multiple target positions of the lens motor during the focusing process;
[0036] a prediction module, configured to determine a predicted clarity of the motor at the target position according to the fitting relationship;
[0037] A stability coefficient calculation module, used for calculating the stability coefficient of clarity according to the plurality of predicted clarity and actual clarity;
[0038] A stability determination module, used for determining the stability of the clarity according to the stability coefficient of the clarity;
[0039] The fitting module is further configured to obtain a fitting relationship between the position and clarity of the motor based on actual clarity of multiple target positions of the lens motor during a focusing process when the result output by the stability determination module is that the clarity stability does not meet the requirement;
[0040] The target position determination module is used to determine the target position of the motor when the stability of the clarity meets the requirements.
[0041] In a third aspect, the present application further provides a computer device. The computer device includes a memory and a processor, the memory stores a computer program, and the processor implements the following steps when executing the computer program:
[0042] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtaining a fitting relationship between the position and sharpness of the motor;
[0043] determining, according to the fitting relationship, a predicted clarity of the motor at the target position;
[0044] Calculating a clarity stability coefficient based on the plurality of predicted clarity and actual clarity;
[0045] Determining the stability of the clarity according to the stability coefficient of the clarity;
[0046] When the clarity stability does not meet the requirement, returning to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of multiple target positions of the lens motor during the focusing process, until the clarity stability meets the requirement;
[0047] When the stability of the resolution meets the requirements, the target position of the motor is determined.
[0048] In a fourth aspect, the present application further provides a computer-readable storage medium. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0049] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtaining a fitting relationship between the position and sharpness of the motor;
[0050] determining, according to the fitting relationship, a predicted clarity of the motor at the target position;
[0051] Calculating a clarity stability coefficient based on the plurality of predicted clarity and actual clarity;
[0052] Determining the stability of the clarity according to the stability coefficient of the clarity;
[0053] When the clarity stability does not meet the requirement, returning to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of multiple target positions of the lens motor during the focusing process, until the clarity stability meets the requirement;
[0054] When the stability of the resolution meets the requirements, the target position of the motor is determined.
[0055] In a fifth aspect, the present application further provides a computer program product. The computer program product includes a computer program, and when the computer program is executed by a processor, the following steps are implemented:
[0056] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtaining a fitting relationship between the position and sharpness of the motor;
[0057] determining, according to the fitting relationship, a predicted clarity of the motor at the target position;
[0058] Calculating a clarity stability coefficient based on the plurality of predicted clarity and actual clarity;
[0059] Determining the stability of the clarity according to the stability coefficient of the clarity;
[0060] When the clarity stability does not meet the requirement, returning to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of multiple target positions of the lens motor during the focusing process, until the clarity stability meets the requirement;
[0061] When the stability of the resolution meets the requirements, the target position of the motor is determined.
[0062] The above-mentioned focusing method, device, computer equipment, storage medium and computer program product obtain the fitting relationship between the position and clarity of the motor based on the actual clarity of multiple target positions of the lens motor during the focusing process, and obtain the predicted clarity of the motor at the target position through the fitting relationship, so as to determine the clarity stability coefficient according to the predicted clarity and the actual clarity, judge the clarity stability according to the clarity stability coefficient, and determine the target position of the motor when the clarity stability meets the requirements, thereby improving the focusing effect of the lens. In the process of focusing, the clarity stability coefficient is used to determine whether the clarity is stable. If the clarity stability does not meet the requirements, the focus is retriggered, and if the clarity stability meets the requirements, the focus is completed, thereby improving the success rate of focusing. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] Figure 1 is an application environment diagram of a focusing method in an embodiment;
[0064] Figure 2 is a schematic flow chart of a focusing method in an embodiment;
[0065] Figure 3 A schematic diagram of a flow chart for determining a fitting relationship between a motor position and clarity in one embodiment;
[0066] Figure 4 is a schematic diagram of a fitting relationship in another embodiment;
[0067] Figure 5 A schematic diagram of a flow chart for determining clarity stability in another embodiment;
[0068] Figure 6 is a schematic flow chart of a focusing method in another embodiment;
[0069] Figure 7 is a structural block diagram of a focusing device in one embodiment;
[0070] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0071] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0072] The camera AF (Auto focus) function is the process of moving the motor to change the focal length to find the best clear point. There are many ways to implement AF, one of which is CDAF (Contrast detection auto focus), also known as contrast focus. FV (Focus value) is a way to measure image clarity. The larger the FV, the clearer the image. The workflow of CDAF is to determine the FV size of the image captured by the camera and find the position of the motor corresponding to the maximum FV while the motor drives the lens group in the lens to move and change the focal length. If the AF focusing process is disturbed by the environment or the object in the focus target area moves, the FV will fluctuate greatly, resulting in failure to focus and unable to find the correct best clear point.
[0073] The focusing method provided in the embodiment of the present application can be applied to Figure 1 In the application environment shown. Among them, the controller 102 controls the motor to move in response to the focus instruction, and the motor drives the lens to move so as to change the focal length, obtains the actual clarity of the lens motor at multiple target positions, and performs fitting according to the target position and the clarity corresponding to the target position to obtain the fitting relationship between the position of the motor and the clarity, and determines the predicted clarity of the motor at the target position according to the fitting relationship; calculates the clarity stability coefficient according to the multiple predicted clarity and the actual clarity; determines the clarity stability according to the clarity stability coefficient; determines the best clarity when the clarity stability meets the requirements; determines the motor position corresponding to the best clarity as the target position of the motor, and the controller 102 drives the motor to move to the target position according to the target position to complete the focus.
[0074] In one embodiment, Figure 2 As shown, a focusing method is provided, which is applied to Figure 1 The controller in includes the following steps:
[0075] Step 202 , based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtain a fitting relationship between the position of the motor and the sharpness.
[0076] The working process of contrast-detection autofocus (CDAF) is that when the focus is started, the motor in the camera drives the lens group in the lens to start moving, the contrast starts to rise, and the picture gradually becomes clear; when the picture is the clearest and the contrast is the highest, the camera will continue to move the lens (in order to find a higher contrast), but when it is found that the contrast begins to decrease, the system moves the lens group in the opposite direction and retreats to the position with the highest contrast, thus completing the focus. However, during the autofocus process, it is easy to be disturbed by the environment or the movement of the object in the focus target area, resulting in a large fluctuation in the actual clarity, and the focus fails and the correct optimal clarity point cannot be found.
[0077] Among them, the clarity FV (Focus value) is a way to measure the clarity of the image. The larger the FV, the clearer the image. When shooting, the position of the lens motor is different, and the corresponding actual clarity is also different. It can be understood that the position of a motor of the lens corresponds to an actual clarity. Move the position of the lens motor to obtain an actual clarity corresponding to the position of each motor. It can be understood that the actual clarity here refers to the clarity corresponding to the motor in different positions obtained by moving the motor position during the focusing process.
[0078] Among them, the functional relationship between the motor position and clarity can be determined in advance through a large number of experiments on the motor position and clarity. For example, through experiments, it can be found that the fitting relationship between the motor position and clarity is a quadratic function, but in the actual focusing process, there may be interference and other situations that cause changes in clarity. Therefore, in each specific focusing process, the parameters of the functional relationship of the fitting relationship between the motor position and clarity are different.
[0079] Therefore, during the actual focusing process, the actual clarity of the lens motor at multiple target positions can be obtained, and based on the functional relationship between the position and clarity of the motor, the parameters of the function can be calculated to obtain the fitting relationship between the position and clarity of the motor during the focusing process.
[0080] For example, the functional relationship between clarity and motor position is a quadratic function:
[0081] y=a*x 2 +b*x+c
[0082] During the actual focusing process, the actual clarity of the lens motor at multiple target positions is obtained, and based on the functional relationship between the motor position and clarity, the parameters a, b and c are calculated, thereby obtaining the fitting relationship between the motor position and clarity during the focusing process.
[0083] Specifically, in response to the focus instruction, the lens motor drives the lens group to move, and when the motor moves to each target position, each target position and the actual clarity corresponding to each target position are determined. According to the obtained multiple motor target positions and the actual clarity of the multiple target positions, the motor position and the actual clarity are fitted to obtain a fitting relationship between the motor position and the clarity. Among them, the target position is the position to which the motor needs to move according to the predetermined movement step of the motor. It can be understood that the clarity to be fitted is the actual clarity corresponding to the position of the motor, that is, the fitting relationship is obtained by the position of the motor and the actual clarity corresponding to the position of the motor.
[0084] Step 204: Determine the predicted clarity of the motor at the target position based on the fitting relationship.
[0085] The predicted clarity is the clarity corresponding to the motor position determined by the fitting relationship.
[0086] After obtaining the fitting relationship between the motor position and the clarity, the clarity corresponding to the motor at multiple target positions, i.e., the predicted clarity, can be calculated based on the fitting relationship between the motor position and the clarity. It can be understood that one motor position corresponds to two clarity, one is the actual clarity and the other is the predicted clarity. Among them, the predicted clarity is determined by the fitting relationship, and the actual clarity refers to the clarity corresponding to the motor at different target positions obtained by moving the motor position during the focusing process.
[0087] Step 206: Calculate the clarity stability coefficient according to the multiple predicted clarity and the actual clarity.
[0088] During the AF focusing process, if the environment interferes or the object in the focus target area moves, the clarity FV will fluctuate greatly, resulting in focus failure and inability to find the correct optimal clarity point. Therefore, it is necessary to determine the clarity fluctuation during the focusing process, and determine whether the focus needs to be re-triggered based on the clarity fluctuation during the focusing process.
[0089] Among them, the clarity stability coefficient represents the fluctuation range of clarity during the focusing process.
[0090] In this embodiment, the fluctuation of the definition FV is characterized by the definition stability coefficient value. Specifically, the position of one motor corresponds to two definitions, one is the actual definition and the other is the predicted definition. According to the actual definitions corresponding to the positions of multiple motors and the corresponding predicted definitions, the stability coefficient of the predicted definition and the actual definition is determined, and the stability coefficient of the predicted definition and the actual definition characterizes the degree of deviation between the actual value and the fitted value.
[0091] Step 208, determining the clarity stability according to the clarity stability coefficient.
[0092] Among them, the clarity stability coefficient represents the stability of clarity. The clarity stability represents whether the AF focusing process is affected by environmental interference or the object in the focus target area is moving, and the degree of fluctuation in clarity caused by the above situations.
[0093] Specifically, after determining the clarity stability coefficient according to the actual clarity corresponding to the positions of the multiple motors and the corresponding predicted clarity, determine whether the clarity of the lens is stable according to the clarity stability coefficient. The clarity stability coefficient characterizes the degree of deviation between the actual value and the fitted value. It can be understood that when the clarity stability coefficient is within a certain range, the clarity is stable, and when the clarity stability coefficient exceeds a certain range, the clarity of the lens is unstable.
[0094] Step 210, determining whether the clarity stability meets the requirement; when the clarity stability does not meet the requirement, returning to step 202, until the clarity stability meets the requirement.
[0095] When the stability of lens clarity does not meet the requirements, it means that the focusing process is disturbed and the clarity fluctuates greatly. During the focusing process, when the clarity stability does not meet the requirements, the focus needs to be re-triggered. That is, when the clarity stability does not meet the requirements, it is necessary to return to the step of obtaining the fitting relationship between the motor position and clarity based on the actual clarity of the lens motor at multiple target positions, and then determine the predicted clarity of the target position and the clarity stability coefficient based on the fitting relationship again until the clarity stability meets the requirements. By refocusing when the clarity stability does not meet the requirements, focusing can be completed when the clarity stability meets the requirements.
[0096] Step 212, when the clarity stability meets the requirement, determine the target position of the motor.
[0097] When the stability of lens clarity meets the required conditions, it means that there is no or only minimal interference during the focusing process, and the fluctuation of clarity is small. For example, there is little environmental interference during the focusing process, or the object in the focusing target area does not move.
[0098] The target position of the motor is the position of the motor corresponding to the best clarity.
[0099] Specifically, after obtaining the stability of clarity based on the stability coefficient of the predicted clarity and the actual clarity, compare the clarity stability with the required stability. When the clarity stability meets the requirements, it is necessary to determine the optimal clarity and the position of the motor corresponding to the optimal clarity, that is, the target position of the motor. The determination of the optimal clarity is the process of finding the maximum clarity. There are many ways to determine the optimal clarity. For example, the optimal clarity can be obtained by numerical comparison, or the optimal clarity can be determined by fitting a relationship. The specific method can be flexibly selected according to actual needs.
[0100] It is understandable that after determining the best definition, it is necessary to determine the position of the motor corresponding to the best definition, that is, the target position of the motor. When the motor moves to the position of the motor corresponding to the best definition, the definition of the captured image is the highest and the image is the clearest.
[0101] Specifically, the position of the motor corresponding to the best definition is determined according to the determined best definition, and the position of the motor corresponding to the best definition is the target position of the motor. Specifically, the target position of the motor can be determined by finding the position of the motor corresponding to the best definition, or the target position of the motor can be determined according to the fitting relationship.
[0102] In this embodiment, based on the actual clarity of the lens motor at multiple target positions, the fitting relationship between the position and clarity of the motor is obtained, and the predicted clarity of the motor at the target position is obtained through the fitting relationship, so that the clarity stability coefficient is determined according to the predicted clarity and the actual clarity, and the clarity stability is judged according to the clarity stability coefficient. When the clarity stability meets the requirements, the target position of the motor is determined, thereby improving the focusing effect of the lens. In the process of focusing, whether the clarity is stable is determined by the stability coefficient of the predicted clarity and the actual clarity, and the focus is retriggered when the clarity stability does not meet the requirements, and the focus is completed when the clarity stability meets the requirements, thereby improving the success rate of focusing.
[0103] In one embodiment, Figure 3 As shown, based on the actual clarity of the lens motor at multiple target positions, a method for obtaining a fitting relationship between the position and clarity of the motor includes the following steps:
[0104] Step 302 , controlling the motors to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor.
[0105] After receiving the focus command, the motor is controlled to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor, thereby obtaining the position of each motor within the travel range and the actual clarity corresponding to the position of each motor. The step size of the motor traversal within the travel range can be set according to actual needs.
[0106] Step 304 , selecting a preset number of target sharpnesses including a maximum sharpness, and taking the position of the motor corresponding to the target sharpness as the target position.
[0107] The preset number is a pre-set number, and the preset number is greater than 3.
[0108] From the motor positions and the actual resolutions corresponding to the motor positions, a preset number of target resolutions including the maximum resolution are selected. A preferred method is to establish a two-dimensional coordinate system using the motor positions as the horizontal coordinate and the resolution FV as the vertical coordinate. According to the motor positions within the travel range and the actual resolutions corresponding to the motor positions, multiple coordinate points are obtained, which are recorded as (x i ,y i ). Select multiple coordinate points symmetrically on both sides of the maximum definition. The maximum definition and the definitions on its left and right sides constitute the target definition. Correspondingly, the position of the motor corresponding to the target definition is used as the target position. The method of selecting the target definition symmetrically on both sides of the maximum definition can achieve a better fitting effect.
[0109] Step 306 , performing curve fitting according to multiple target positions and target sharpnesses to obtain a fitting relationship between the position and sharpness of the motor.
[0110] Curve fitting is performed based on the target clarity and the position of the motor corresponding to the target clarity. The fitting of the clarity and the corresponding motor position includes but is not limited to a quadratic function, such as a function of 3 to 5 or a higher order function.
[0111] In this embodiment, a quadratic function is used as an example to fit the target definition and the position of the motor corresponding to the target definition. Assume that the functional relationship between the definition and the position of the motor is:
[0112] y=a*x 2 +b*x+c
[0113] Generally, three sets of target clarity and the motor positions corresponding to the target clarity can be used to determine the three coefficients of the quadratic function. Since the three sets of target clarity and the motor positions corresponding to the target clarity selected above are exactly the same as the predicted clarity obtained by the above fitting relationship, the stability coefficient of the actual clarity and the predicted clarity cannot be calculated in this way.
[0114] A preferred way to solve the three coefficients of a quadratic function is to use more than three sets of target clarity and motor positions corresponding to the target clarity to solve the quadratic equation. The more target clarity and motor positions corresponding to the target clarity are selected, the more accurate the solved quadratic function will be. The specific process for solving the quadratic function is as follows.
[0115] Using the preset number of coordinate points (x i ,y i ), the solved quadratic function curve is fitted by a preset number of coordinate points. It can be understood that in order to make each coordinate point as close to the fitting curve as possible, a*x i 2 +b*x i +c is as equal to y as possible i .
[0116] Mathematically, there exists a set of a, b, and c such that the square of the difference between the two has a minimum value of 0. The formula is as follows:
[0117]
[0118] The above formula is converted into the following formula by adding up the preset number of points:
[0119]
[0120] The above formula can be converted into the following formula:
[0121]
[0122] The above formula is expressed as F. When there is a minimum value, the derivative is 0.
[0123] The formula for calculating the partial derivative of formula F with respect to a can be converted into the following formula.
[0124]
[0125] Similarly, the formula for calculating the partial derivative of formula F with respect to b and the formula for calculating the partial derivative of formula c can be converted into the following formula.
[0126]
[0127]
[0128] By selecting a preset number of target sharpnesses and the motor positions corresponding to the target sharpnesses, the three unknowns a, b and c are solved using the above three formulas. The obtained a, b and c are the coefficients a, b and c of the above quadratic function y=a*x^2+b*x+c. Thus, the fitting relationship between the motor position and the sharpness is obtained. The fitting relationship between the motor position and the sharpness is shown in Figure 4 shown.
[0129] In this embodiment, the actual clarity corresponding to the position of each motor is obtained by traversing the motor within the travel range, from which a preset number of target clarity including the maximum clarity are selected, and the functional relationship between the selected target clarity and the corresponding motor position is processed to obtain a fitting relationship between the motor position and clarity, thereby providing conditions for determining the stability of clarity.
[0130] In one embodiment, the stability of clarity is determined based on the stability coefficient of predicted clarity and actual clarity, including: determining the average value of actual clarity based on multiple actual clarity; obtaining the stability coefficient of clarity based on the difference between the average values of multiple predicted clarity and actual clarity, and the difference between the actual clarity and the average value of the actual clarity.
[0131] There are many groups of predicted clarity and corresponding actual clarity of motor positions, and there are many ways to select multiple groups for clarity calculation, and this application does not limit the selection method. Generally, the selection method of multiple groups of actual clarity and predicted clarity required for calculating the clarity stability coefficient can be to arbitrarily select n from the actual clarity corresponding to the position of each motor, and determine the motor position corresponding to the actual clarity according to the selected n actual clarity, and then determine the predicted clarity corresponding to the motor position according to the motor position and the fitting relationship.
[0132] In this embodiment, a preferred method is to determine the predicted clarity of the target position according to the target position and the fitting relationship, and then calculate the clarity stability coefficient based on the actual clarity of the target position and the predicted clarity.
[0133] In this embodiment, a preferred method for calculating the clarity stability coefficient is: calculating the difference between each predicted clarity and the average value of the actual clarity to obtain multiple first differences; calculating the difference between each actual clarity and the average value of the actual clarity to obtain multiple second differences; and obtaining the clarity stability coefficient based on the ratio of the cumulative value of the multiple first differences to the cumulative value of the multiple second differences.
[0134] Specifically, the calculation formula of the clarity stability coefficient is:
[0135]
[0136] in, is the predicted clarity of the selected n target positions, is the average value of the actual clarity, obtained by averaging the actual clarity of the selected n target positions, y i is the selected n actual resolutions, is the first difference, The stability coefficient of the predicted clarity corresponding to the positions of the n motors is obtained by accumulating the stability coefficient of the predicted clarity and the actual clarity, and the stability of the clarity is determined according to the obtained stability coefficient value and the stability coefficient threshold.
[0137] In this embodiment, the average value of the actual clarity of multiple motor positions is obtained through the actual clarity of multiple motor positions. The clarity stability coefficient is determined based on the predicted clarity, actual clarity and the average value of the actual clarity of multiple motor positions, thereby determining the clarity stability.
[0138] In one embodiment, Figure 5 As shown, according to the clarity stability coefficient, determining the clarity stability includes the following steps:
[0139] Step 502, obtaining a stability coefficient threshold.
[0140] The stability coefficient threshold is a preset threshold, and the stability coefficient threshold may be 0.8, 0.85, 0.9, etc. Specifically, the stability coefficient threshold may be adjusted according to actual conditions. In this embodiment, the stability coefficient threshold is set to 0.8.
[0141] Step 504, determining whether the clarity stability coefficient is greater than or equal to a stability coefficient threshold.
[0142] If yes, then step 506 is executed to determine whether the definition is stable.
[0143] Specifically, the clarity stability coefficient and the stability coefficient threshold are compared. When the clarity stability coefficient is greater than or equal to the stability coefficient threshold, it indicates that the clarity is stable. Assuming the stability coefficient threshold is 0.8, when the clarity stability coefficient is greater than or equal to 0.8, the clarity is stable.
[0144] If not, step 508 is executed to determine whether the definition is unstable.
[0145] Compare the clarity stability coefficient and the stability coefficient threshold. When the clarity stability coefficient is less than the stability coefficient threshold, the clarity is unstable. It can be understood that, assuming the stability coefficient threshold is 0.8, then when the clarity stability coefficient is less than 0.8, the clarity is determined to be unstable. At this time, the focus is retriggered.
[0146] In this embodiment, whether the clarity is stable is determined by comparing the clarity stability coefficient with a preset stability coefficient threshold. When the clarity is determined to be unstable, the focus is re-triggered; when the clarity is determined to be stable, the optimal clarity is determined.
[0147] In one embodiment, when the clarity stability meets the requirements, the target position of the motor is determined, including: when the clarity stability meets the requirements, the maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity; and the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0148] Specifically, the clarity stability is determined according to the stability coefficient threshold, and when the clarity stability coefficient is greater than or equal to the stability coefficient threshold, the clarity stability meets the requirement. The clarity stability meeting the requirement indicates that during the focusing process, the clarity fluctuation is small, that is, during the focusing process, the environmental interference is small and the object in the focus target area does not move.
[0149] When the clarity stability meets the requirements, it is necessary to determine the optimal clarity and the position of the motor corresponding to the optimal clarity, that is, the target position of the motor, based on the clarity. There are many ways to determine the optimal clarity. In this embodiment, a preferred way is to determine the optimal clarity and the target position of the motor corresponding to the optimal clarity by obtaining the fitting relationship between the position of the motor and the clarity. Among them, the maximum predicted clarity is the optimal clarity. Take the quadratic function relationship as an example, that is, the functional relationship between the position of the motor and the clarity is:
[0150] y=a*x 2 +b*x+c
[0151] The target position of the motor corresponding to the best clarity is:
[0152]
[0153] In this embodiment, when the stability of the clarity meets the requirements, the maximum predicted clarity is determined as the optimal clarity and the target position of the motor corresponding to the optimal clarity is determined through the fitting relationship between the position of the motor and the clarity.
[0154] In one embodiment, when the clarity stability meets the requirements, determining the target position of the motor also includes: when the clarity stability meets the requirements, determining the actual maximum clarity as the optimal clarity; and determining the motor position corresponding to the optimal clarity as the target position of the motor.
[0155] There are many ways to determine the best clarity. In this embodiment, another method for determining the best clarity is provided. The actual clarity corresponding to each motor position traversed by the motor in the travel range is obtained, and the maximum clarity is selected as the best clarity. In the actual process, if the above method is selected to determine the maximum clarity, that is, to determine the maximum clarity from the actual clarity, it is necessary to consider the step length traversed by the motor in the travel range. Because when the motor step length is large, the maximum clarity determined from the actual clarity may not be the maximum clarity. Therefore, the motor step length needs to be as small as possible to ensure that the motor traverses the travel range. The actual clarity obtained can be closer to the real clarity. The smaller the motor step length, the more accurate the actual clarity obtained, and the more accurate the best clarity obtained, that is, the accuracy of the best clarity can be improved. After determining the best clarity, the motor position corresponding to the best clarity is determined as the target position of the motor.
[0156] In this embodiment, when the stability of clarity meets the requirements, the actual clarity corresponding to the position of each motor is obtained by traversing the motor within the travel range. According to the actual clarity corresponding to the position of each motor, the maximum actual clarity is determined as the optimal clarity, and the position of the motor corresponding to the optimal clarity is the target position of the motor.
[0157] This application provides a focusing method, such as Figure 6 As shown, the focusing method includes the following steps:
[0158] Step 602, control the motor to traverse within the travel range, obtain the actual clarity corresponding to the position of each motor, the position of each motor and the actual clarity corresponding to the position of the motor are a coordinate point, and construct a two-dimensional coordinate of the motor position and the actual clarity.
[0159] Step 604: In the two-dimensional coordinates, select a preset number of target coordinate points near the maximum definition.
[0160] Select a preset number of target coordinate points, marked as (x i ,y i ), the subscript i is the number of the point, ranging from 1 to n, n>3.
[0161] Step 606: Obtain a fitting relationship between the position and clarity of the motor according to a preset number of target coordinate points.
[0162] Taking the quadratic function relationship as an example, the functional relationship between clarity and motor position can be expressed as
[0163] y=a*x 2 +b*x+c
[0164] By using the following three equations and selecting a preset number of target coordinate points, the three coefficients a, b and c in the fitting relationship are solved to obtain the fitting relationship between the clarity and the position of the motor.
[0165]
[0166]
[0167]
[0168] Step 608, based on the fitting relationship and the target coordinate point, obtain the predicted clarity corresponding to the position of the motor at each target coordinate point, and the target position of the motor corresponding to the optimal clarity.
[0169] According to the position of the motor in the target coordinate point and the fitting relationship, the predicted clarity corresponding to the position of the motor in the target coordinate point is obtained. The predicted clarity corresponding to the position of the motor in each target coordinate point is recorded as n points y i The average value of Determine the target position of the motor corresponding to the best clarity based on the fitting relationship
[0170] Step 610: Determine a clarity stability coefficient based on a plurality of predicted clarity and actual clarity.
[0171] The stability coefficient calculation formula is:
[0172]
[0173] in, is the predicted clarity corresponding to the position of the motor at each target coordinate point, For n points y i The average value of .
[0174] According to the selected preset number of target coordinate points (x i ,y i ), and calculate the stability coefficient of clarity.
[0175] Step 612, determining whether the clarity stability coefficient is greater than or equal to a stability coefficient threshold.
[0176] If yes, then execute step 614 to move the motor to the target position of the motor; otherwise, return to step 602.
[0177] The target position of the motor may be the motor position corresponding to the maximum predicted clarity determined according to the fitting relationship, or may be the motor position corresponding to the actual maximum clarity.
[0178] The focusing method provided in the present application determines the degree of deviation between the actual clarity and the predicted clarity through the clarity stability coefficient, and uses the clarity stability coefficient as the basis for judging the clarity stability. When the clarity is unstable, the focus is re-triggered to improve the success rate of focusing; when the clarity is stable, the motor is moved according to the target position of the motor corresponding to the optimal clarity to improve the focusing effect of the lens.
[0179] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.
[0180] Based on the same inventive concept, the embodiment of the present application also provides a focusing device for implementing the above-mentioned focusing method. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above-mentioned method, so the specific limitations in one or more focusing device embodiments provided below can refer to the limitations on the focusing method above, and will not be repeated here.
[0181] In one embodiment, Figure 7 As shown, a focusing device is provided, including: a fitting module 702, a prediction module 704, a stability coefficient calculation module 706, a stability determination module 708, the fitting module 710 and a target position determination module 712, wherein:
[0182] The fitting module 702 is used to obtain a fitting relationship between the position and clarity of the motor based on the actual clarity of multiple target positions of the lens motor during the focusing process.
[0183] The prediction module 704 is used to determine the prediction clarity of the motor at the target position according to the fitting relationship.
[0184] The stability coefficient calculation module 706 is used to calculate the stability coefficient of the definition according to the multiple predicted definitions and the actual definitions.
[0185] The stability determination module 708 is used to determine the stability of the clarity according to the stability coefficient of the clarity.
[0186] The fitting module 710 is used to obtain a fitting relationship between the position of the motor and the clarity based on the actual clarity of the lens motor at multiple target positions when the result output by the stability determination module is that the clarity stability does not meet the requirements.
[0187] The target position determination module 712 is used to determine the target position of the motor when the clarity stability meets the requirements.
[0188] In one embodiment, the fitting module is also used to control the motor to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor; select a preset number of target clarity including the maximum clarity, and use the position of the motor corresponding to the target clarity as the target position; perform curve fitting based on multiple target positions and target clarity to obtain the fitting relationship between the motor position and clarity.
[0189] In one embodiment, the stability coefficient calculation module is used to determine the average value of the actual clarity based on multiple actual clarity; and obtain the clarity stability coefficient based on the difference between the average value of multiple predicted clarity and the actual clarity, and the difference between the actual clarity and the average value of the actual clarity.
[0190] In one embodiment, the stability coefficient calculation module is also used to calculate the difference between each predicted clarity and the average value of the actual clarity to obtain multiple first differences; calculate the difference between each actual clarity and the average value of the actual clarity to obtain multiple second differences; and obtain the clarity stability coefficient based on the ratio of the cumulative value of the multiple first differences to the cumulative value of the multiple second differences.
[0191] In one embodiment, the stability determination module is further used to determine that the clarity is stable if the stability coefficient of the clarity is greater than or equal to a preset stability coefficient threshold; if the stability coefficient of the clarity is less than the stability coefficient threshold, determine that the clarity is unstable.
[0192] In one embodiment, the target position determination module is used to obtain the maximum predicted clarity according to the fitting relationship when the clarity stability meets the requirements, and determine the maximum predicted clarity as the optimal clarity; and determine the motor position corresponding to the optimal clarity as the target position of the motor.
[0193] In one embodiment, the target position determination module is used to determine the actual maximum clarity as the optimal clarity when the clarity stability meets the requirements; and determine the motor position corresponding to the optimal clarity as the target position of the motor.
[0194] Each module in the above-mentioned focusing device can be implemented in whole or in part by software, hardware or a combination thereof. Each of the above-mentioned modules can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.
[0195] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, a communication interface, a display screen and an input device connected via a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a focusing method is implemented.
[0196] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.
[0197] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:
[0198] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, a fitting relationship between the position and sharpness of the motor is obtained;
[0199] Based on the fitted relationship, the predicted clarity of the motor at the target position is determined;
[0200] Calculating a stability coefficient of clarity based on a plurality of predicted clarity and actual clarity;
[0201] Determine the stability of the clarity according to the stability coefficient of the clarity;
[0202] When the clarity stability does not meet the requirement, return to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of the lens motor at multiple target positions until the clarity stability meets the requirement;
[0203] When the clarity stability meets the requirements, the target position of the motor is determined.
[0204] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0205] The motor is controlled to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor; a preset number of target clarity including the maximum clarity is selected, and the position of the motor corresponding to the target clarity is used as the target position; curve fitting is performed according to multiple target positions and target clarity to obtain the fitting relationship between the motor position and clarity.
[0206] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0207] Performing curve fitting according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor includes:
[0208] Based on the quadratic function relationship between the clarity and the position of the motor, and at least four groups of the target positions and the target clarity, the quadratic function relationship is solved to obtain a quadratic equation representing the fitting relationship between the position and clarity of the motor.
[0209] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0210] According to multiple actual sharpnesses, an average value of the actual sharpnesses is determined; according to the difference between the average value of multiple predicted sharpnesses and the actual sharpnesses, and the difference between the actual sharpnesses and the average value of the actual sharpnesses, a stability coefficient of the sharpness is obtained.
[0211] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0212] The difference between each predicted clarity and the average value of the actual clarity is calculated to obtain multiple first differences; the difference between each actual clarity and the average value of the actual clarity is calculated to obtain multiple second differences; and the clarity stability coefficient is obtained according to the ratio of the accumulated value of the multiple first differences to the accumulated value of the multiple second differences.
[0213] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0214] If the clarity stability coefficient is greater than or equal to a preset stability coefficient threshold, the clarity is determined to be stable; if the clarity stability coefficient is less than the stability coefficient threshold, the clarity is determined to be unstable.
[0215] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0216] When the stability of the clarity meets the requirements, the maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity; the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0217] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:
[0218] When the stability of the clarity meets the requirements, the actual maximum clarity is determined as the optimal clarity; and the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0219] In one embodiment, a computer readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:
[0220] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, a fitting relationship between the position and sharpness of the motor is obtained;
[0221] Based on the fitted relationship, the predicted clarity of the motor at the target position is determined;
[0222] Calculating a stability coefficient of clarity based on a plurality of predicted clarity and actual clarity;
[0223] Determine the stability of the clarity according to the stability coefficient of the clarity;
[0224] When the clarity stability does not meet the requirement, return to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of the lens motor at multiple target positions until the clarity stability meets the requirement;
[0225] When the clarity stability meets the requirements, the target position of the motor is determined.
[0226] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0227] The motor is controlled to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor; a preset number of target clarity including the maximum clarity is selected, and the position of the motor corresponding to the target clarity is used as the target position; curve fitting is performed according to multiple target positions and target clarity to obtain the fitting relationship between the motor position and clarity.
[0228] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0229] Performing curve fitting according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor includes:
[0230] Based on the quadratic function relationship between the clarity and the position of the motor, and at least four groups of the target positions and the target clarity, the quadratic function relationship is solved to obtain a quadratic equation representing the fitting relationship between the position and clarity of the motor.
[0231] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0232] According to multiple actual sharpnesses, an average value of the actual sharpnesses is determined; according to the difference between the average value of multiple predicted sharpnesses and the actual sharpnesses, and the difference between the actual sharpnesses and the average value of the actual sharpnesses, a stability coefficient of the sharpness is obtained.
[0233] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0234] The difference between each predicted clarity and the average value of the actual clarity is calculated to obtain multiple first differences; the difference between each actual clarity and the average value of the actual clarity is calculated to obtain multiple second differences; and the clarity stability coefficient is obtained according to the ratio of the accumulated value of the multiple first differences to the accumulated value of the multiple second differences.
[0235] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0236] If the clarity stability coefficient is greater than or equal to a preset stability coefficient threshold, the clarity is determined to be stable; if the clarity stability coefficient is less than the stability coefficient threshold, the clarity is determined to be unstable.
[0237] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0238] When the stability of the clarity meets the requirements, the maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity; the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0239] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0240] When the stability of the clarity meets the requirements, the actual maximum clarity is determined as the optimal clarity; and the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0241] In one embodiment, a computer program product is provided, comprising a computer program, which, when executed by a processor, implements the following steps:
[0242] Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, a fitting relationship between the position and sharpness of the motor is obtained;
[0243] Based on the fitted relationship, the predicted clarity of the motor at the target position is determined;
[0244] Calculating a stability coefficient of clarity based on a plurality of predicted clarity and actual clarity;
[0245] Determine the stability of the clarity according to the stability coefficient of the clarity;
[0246] When the clarity stability does not meet the requirement, return to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of the lens motor at multiple target positions until the clarity stability meets the requirement;
[0247] When the clarity stability meets the requirements, the target position of the motor is determined.
[0248] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0249] The motor is controlled to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor; a preset number of target clarity including the maximum clarity is selected, and the position of the motor corresponding to the target clarity is used as the target position; curve fitting is performed according to multiple target positions and target clarity to obtain the fitting relationship between the motor position and clarity.
[0250] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0251] Performing curve fitting according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor includes:
[0252] Based on the quadratic function relationship between the clarity and the position of the motor, and at least four groups of the target positions and the target clarity, the quadratic function relationship is solved to obtain a quadratic equation representing the fitting relationship between the position and clarity of the motor.
[0253] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0254] According to multiple actual sharpnesses, an average value of the actual sharpnesses is determined; according to the difference between the average value of multiple predicted sharpnesses and the actual sharpnesses, and the difference between the actual sharpnesses and the average value of the actual sharpnesses, a stability coefficient of the sharpness is obtained.
[0255] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0256] The difference between each predicted clarity and the average value of the actual clarity is calculated to obtain multiple first differences; the difference between each actual clarity and the average value of the actual clarity is calculated to obtain multiple second differences; and the clarity stability coefficient is obtained according to the ratio of the accumulated value of the multiple first differences to the accumulated value of the multiple second differences.
[0257] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0258] If the clarity stability coefficient is greater than or equal to a preset stability coefficient threshold, the clarity is determined to be stable; if the clarity stability coefficient is less than the stability coefficient threshold, the clarity is determined to be unstable.
[0259] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0260] When the stability of the clarity meets the requirements, the maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity; the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0261] In one embodiment, when the computer program is executed by a processor, the following steps are also implemented:
[0262] When the stability of the clarity meets the requirements, the actual maximum clarity is determined as the optimal clarity; and the motor position corresponding to the optimal clarity is determined as the target position of the motor.
[0263] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.
[0264] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0265] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.
Claims
1. A focusing method, It is characterized in that The method comprises: Based on the actual sharpness of multiple target positions of the lens motor during the focusing process, obtaining a fitting relationship between the position and sharpness of the motor; determining, according to the fitting relationship, a predicted clarity of the motor at the target position; Calculating a clarity stability coefficient based on the plurality of predicted clarity and actual clarity; Determining the stability of the clarity according to the stability coefficient of the clarity; When the stability of the clarity does not meet the requirement, returning to the step of obtaining a fitting relationship between the position of the motor and the clarity based on the actual clarity of the multiple target positions of the lens motor during the focusing process, until the stability of the clarity meets the requirement; When the stability of the resolution meets the requirements, the target position of the motor is determined.
2. The method according to claim 1, It is characterized in that The method of obtaining a fitting relationship between the position and clarity of the motor based on the actual clarity of multiple target positions of the lens motor during the focusing process includes: Control the motors to traverse within the travel range to obtain the actual clarity corresponding to the position of each motor; Selecting a preset number of target definitions including a maximum definition, and using the position of the motor corresponding to the target definition as the target position; Curve fitting is performed according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor.
3. The method according to claim 2, It is characterized in that The fitting relationship between the clarity and the position of the motor is a quadratic function relationship; Performing curve fitting according to the plurality of target positions and the target clarity to obtain a fitting relationship between the position and clarity of the motor includes: Based on the quadratic function relationship between the clarity and the position of the motor, and at least four groups of the target positions and the target clarity, the quadratic function relationship is solved to obtain a quadratic equation representing the fitting relationship between the position and clarity of the motor.
4. The method according to claim 1, It is characterized in that The calculating of the clarity stability coefficient according to the plurality of predicted clarity and the actual clarity comprises: Determine an average value of the actual definition according to the plurality of actual definition; A clarity stability coefficient is obtained according to a difference between a plurality of the predicted clarity and an average value of the actual clarity, and a difference between the actual clarity and an average value of the actual clarity.
5. The method according to claim 4, It is characterized in that The obtaining of the clarity stability coefficient according to the difference between the average value of the predicted clarity and the actual clarity, and the difference between the actual clarity and the average value of the actual clarity, comprises: Calculating the difference between each predicted definition and the average value of the actual definition to obtain a plurality of first difference values; Calculating the difference between each of the actual sharpnesses and the average value of the actual sharpnesses to obtain a plurality of second difference values; A clarity stability coefficient is obtained according to a ratio of an accumulated value of the plurality of first differences to an accumulated value of the plurality of second differences.
6. The method according to claim 1, It is characterized in that Determining the clarity stability according to the clarity stability coefficient includes: If the stability coefficient of the clarity is greater than or equal to a preset stability coefficient threshold, then the clarity is determined to be stable; If the stability coefficient of the definition is less than the stability coefficient threshold, it is determined that the definition is unstable.
7. The method according to any one of claims 1 to 6, It is characterized in that When the stability of the clarity meets the requirement, determining the target position of the motor includes: When the stability of the clarity meets the requirement, a maximum predicted clarity is obtained according to the fitting relationship, and the maximum predicted clarity is determined as the optimal clarity; The motor position corresponding to the optimal clarity is determined as the target position of the motor.
8. The method according to any one of claims 1 to 6, It is characterized in that When the stability of the clarity meets the requirement, determining the target position of the motor also includes: When the stability of the definition meets the requirement, determining the actual maximum definition as the optimal definition; The motor position corresponding to the optimal clarity is determined as the target position of the motor.
9. A focusing device, It is characterized in that The device comprises: A fitting module, for obtaining a fitting relationship between the position and clarity of the motor based on actual clarity of multiple target positions of the lens motor during the focusing process; a prediction module, configured to determine a predicted clarity of the motor at the target position according to the fitting relationship; A stability coefficient calculation module, used for calculating the stability coefficient of clarity according to the plurality of predicted clarity and actual clarity; A stability determination module, used for determining the stability of the clarity according to the stability coefficient of the clarity; The fitting module is further configured to obtain a fitting relationship between the position and clarity of the motor based on actual clarity of multiple target positions of the lens motor during a focusing process when the result output by the stability determination module is that the clarity stability does not meet the requirement; The target position determination module is used to determine the target position of the motor when the stability of the clarity meets the requirements.
10. A computer device comprising a memory and a processor, wherein the memory stores a computer program. It is characterized in that When the processor executes the computer program, the steps of the method according to any one of claims 1 to 8 are implemented.
