Mechanical lens deviation calculation method
By acquiring and fitting the motion pulse data of the mechanical lens, combining the image sharpness value, calculating and compensating the deviation of the mechanical lens, the deviation problem caused by the lack of an encoder when the mechanical lens rotates at high speed is solved, and the consistent image sharpness is achieved reduces sexual and equipment costs.
Patent Information
- Application Number
- CN202410313978.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-19
- Publication Date
- 2025-02-11
- Estimated Expiration
- 2044-03-19
AI Technical Summary
When the mechanical lens rotates at high speed, the deviation is caused by brake inertia and reversal inertia, and the lack of an encoder to record the absolute position of the lens motor after it moves, making it difficult to accurately calculate the deviation.
By obtaining the total number of first motion pulses of the mechanical lens moving from the start bit to the end bit according to a single pulse, and obtaining the total number of second motion pulses of the mechanical lens moving from the start bit to the end bit under multiple pulse lengths, fitting with pulses The length is the independent variable, and the forward deviation is the forward deviation function of the dependent variable. The forward and backward mechanical lens are controlled to compensate, and the inversion deviation is determined by the image sharpness value.
Without an encoder, the forward and inversion deviations of the mechanical lens can be accurately calculated, ensuring the consistent clarity of the image acquired at the same position and reducing equipment costs.
Smart Images

Figure CN118195954B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of imaging equipment, and in particular to a method for calculating a mechanical lens deviation. Background Art
[0002] As companies continue to implement plans to reduce costs and increase efficiency, the purchase cost of mechanical lenses has also decreased. Most mechanical lenses on the market do not have encoders to record the absolute position of the lens motor after movement. Therefore, when the mechanical lens rotates at high speed, it is inevitable that braking inertia and reverse inertia will occur, resulting in different deviations of the lens after moving different lengths. Summary of the invention
[0003] The mechanical lens deviation calculation method provided by the present invention can calculate the forward deviation and reverse deviation of the mechanical lens without using an encoder, which is beneficial to the clarity consistency when the mechanical lens captures images at the same position.
[0004] The present invention provides a method for calculating a mechanical lens deviation, the method comprising:
[0005] Acquire the total number of first motion pulses of the mechanical lens moving from the start position to the end position according to a single pulse;
[0006] Obtaining the total number of second motion pulses of the mechanical lens moving from the start position to the end position under multiple pulse lengths;
[0007] According to the total number of second motion pulses and the total number of first motion pulses corresponding to the multiple pulse lengths, the forward deviations corresponding to the multiple pulse lengths are obtained;
[0008] According to the plurality of pulse lengths and the corresponding forward deviations, fitting a forward deviation function with the pulse length as an independent variable and the forward deviation as a dependent variable;
[0009] The mechanical lens is controlled to advance and retreat, the advance and retreat process of the mechanical lens is compensated according to the advance deviation function, and the reversal deviation is determined according to images with the same sharpness value in the advance process and the retreat process.
[0010] Optionally, determining the reversal deviation according to the image having the same sharpness value in the forward process and the backward process comprises:
[0011] Controlling the mechanical lens to move forward multiple times, and obtaining a first image sharpness value after each movement;
[0012] Controlling the mechanical lens to retreat multiple times, and obtaining a second image sharpness value after each retreat;
[0013] The reversal deviation of the mechanical lens is determined according to the first image sharpness value and the second image sharpness value.
[0014] Optionally, determining the reversal deviation of the mechanical lens according to the first image sharpness value and the second image sharpness value comprises:
[0015] According to the first image sharpness value and the number of forward pulses at the corresponding position, a first sharpness function of the first image sharpness value and the number of forward pulses is fitted; according to the second image sharpness value and the number of forward pulses at the corresponding position, a second sharpness function of the second image sharpness value and the number of forward pulses is fitted;
[0016] Acquire a first forward pulse number corresponding to the position where the first sharpness function extreme value is located and a second forward pulse number corresponding to the position where the second sharpness function extreme value is located;
[0017] The difference between the first forward pulse number and the second forward pulse number is calculated to obtain the reversal deviation of the mechanical lens.
[0018] Optionally, fitting the second sharpness function of the second image sharpness value and the number of forward pulses according to the second image sharpness value and the number of forward pulses at the corresponding position comprises:
[0019] The number of forward pulses at the position of the mechanical lens at the end of the forward movement is successively subtracted from the number of backward pulses during each retreat to determine the number of forward pulses corresponding to the sharpness value of the second image after each retreat.
[0020] Optionally, fitting a first sharpness function of the first image sharpness value and the number of forward pulses at a corresponding position includes:
[0021] Initialize the quadratic polynomial with the number of forward pulses as the independent variable and the first image sharpness value as the dependent variable;
[0022] Calculating a residual sum of squares function according to the quadratic polynomial;
[0023] The constant parameters of the quadratic polynomial are calculated according to the residual square sum function.
[0024] Optionally, fitting a forward deviation function with the pulse length as an independent variable and the forward deviation as a dependent variable according to the multiple pulse lengths and the corresponding forward deviations includes:
[0025] The quadratic polynomial is randomly initialized with pulse length as the independent variable and forward deviation as the dependent variable;
[0026] Calculating prediction deviations corresponding to a plurality of pulse lengths according to the quadratic polynomial;
[0027] Using a mean square error function as a loss function, calculating the precision loss of the prediction deviation and the forward deviation;
[0028] When the precision loss is not in a convergence state, the constant parameters of the quadratic polynomial are updated according to a preset learning rate and the step of calculating the prediction deviations corresponding to the multiple pulse lengths according to the quadratic polynomial is returned.
[0029] Optionally, the method of acquiring the total number of first motion pulses of the mechanical lens from the start position to the end position according to a single pulse comprises:
[0030] Controlling the mechanical lens to retreat until a starting position sensor of the mechanical lens sends a limit signal;
[0031] Sending out single pulses multiple times to drive the mechanical lens forward until an end position sensor of the mechanical lens sends out a limit signal;
[0032] The number of single pulses emitted by the mechanical lens during its forward movement is obtained as the total number of first motion pulses.
[0033] Optionally, the step of obtaining the total number of second motion pulses of the mechanical lens moving from the start position to the end position under multiple pulse lengths comprises:
[0034] Controlling the mechanical lens to retreat until a starting position sensor of the mechanical lens sends a limit signal;
[0035] According to one of a plurality of pulse lengths, pulses are sent multiple times to drive the mechanical lens forward until an end position sensor of the mechanical lens sends a limit signal;
[0036] Obtaining the number of pulses emitted by the mechanical lens during its forward movement;
[0037] The total number of second motion pulses is determined based on the pulse number and the pulse length.
[0038] Optionally, determining the total number of second motion pulses according to the number of pulses and the pulse length comprises:
[0039] Acquire the number of pulses actually driving the mechanical lens to move when the pulse is last emitted as the number of compensation pulses;
[0040] Subtract one from the number of pulses to obtain the number of complete pulses;
[0041] The total number of second motion pulses is obtained by multiplying the number of complete pulses by the pulse length and then adding the number of compensating pulses.
[0042] Optionally, obtaining the forward deviations corresponding to the multiple pulse lengths according to the total number of second motion pulses and the total number of first motion pulses corresponding to the multiple pulse lengths comprises:
[0043] The total number of the first motion pulses is subtracted from the total number of the second motion pulses to obtain a motion pulse difference;
[0044] The ratio of the motion pulse difference to the number of complete pulses is calculated to obtain the forward deviation.
[0045] In the technical solution provided by the present invention, the forward deviation can be effectively obtained according to the length of the forward pulse by fitting the forward deviation, which is beneficial to the compensation of the forward deviation. At the same time, the sharpness of the image is also used to calculate the deviation (i.e., the reversal deviation) in the process of mechanical lens retreat, which is beneficial to the mechanical lens to compensate for the deviation after experiencing multiple advances and retreats, so that the images captured at the same position have the same clarity. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 This is a flow chart of a method for calculating a mechanical lens deviation according to an embodiment of the present invention;
[0047] Figure 2 A flowchart of calculating a reversal deviation of a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0048] Figure 3 A flowchart of calculating a reversal deviation of a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0049] Figure 4 A flowchart of fitting a first sharpness function in a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0050] Figure 5 A flowchart of fitting a forward deviation function of a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0051] Figure 6 A flowchart of obtaining the total number of first motion pulses in a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0052] Figure 7 A flowchart of obtaining the total number of second motion pulses in a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0053] Figure 8 A flowchart of obtaining the total number of second motion pulses in a method for calculating a mechanical lens deviation according to another embodiment of the present invention;
[0054] Fig. 9 This is a flow chart of calculating the forward deviation of a method for calculating the mechanical lens deviation according to another embodiment of the present invention. DETAILED DESCRIPTION
[0055] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0056] The embodiment of the present invention provides a method for calculating a mechanical lens deviation. Figure 1 As shown, the method includes:
[0057] Step 100, obtaining the total number of first motion pulses of the mechanical lens moving from the start position to the end position according to a single pulse;
[0058] In some embodiments, the mechanical lens sends a number of pulses to the mechanical lens module through an electrical signal. After receiving the pulse signal, the module rotates the motor, and the motor drives the mechanical lens and the camera sensor to move away and closer relative to each other through the gears. Since the number of pulses sent each time is different, the motor speed is the same, resulting in different deviations due to different braking inertia after the motor stops. Secondly, when turning, a fixed steering deviation is generated due to factors such as mechanical structure, processing errors and steering control. In order to determine the total number of pulses in the stroke of the mechanical lens, in this implementation step, the total number of first motion pulses of the mechanical lens from the starting position to the end position is obtained by sending single pulses one by one.
[0059] Step 200, obtaining the total number of second motion pulses of the mechanical lens moving from the start position to the end position under multiple pulse lengths;
[0060] In some embodiments, the deviation caused by mechanical lens motion for different pulse lengths is usually different. Therefore, in an embodiment, the total number of second motion pulses at multiple pulse lengths is obtained to fit the relationship between pulse length and forward deviation.
[0061] Step 300, obtaining the forward deviations corresponding to the plurality of pulse lengths according to the total number of second motion pulses corresponding to the plurality of pulse lengths and the total number of first motion pulses;
[0062] In some embodiments, the difference between the total number of second motion pulses and the total number of first pulses can be used to determine the deviation caused by multiple advances with the same pulse length. In order to obtain the deviation caused by a single time, it is necessary to divide it by the number of times the same pulse length is sent.
[0063] Step 400, fitting a forward deviation function with the pulse length as an independent variable and the forward deviation as a dependent variable according to the plurality of pulse lengths and the corresponding forward deviations;
[0064] In some embodiments, a function can be fitted using multiple pulse lengths and corresponding advance deviations to characterize the relationship between the pulse length and the advance deviation. As a preferred implementation, for example, a quadratic function can be fitted.
[0065] Step 500, controlling the mechanical lens to move forward and backward, compensating the moving forward and backward processes of the mechanical lens according to the moving forward deviation function, and determining the reversal deviation according to images with the same sharpness values during the moving forward process and the backward process.
[0066] In some embodiments, since the sharpness value of the camera will change as the mechanical lens moves forward and backward during the image acquisition process, the position corresponding to the image with the same sharpness value during the camera's forward and backward processes can be determined as the same position, and then the deviation generated during the reversal process can be determined based on the difference between the number of forward pulses calculated during the backward process and the actual number of forward pulses. The number of forward pulses refers to the number of single pulses required to advance from the starting position to the current position.
[0067] In the technical solution provided in the embodiment of the present invention, by fitting the forward deviation, the forward deviation can be effectively obtained according to the length of the forward pulse, which is beneficial to compensate for the forward deviation. At the same time, the sharpness of the image is also used to calculate the deviation (i.e., reversal deviation) in the process of mechanical lens retreat, which is beneficial for the mechanical lens to compensate for the deviation after experiencing multiple advances and retreats, so that the images captured at the same position have the same clarity.
[0068] As an optional implementation, Figure 2 As shown, the determining of the reversal deviation based on the image having the same sharpness value in the forward process and the backward process includes:
[0069] Step 510, controlling the mechanical lens to move forward multiple times, and obtaining a first image sharpness value after each movement;
[0070] Step 520, controlling the mechanical lens to retreat multiple times, and obtaining a second image sharpness value after each retreat;
[0071] Step 530: Determine the reversal deviation of the mechanical lens according to the first image sharpness value and the second image sharpness value.
[0072] In some embodiments, when the mechanical lens moves forward, it can start moving forward from the position with the highest sharpness value, that is, the position where the image is clearest. When the mechanical lens moves backward, the total distance to be moved backward is greater than the total distance to be moved forward, so as to find the position with the highest image sharpness value, that is, the position where the image is clearest. When the first image sharpness value and the second image sharpness value are equal, it can be considered that the position of the mechanical lens is the same. At this time, the reversal deviation caused by the reverse reversal in the process of changing from moving forward to moving backward can be determined.
[0073] As an optional implementation, Figure 3 As shown, determining the reversal deviation of the mechanical lens according to the first image sharpness value and the second image sharpness value includes:
[0074] Step 531, fitting a first sharpness function of the first image sharpness value and the number of forward pulses at the corresponding position according to the first image sharpness value and the number of forward pulses; fitting a second sharpness function of the second image sharpness value and the number of forward pulses according to the second image sharpness value and the number of forward pulses at the corresponding position;
[0075] Step 532, obtaining a first forward pulse number corresponding to the position where the first sharpness function extreme value is located and a second forward pulse number corresponding to the position where the second sharpness function extreme value is located;
[0076] Step 533: Calculate the difference between the first forward pulse number and the second forward pulse number to obtain the reversal deviation of the mechanical lens.
[0077] In some embodiments, after obtaining the first image sharpness value, since the multiple first image sharpness values correspond to different positions of the mechanical lens, that is, correspond to different numbers of forward pulses, the relationship between the first image sharpness and the number of forward pulses can be fitted. Similarly, the relationship between the second image sharpness value and the number of forward pulses can be fitted. The extreme value of the function is the position where the image has the highest sharpness value, that is, the position where the image is clearest. Therefore, it can be considered that the extreme values of the two functions correspond to the same position of the mechanical lens. The second forward pulse number is obtained by subtracting the number of pulses when moving forward and the number of pulses when moving backward before compensating for the reversal deviation.
[0078] As an optional implementation manner, the second sharpness function of fitting the second image sharpness value and the number of forward pulses according to the second image sharpness value and the number of forward pulses at the corresponding position includes:
[0079] The number of forward pulses at the position of the mechanical lens at the end of the forward movement is successively subtracted from the number of backward pulses during each retreat to determine the number of forward pulses corresponding to the sharpness value of the second image after each retreat.
[0080] As an optional implementation, Figure 4As shown, the first sharpness function of fitting the first image sharpness value and the number of forward pulses at the corresponding position includes:
[0081] Step 534, initializing a quadratic polynomial using the number of forward pulses as an independent variable and the first image sharpness value as a dependent variable;
[0082] Step 535, calculating the residual sum of squares function according to the quadratic polynomial;
[0083] Step 536, calculating the constant parameters of the quadratic polynomial according to the residual square sum function.
[0084] In some embodiments, the fitting process may be performed, for example, in the following manner:
[0085] Move from the starting position to X1, X2, X3, X4...X n The image sharpness values f(X1), f(X2), f(X3), f(X4)…f(X n );in, Where N and M are the length and width of the image, L is the brightness of each central pixel, and l i is the brightness of the eight pixels around the central pixel. Based on the above consensus, we can calculate X1, X2, X3, X4…X n The image sharpness values of multiple forward pulse numbers are calculated. After calculation, multiple coordinates are obtained, (X1, Y1), (X2, Y2), (X3, Y3), (X4, Y4), ... (X n , Y n ), where Y n =f(X n ). According to the above coordinates, fit the quadratic polynomial Y = aX 2 +bX+c, after substituting the above coordinates into the quadratic polynomial, we get the following system of equations:
[0086]
[0087] The minimum value of the residual sum of squares is used for calculation, and we get:
[0088]
[0089] Taking partial derivatives of a, b, and c in the aforementioned residual sum of squares function and setting the partial derivative equal to 0, we can obtain:
[0090]
[0091] Furthermore, since the extreme value of the quadratic function is at its symmetry axis, in order to facilitate the calculation of the flip deviation, its symmetry axis can be calculated:
[0092] The relationship between the sharpness value of the second image and the number of forward pulses in the backward process can also be fitted in the above manner, and its symmetry axis is calculated. Let the number of forward pulses corresponding to the symmetry axis of the first sharpness function be x f , the number of forward pulses corresponding to the symmetry axis of the second sharpness function is x b , at this time, the flip deviation D = x f -x b .
[0093] As an optional implementation, Figure 5 As shown, the fitting of the forward deviation function with the pulse length as the independent variable and the forward deviation as the dependent variable according to the plurality of pulse lengths and the corresponding forward deviations includes:
[0094] Step 410, randomly initializing a quadratic polynomial with pulse length as an independent variable and forward deviation as a dependent variable;
[0095] Step 420, calculating prediction deviations corresponding to a plurality of pulse lengths according to the quadratic polynomial;
[0096] Step 430, using a mean square error function as a loss function, calculating the precision loss of the prediction deviation and the forward deviation;
[0097] Step 440, when the precision loss is not in a convergence state, updating the constant parameters of the quadratic polynomial according to a preset learning rate and returning to the step of calculating the prediction deviations corresponding to multiple pulse lengths according to the quadratic polynomial.
[0098] In some embodiments, due to different step deviations, multiple discrete points (k, R) are obtained, and these discrete points are fitted by quadratic polynomials to obtain the forward deviations corresponding to different continuous pulse lengths k. The gradient descent method of quadratic polynomial regression is used for fitting, and the steps are as follows:
[0099] A. Initialize the quadratic polynomial model R = ok 2 +pk+q, randomly initialize o, p, q.
[0100] B. Define the loss function: Define the loss function as the mean square error, that is, the loss function is the average of the squared difference between the predicted value and the actual value of all data points: loss = (1 / m) * Σ (R_pred_j-R_j)^2. Among them, m is the number of data points, and multiple data points can be calculated through multiple pulse lengths. R_pred_j is the dependent variable value predicted by the model. 2 +pk+q, R_j is the actual dependent variable value, that is, the discrete point R.
[0101] C. Calculate the gradient: Calculate the partial derivative of the loss function with respect to the model parameters o, p, q, that is, calculate the gradient of the loss function. For the quadratic polynomial model, the following gradient calculation formula can be obtained:
[0102] dloss / do=(2 / m)*Σ((o*k_i^2+p*k_i+q-R_i)*k_i^2);
[0103] dloss / dp=(2 / m)*Σ((o*k_i^2+p*k_i+q-R_i)*k_i);
[0104] dloss / dq=(2 / m)*Σ(o*k_i^2+p*k_i+c-R_i); where k_i is the independent variable value of the i-th data point, and R_i is the actual dependent variable value.
[0105] D. Update model parameters: Update model parameters o, p, q according to the direction of the gradient and the learning rate. The learning rate can control the step size of each update. The update rules are as follows:
[0106] o = o - learning_rate * dloss / do
[0107] p = p - learning_rate * dloss / dp
[0108] q = q - learning_rate * dloss / dq
[0109] Among them, learning_rate is the learning rate, which determines the magnitude of each update. For example, the learning rate can be defined as 0.05.
[0110] E. Repeat steps C and D: Repeat the steps of calculating gradients and updating model parameters until convergence conditions are reached or the maximum number of iterations is reached, where the maximum number of iterations is set to 1000.
[0111] Through the above steps, a quadratic polynomial of the forward deviation is fitted, namely the forward deviation.
[0112] As an optional implementation, Figure 6 As shown, the total number of first motion pulses of the mechanical lens from the start position to the end position according to a single pulse includes:
[0113] Step 110, controlling the mechanical lens to retreat until the starting position sensor of the mechanical lens sends a limit signal;
[0114] Step 120, sending out single pulses multiple times to drive the mechanical lens forward until the end position sensor of the mechanical lens sends out a limit signal;
[0115] Step 130 , obtaining the number of single pulses emitted by the mechanical lens during its forward movement as the total number of first motion pulses.
[0116] In some embodiments, sensors are added at both ends of the path of the mechanical lens movement. The sensors may be, for example, photoelectric sensors or pressure sensors. IO limits are made through these sensors, one as a low limit and the other as a high limit. Through the output of the IO limit signal, the start and end positions of the mechanical lens can be accurately defined, and the pulse output can be stopped in time, so that the specific number of movement pulses of the mechanical lens can be accurately calculated. When recording the total number of the first movement pulses that can be adjusted between the high and low limits, 1 pulse is continuously given, and the total number of movement pulses M of the mechanical lens from the low limit to the high limit is recorded.
[0117] As an optional implementation, Figure 7 As shown, the total number of second motion pulses of the mechanical lens moving from the start position to the end position under multiple pulse lengths is obtained, which includes:
[0118] Step 210, controlling the mechanical lens to retreat until the starting position sensor of the mechanical lens sends a limit signal;
[0119] Step 220, according to one of a plurality of pulse lengths, multiple pulses are sent to drive the mechanical lens forward until the end position sensor of the mechanical lens sends a limit signal;
[0120] Step 230, obtaining the number of pulses emitted by the mechanical lens during its forward movement;
[0121] Step 240, determining the total number of second motion pulses according to the pulse number and the pulse length.
[0122] As an optional implementation, Figure 8 As shown, the determining the total number of second motion pulses according to the number of pulses and the pulse length comprises:
[0123] Step 241, obtaining the number of pulses actually driving the mechanical lens to move when the pulse is emitted for the last time as the number of compensation pulses;
[0124] Step 242, subtracting one from the pulse number to obtain the complete pulse number;
[0125] Step 243, multiplying the number of complete pulses by the pulse length, and then adding the number of compensating pulses to obtain the total number of second motion pulses.
[0126] In some embodiments, according to the total number of mechanical lens pulses, the number of continuous pulses with a pulse length of x is recorded, and the number of continuous pulses with a pulse length of k is recorded. The total number of pulses moving from the low limit to the high limit is M. k =k*T+β, where β is the supplementary pulse after the number of pulses k is insufficient, which can be obtained by the mechanical lens movement after T times k pulses.
[0127] As an optional implementation, Fig. 9 As shown, the forward deviation corresponding to the plurality of pulse lengths is obtained based on the total number of second motion pulses and the total number of first motion pulses corresponding to the plurality of pulse lengths, including:
[0128] Step 310, subtracting the total number of second motion pulses from the total number of the first motion pulses to obtain a motion pulse difference;
[0129] Step 320, calculating the ratio of the motion pulse difference to the number of complete pulses to obtain the forward deviation.
[0130] In some embodiments, the forward deviation R=(MM k ) / T, since the motion process corresponding to the compensation pulse number β does not involve the deceleration process of the mechanical lens, it can be considered that there is no forward deviation in the β pulses. Therefore, this part of the deviation is not considered, and the ratio of the motion pulse difference to the complete pulse number is taken as the forward deviation, that is, the deviation generated in the process of driving the mechanical lens forward with continuous pulses with a pulse length of k is calculated.
[0131] In the technical solution provided by the present invention, the mechanical lens can accurately identify the position where the electrode needs to be moved without the need for an encoder, ensuring that the image clarity captured by the camera at the same position is consistent. At the same time, since no encoder is required, the equipment cost can be effectively reduced. In the technical solution provided by the present invention, the number of pulses required for the complete stroke of the mechanical lens is first collected, and then the total number of second motion pulses obtained by each pulse length can effectively obtain the deviation generated by the mechanical lens during the unidirectional movement. After reversing the direction of movement, the position of the mechanical lens is judged by the sharpness of the collected image, and then the deviation generated during the reversal process is obtained. Therefore, the forward deviation and reversal deviation generated under different pulse lengths can be accurately fitted, and the encoder is not required to judge the lens position.
[0132] Those skilled in the art can understand that all or part of the processes in the above method embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes in the above method embodiments. The storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0133] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for calculating mechanical lens deviation, characterized in that: The method comprises: Acquire the total number of first motion pulses of the mechanical lens moving from the start position to the end position according to a single pulse; Obtaining the total number of second motion pulses of the mechanical lens moving from the start position to the end position under multiple pulse lengths; According to the total number of second motion pulses corresponding to the multiple pulse lengths and the total number of the first motion pulses, the forward deviations corresponding to the multiple pulse lengths are obtained; According to the plurality of pulse lengths and the corresponding forward deviations, fitting a forward deviation function with the pulse length as an independent variable and the forward deviation as a dependent variable; Controlling the mechanical lens to move forward and backward, compensating the moving forward and backward processes of the mechanical lens according to the moving forward deviation function, and determining the reversal deviation according to images having the same sharpness value during the moving forward process and the backward process; Wherein, the step of fitting a forward deviation function with the pulse length as an independent variable and the forward deviation as a dependent variable according to the plurality of pulse lengths and the corresponding forward deviations comprises: The quadratic polynomial is randomly initialized with pulse length as the independent variable and forward deviation as the dependent variable; Calculating prediction deviations corresponding to a plurality of pulse lengths according to the quadratic polynomial; Using a mean square error function as a loss function, calculating the precision loss of the prediction deviation and the forward deviation; When the precision loss is not in a convergence state, the constant parameters of the quadratic polynomial are updated according to a preset learning rate and the step of calculating the prediction deviations corresponding to the multiple pulse lengths according to the quadratic polynomial is returned.
2. The method according to claim 1, characterized in that Determining the reversal deviation according to the image having the same sharpness value in the forward process and the backward process comprises: Controlling the mechanical lens to move forward multiple times, and obtaining a first image sharpness value after each movement; Controlling the mechanical lens to retreat multiple times, and obtaining a second image sharpness value after each retreat; A reversal deviation of the mechanical lens is determined according to the first image sharpness value and the second image sharpness value.
3. The method according to claim 2, characterized in that Determining the reversal deviation of the mechanical lens according to the first image sharpness value and the second image sharpness value includes: According to the first image sharpness value and the number of forward pulses at the corresponding position, a first sharpness function of the first image sharpness value and the number of forward pulses is fitted; according to the second image sharpness value and the number of forward pulses at the corresponding position, a second sharpness function of the second image sharpness value and the number of forward pulses is fitted; Acquire a first forward pulse number corresponding to a position where the extreme value of the first sharpness function is located and a second forward pulse number corresponding to a position where the extreme value of the second sharpness function is located; The difference between the first forward pulse number and the second forward pulse number is calculated to obtain the reversal deviation of the mechanical lens.
4. The method according to claim 3, characterized in that The step of fitting the second image sharpness value and the second sharpness function of the forward pulse number according to the second image sharpness value and the forward pulse number at the corresponding position comprises: The number of forward pulses at the position of the mechanical lens at the end of the forward movement is successively subtracted from the number of backward pulses during each retreat to determine the number of forward pulses corresponding to the sharpness value of the second image after each retreat.
5. The method according to claim 3, characterized in that: The step of fitting the first image sharpness value and the first sharpness function of the forward pulse number according to the first image sharpness value and the forward pulse number at the corresponding position comprises: Initialize the quadratic polynomial with the number of forward pulses as the independent variable and the first image sharpness value as the dependent variable; Calculating a residual sum of squares function according to the quadratic polynomial; The constant parameters of the quadratic polynomial are calculated according to the residual square sum function.
6. The method according to claim 1, characterized in that The total number of first movement pulses of the mechanical lens moving from the start position to the end position according to a single pulse comprises: Controlling the mechanical lens to retreat until a starting position sensor of the mechanical lens sends a limit signal; Sending out single pulses multiple times to drive the mechanical lens forward until an end position sensor of the mechanical lens sends out a limit signal; The number of single pulses emitted by the mechanical lens during its forward movement is obtained as the total number of the first motion pulses.
7. The method according to claim 1, characterized in that The method of obtaining the total number of second motion pulses of the mechanical lens from the start position to the end position under multiple pulse lengths comprises: Controlling the mechanical lens to retreat until a starting position sensor of the mechanical lens sends a limit signal; According to one of a plurality of pulse lengths, pulses are sent multiple times to drive the mechanical lens forward until an end position sensor of the mechanical lens sends a limit signal; Obtaining the number of pulses emitted by the mechanical lens during its forward movement; The total number of the second motion pulses is determined based on the pulse number and the pulse length.
8. The method according to claim 7, characterized in that Determining the total number of the second motion pulses according to the number of pulses and the pulse length comprises: Acquire the number of pulses actually driving the mechanical lens to move when the pulse is last emitted as the number of compensation pulses; Subtract one from the number of pulses to obtain the number of complete pulses; The total number of the second motion pulses is obtained by multiplying the number of complete pulses by the pulse length and then adding the number of compensating pulses.
9. The method according to claim 8, characterized in that The method of obtaining the forward deviations corresponding to the plurality of pulse lengths according to the total number of second motion pulses and the total number of first motion pulses corresponding to the plurality of pulse lengths comprises: The total number of the first motion pulses is subtracted from the total number of the second motion pulses to obtain a motion pulse difference; The ratio of the motion pulse difference to the number of complete pulses is calculated to obtain the forward deviation.
Citation Information
Patent Citations
Direct-current motor focusing method and device, terminal device and storage medium
CN111246082A
Camera equipment lens focusing method and device, camera equipment and storage medium
CN114302053A