Automatic focusing method and device and imaging system

By combining prediction and measurement position correction technology, the problems of low DC motor driving accuracy and inaccurate feedback of magnetic encoder in ultra-telephoto imaging system are solved, and accurate focus of the imaging system is achieved.

CN119255103APending Publication Date: 2025-01-03ZHEJIANG HEALNOC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411296424.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-14
Publication Date
2025-01-03

AI Technical Summary

Technical Problem

During the automatic focus process, the existing ultra-telephoto imaging system cannot accurately focus due to the large driving torque of the DC motor but poor accuracy, and the inaccurate position feedback of the magnetic encoder.

Method used

By combining the predicted position and measured position of the motor, the difference between the predicted position and the observed position is used for weight assignment and correction, and the motor position is corrected in real time to ensure that the motor runs accurately to the target position and achieve focus.

Benefits of technology

It improves the focus accuracy and real-time performance of the imaging system, and solves the problem that the ultra-telephoto imaging system cannot focus accurately.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119255103A_ABST
    Figure CN119255103A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic focusing method and device and an imaging system, and the method comprises the steps: operating a motor, and determining whether the imaging system is in a preset state or not according to an image obtained by a lens; when the imaging system is in a preset state, predicting the predicted position of the motor at the current moment according to the operation parameters of the motor at the previous moment, and measuring to obtain the observation position of the motor at the current moment; combining the prediction position and the observation position to obtain a target position of the motor; and operating the motor until the motor reaches the target position. By adopting the method, the technical problem that an imaging system cannot accurately focus can be solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of camera technology, and in particular to an automatic focusing method, device and imaging system. Background Art

[0002] In recent years, with the rapid development of medical images and users' demand for high-definition images, especially in the field of neurosurgery microscopy, it is usually necessary to use ultra-telephoto and high-power lens sets so that users can observe tissue lesions more carefully and improve the accuracy of surgery. However, in ultra-telephoto imaging systems, the depth of field of the image will decrease. The actual depth of field that users can see clearly may be only 2 to 3 mm. Due to the shallow depth of field, users need to adjust the focus frequently to ensure a clear image. Therefore, in order to provide users with more convenient surgical field focus adjustment, autofocus technology will be used to meet users' frequent focusing needs.

[0003] The commonly used autofocus methods in related technologies are all equipped with a focus motor to adjust the focus. The algorithm determines the clarity of the image, guides the stepper motor to rotate through the rotor, and then links the focus lens group to move forward and backward to adjust the image focus. For ordinary lens groups, when the motor driving accuracy requirements are relatively high, a stepper motor can be used. However, for ultra-telephoto lens groups, due to the large size of the lens group, the driving torque of the stepper motor is generally not enough, and a DC motor is required to drive the lens. However, the driving torque of the DC motor is large but the accuracy is poor. In addition, the DC motor generally needs to be equipped with a magnetic encoder for position indication, but the position accuracy of the magnetic encoder will be affected by its own design reasons, and it cannot provide a higher resolution. In addition, the encoder is not synchronized with the motor shaft, electromagnetic interference and other reasons will cause the motor position feedback to be untimely and the feedback accuracy to be low. This is contrary to the requirement of the autofocus algorithm to obtain the lens position information in real time and accurately, resulting in the problem that the imaging system cannot focus on the clear position of the picture.

[0004] With regard to the problem in the related art that the imaging system cannot focus accurately, no effective solution has been proposed yet. Summary of the invention

[0005] Based on this, it is necessary to provide an automatic focusing method, device and imaging system that can solve the problem that the imaging system cannot focus accurately in response to the above technical problems.

[0006] In a first aspect, an automatic focusing method is provided in this embodiment, wherein an imaging system includes a motor and a lens, and the method includes:

[0007] running the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens;

[0008] When the imaging system is in a preset state, the predicted position of the motor at the current moment is predicted according to the operating parameters of the motor at the previous moment, and the observed position of the motor at the current moment is measured;

[0009] Combining the predicted position and the observed position to obtain a target position of the motor;

[0010] The motor is operated until the motor reaches the target position.

[0011] In some embodiments, combining the predicted position and the observed position to obtain the target position includes:

[0012] Obtaining a difference between the predicted position and the observed position;

[0013] Obtaining a weight of the difference according to a covariance matrix of the motor position at a previous moment predicted, noise when predicting the predicted position of the motor, and a measurement error of the observed position;

[0014] Obtaining a correction value according to the weight and the difference;

[0015] The predicted position is corrected based on the correction value to obtain the target position.

[0016] In some embodiments, predicting the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment includes:

[0017] The predicted position of the motor at the current moment is predicted based on the position, running speed and moving direction of the motor at the previous moment.

[0018] In some embodiments, the imaging system further includes a position encoder, and the observed position of the motor at the current moment obtained by the measurement includes:

[0019] Obtaining a measurement value output by the position encoder;

[0020] The observed position is obtained by combining the measurement error and the measurement value.

[0021] In some embodiments, the operating the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens includes:

[0022] Running the motor based on the first running direction until the difference between the clarity of adjacent frame images acquired by the lens meets a first threshold condition, and adjusting the first running direction of the lens;

[0023] Running the motor based on the adjusted first running direction until the difference between the clarity levels of adjacent frame images acquired by the lens meets the first threshold condition again, and obtaining the motor running range according to the position of the motor when the first threshold condition is met;

[0024] According to the clarity of the image acquired by the lens within the operating range of the motor, it is determined that the imaging system is in the preset state.

[0025] In some embodiments, after the motor is operated based on the adjusted first operating direction until the difference between the clarity levels of adjacent frame images acquired by the lens again satisfies the first threshold condition, the method further includes:

[0026] operating the motor based on a second operating direction, the second operating direction being opposite to the first operating direction;

[0027] When the difference between the clarity of adjacent frame images captured by the lens meets a second threshold condition, the preset state of the imaging system is obtained according to the clarity of the image captured by the lens during the operation of the motor.

[0028] In some embodiments, operating the motor to the target position includes:

[0029] The motor is operated based on a third operating direction until the motor reaches the target position; wherein the third operating direction is opposite to the operating direction of the motor at a previous moment.

[0030] In some of the embodiments, the operating speed of the motor when the motor is operated to the target position is less than the operating speed of the motor before the target position is obtained.

[0031] In a second aspect, an autofocus device is provided in this embodiment, wherein the imaging system includes a motor and a lens, and the device includes:

[0032] A focusing module, used for operating the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens;

[0033] A position acquisition module, used for predicting the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment when the imaging system is in a preset state, and measuring the observed position of the motor at the current moment;

[0034] A position correction module, used to obtain a target position of the motor by combining the predicted position and the observed position;

[0035] An operating module is used to operate the motor until the motor reaches the target position.

[0036] In a third aspect, an imaging system is provided in this embodiment, wherein the imaging system comprises a motor, a lens, a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the autofocus method described in the first aspect is implemented.

[0037] The above-mentioned automatic focusing method, device and imaging system, by combining the predicted position obtained by prediction and the observed position obtained by measurement, correct the actual position of the motor in real time, timely and accurately obtain the target position of the motor when the imaging system is in a preset state, and run the motor to the target position so that the imaging system can focus accurately, thereby solving the technical problem that the imaging system cannot focus accurately. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] Figure 1 A schematic diagram of a flow chart of an automatic focusing method according to an embodiment;

[0039] Figure 2 is a schematic flow chart of an automatic focusing method in another embodiment;

[0040] Figure 3 is a flow chart of a motor position processing method in one embodiment;

[0041] Figure 4 is a flowchart of a focus search method in one embodiment;

[0042] Figure 5 is a structural block diagram of an automatic focusing device in one embodiment;

[0043] Figure 6 FIG. 4 is a structural block diagram of an imaging system in one embodiment. DETAILED DESCRIPTION

[0044] 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.

[0045] In the related art, most autofocus algorithms use the hill climbing method to iteratively drive the motor, so that the lens moves and finds the clearest position of the image based on the real-time acquisition of the image clarity of each frame, thereby guiding the movement of the lens group. After the lens group repeatedly turns back near the peak of the image clarity, the lens group stops at the clearest image position to complete the focus. This algorithm has high requirements for the accuracy of obtaining the position of the lens group during the movement of the lens group. Otherwise, the number of steps that the algorithm takes to turn back over the peak is large, and the image jitter is large during the focusing process. In addition, this algorithm needs to control the lens group to stop at the clearest position during the search process. Due to the inaccurate position of the magnetic encoding, there is often a situation where the lens group cannot stop at the clearest position of the image.

[0046] In one embodiment, Figure 1 As shown, an automatic focusing method is provided, wherein the imaging system includes a motor and a lens, and includes the following steps:

[0047] Step S102, running the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens.

[0048] The motor in the imaging system is connected to the lens, and the lens is driven by the operation of the motor and moves with the operation of the motor. When the direction of the motor changes, the direction of movement of the lens changes accordingly. The lens in the imaging system can be a single lens or a lens group composed of multiple lenses. Optionally, the lens captures an image during the operation of the motor. The lens can continuously acquire images or sample the captured images based on a specified time interval, and determine whether the imaging system is focused based on the sampled images.

[0049] Optionally, one or more image features such as image clarity value, contrast, image frequency characteristics, etc. may be obtained to determine whether the imaging system is in a preset state. When the image clarity value reaches a maximum value during the operation of the motor, or the frequency of the object to be focused in the image is concentrated and reaches a maximum value, it can be determined that the imaging system is in a preset state at this moment.

[0050] Optionally, the motor moves within a movable range, and by comparing the change trend of the clarity between adjacent frames of images obtained by the lens during the movement of the motor, it is determined whether the imaging system is in a preset state. It is understandable that if the position of the motor at the moment when the imaging system is in a preset state can be accurately obtained, and the motor is controlled to move to this position, the clearest image can be obtained, and the imaging system can complete the focus.

[0051] Step S104, when the imaging system is in a preset state, the predicted position of the motor at the current moment is predicted according to the operating parameters of the motor at the previous moment, and the observed position of the motor at the current moment is measured.

[0052] The operating parameters of the motor at the last moment include, but are not limited to, the motor operating speed, operating direction, operating acceleration, motor position, etc. The operating parameters at the last moment are the operating parameters of the motor at the moment before the imaging system is in the preset state.

[0053] Optionally, the motor position at the current moment, that is, when the imaging system is in a preset state, can be detected by a device with a position detection function such as a magnetic encoder, an optical encoder, or a Hall sensor in the imaging system to obtain the observed position.

[0054] Step S106, combining the predicted position and the observed position to obtain the target position of the motor.

[0055] Among them, although the observed position is the measured motor position, there is a situation where the measuring device is not synchronized with the motor shaft. When the measuring device is a magnetic encoder or Hall sensor, it will also be affected by factors such as electromagnetic interference, resulting in inaccurate observed position. Therefore, it is necessary to correct the motor position by combining the predicted position and the observed position.

[0056] Among them, the combination of predicted position and observed position can be achieved based on any of the following methods:

[0057] Optionally, different weights may be assigned to the predicted position and the observed position to obtain the target position of the motor. For example, the predicted position and the observed position are weighted and summed to obtain the target position of the motor. The difference between the predicted position and the observed position may also be obtained, and a corresponding weight may be assigned to the difference between the predicted position and the observed position. Based on the result of multiplying the difference and the weight, the predicted position is corrected to obtain the target position. For example, the result of multiplying the difference and the weight is added to the predicted position to obtain the target position.

[0058] Optionally, a mapping relationship among the predicted position, the observed position and the target position is obtained through actual test calibration, and then the predicted position and the observed position are mapped based on the calibrated mapping relationship to obtain the target position.

[0059] Optionally, based on Bayesian filtering, Kalman filtering or particle filtering methods, the motor operating state at the current moment is predicted, and the predicted position is updated and corrected according to the observed position measured at the current moment, so as to estimate the target position at the current moment.

[0060] Step S108, running the motor until the motor reaches the target position.

[0061] Optionally, the running direction and speed of the motor are obtained according to the target position and the current position of the motor, and the motor position is continuously detected until the motor runs to the target position. Alternatively, when the distance between the motor position and the target position is less than a specified threshold, it is determined that the motor is running to the target position.

[0062] Optionally, in the process of running the motor to the target position, the position of the motor can also be predicted and measured based on the same method as step S104 and step S106, and the predicted result and measured result of the motor position can be combined to obtain the corrected position of the motor. When the corrected position of the motor coincides with the target position, or the coincidence between the corrected position of the motor and the target position is less than a specified threshold, it is judged that the motor has reached the target position and the automatic focusing of the imaging system is completed, thereby avoiding the situation in which the lens group repeatedly turns back near the image focus position and the focus jitters during the process of the motor driving the lens group to move.

[0063] Furthermore, while the motor is running in step S102 , the position of the motor during the movement may be predicted and measured by the same method as in step S104 and step S106 .

[0064] In the above-mentioned automatic focusing method, the moment when the imaging system is in a preset state is obtained according to the image obtained by the lens during the operation of the motor. The predicted position of the motor when the imaging system is in the preset state is predicted, and the observed position of the motor when the imaging system is in the preset state is measured at the same time. The predicted position obtained by prediction and the observed position obtained by measurement are combined to correct the position of the motor, so that the target position of the motor when the imaging system is focused can be obtained in a timely and accurate manner, thereby completing the automatic focusing, improving the real-time accuracy of the motor position, and solving the technical problem that the imaging system cannot focus accurately.

[0065] In one embodiment, predicting the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment includes: predicting the predicted position of the motor at the current moment according to the position, operating speed and movement direction of the motor at the previous moment.

[0066] The position of the motor at the last moment may be the position measured at the last moment or the position predicted. In order to improve the accuracy of the predicted position, the position of the motor at the last moment may be obtained based on the same method as the target position: combining the predicted position of the motor at the last moment and the observed position of the motor at the last moment to obtain the corrected position of the motor at the last moment.

[0067] In this embodiment, the motor position at the current moment can be predicted more accurately through the motor operating parameters at the previous moment, thereby improving the accuracy of obtaining the predicted position.

[0068] In one embodiment, the imaging system further includes a position encoder, and the observed position of the motor at the current moment obtained by measuring includes: obtaining a measurement value output by the position encoder; and obtaining the observed position by combining the measurement error and the measurement value.

[0069] The position encoder may be a magnetic encoder, a grating encoder, an inductive encoder, etc. The measurement error may be a random variable distribution or a constant, and the measurement error may be obtained by debugging through multiple tests, or the measurement error may be modified according to user requirements.

[0070] Optionally, the measurement error is a measurement noise error of the position encoder. The measurement value and the measurement error are added to obtain the observed position. It is understandable that the measurement value and the measurement error can also be combined by an existing error compensation algorithm to obtain the observed position.

[0071] In this embodiment, considering that there is an error in the measurement of the position encoder, the measurement value is corrected by measuring the error to improve the accuracy of obtaining the observed position.

[0072] In one embodiment, combining the predicted position and observed position of the motor at the current moment to obtain the target position of the motor at the current moment includes: obtaining the difference between the predicted position and the observed position; obtaining the weight of the difference based on the covariance matrix of the motor position at the previous moment, the noise when predicting the predicted position of the motor and the measurement error of the observed position; obtaining a correction value based on the weight and the difference; and correcting the predicted position based on the correction value to obtain the target position.

[0073] Among them, the motor position at the last moment is obtained by combining the motor predicted position at the last moment and the motor observed position at the last moment, and the covariance matrix is ​​calculated based on the motor position at the last moment. The noise when predicting the predicted position of the motor and the measurement error of the observed position can be a constant or a random variable distribution, which can be obtained through the debugging of the imaging system.

[0074] Among them, the covariance matrix of the motor position at the last moment is used to indicate the uncertainty of the value of the motor position at the last moment. According to the covariance matrix of the motor position at the last moment and the noise when predicting the predicted position of the motor, the prediction uncertainty of the predicted position can be obtained. The measurement error is used to indicate the measurement accuracy of the observed position. Therefore, the weight between the predicted position and the observed position can be determined by combining the covariance matrix of the motor position at the last moment, the noise when predicting the predicted position of the motor and the measurement error of the observed position.

[0075] Optionally, based on the noise of the motor during prediction, the noise covariance Q is calculated. Based on the covariance matrix P of the motor position at the last moment t-1The covariance matrix of the motor position at the current moment is obtained by using the noise covariance Q when predicting the predicted position of the motor

[0076]

[0077] The measurement error variance R is calculated based on the measurement error. According to the covariance matrix of the motor position at the current moment The weight k is calculated by the variance R of the measurement error t :

[0078]

[0079] Multiply the weight by the difference between the predicted position and the observed position to get the correction value. Add the correction value to the predicted position to get the target position.

[0080] In this embodiment, the weight of the difference between the predicted position and the observed position is obtained through the errors in the measurement process and the prediction process, and the predicted position is corrected according to the correction value calculated based on the weight and the difference, thereby improving the real-time accuracy of the target position.

[0081] In one embodiment, running the motor and determining whether the imaging system is in a preset state based on the image captured by the lens includes: running the motor based on a first running direction until the difference between the clarity of adjacent frame images captured by the lens meets a first threshold condition, and adjusting the first running direction of the motor; running the motor based on the adjusted first running direction until the difference between the clarity of adjacent frame images captured by the lens meets the first threshold condition again, and obtaining the motor operating range according to the position of the motor when the first threshold condition is met; and determining whether the imaging system is in a preset state according to the clarity of the image captured by the lens within the motor operating range.

[0082] Among them, the first threshold condition is used to indicate that as the motor runs, the clarity of the image acquired by the lens decreases to a specified level. Optionally, the clarity can be obtained by one or more parameters of clarity value, contrast, and image frequency characteristics. It can be understood that when the clarity of the image is high, the image clarity value is high, the contrast is high, and the frequency corresponding to the focused object in the image is high. The difference between the clarity of adjacent frame images can be determined based on mathematical calculation methods such as the difference and ratio of the adjacent frame images on the above parameters. Optionally, when the difference in clarity value between the subsequent frame image and the previous frame image is within a specified threshold range, it is judged that the first threshold condition is met. Alternatively, it is also possible to judge that the first threshold condition is met when the ratio between the clarity values ​​of adjacent frame images is within a specified threshold range.

[0083] Therefore, after the difference between the clarity of adjacent frame images acquired by the lens meets the first threshold condition, it can be determined that the lens is moving away from the focus position and the first running direction needs to be adjusted. After adjusting the first running direction, the clarity of the image acquired by the lens will gradually increase and the lens will approach the focus position until the difference between the clarity of adjacent frame images acquired by the lens meets the first threshold condition again. It is then determined that the clarity of the image acquired by the lens begins to decrease to a specified degree again, that is, the lens begins to move away from the focus position again. The position of the motor when the preset condition is met twice is taken as the endpoint, and the motor operating range is constructed based on the operating range within the endpoint. When the motor moves within the motor operating range, the search range of the preset state can be narrowed.

[0084] In this embodiment, by repeatedly judging whether the first threshold condition is met, the motor range of the imaging system during autofocusing is obtained, the motor search range is narrowed, and the preset state of the imaging system is obtained according to the image clarity within a smaller search range, thereby achieving the effect of quickly and accurately obtaining the preset state of the imaging system.

[0085] After obtaining the motor operation range, optionally, the clarity of the image captured by the lens within the motor operation range is obtained, and the moment when the image captured by the lens reaches a maximum clarity value is determined as the moment when the imaging system is in a preset state.

[0086] In order to further improve the accuracy of determining whether the imaging system is in a preset state, in one embodiment, after running the motor based on the adjusted first running direction until the difference between the clarity of adjacent frame images acquired by the lens meets the first threshold condition again, the method further includes: running the motor based on a second running direction, the second running direction being opposite to the first running direction; and obtaining the preset state of the imaging system according to the clarity of the image acquired by the lens during the operation of the motor when the difference between the clarity of adjacent frame images acquired by the lens meets the second threshold condition.

[0087] Among them, the threshold range corresponding to the second threshold condition is smaller than the threshold range corresponding to the first threshold condition, so that the motor position range obtained when the image clarity meets the second threshold condition is smaller than the motor position range obtained when the image clarity meets the first threshold condition.

[0088] Optionally, get the clarity value fv of the previous frame lst , and the image clarity value fv of the current frame cur . Calculate the clarity value of the current frame and the clarity value of the previous frame fv lst The ratio value R:

[0089]

[0090] When R is less than or equal to the first threshold, it is determined that the first threshold condition is met. The first running direction is adjusted to the opposite direction until the difference between the clarity of adjacent frame images acquired by the lens meets the first threshold condition again. The motor is set to move in the opposite direction of the first running direction of the previous stage, that is, the second running direction. When the motor moves based on the second running direction, the ratio R is also calculated, and when R is less than or equal to the second threshold, it is determined that the second threshold condition is met. Among them, the second threshold is less than the first threshold.

[0091] Optionally, when the difference between the clarity of adjacent frames of images captured by the lens meets the second threshold condition, the clarity value of multiple frames of images captured by the lens during the operation of the motor based on the second operation direction is obtained. When it is determined that the image captured by the lens reaches the maximum clarity value, the imaging system is in a preset state and the motor position is in a focusing position.

[0092] Further, after the motor is operated based on the second operating direction, if the difference between the clarity of adjacent frame images acquired by the lens cannot meet the second threshold condition, the motor position fp when the difference between the clarity of adjacent frame images acquired by the lens first meets the first threshold condition can be obtained. limit Among them, the motor position fp limit It can be obtained in the same way as the target position. The motor is operated in the second operating direction and the position of the motor reaches fp limit , the motor is stopped. And according to the clarity of the image acquired by the lens during the operation of the motor based on the second operation direction, the preset state of the imaging system is obtained.

[0093] In this embodiment, the second threshold condition is used to narrow the motor operation range, thereby improving the focusing accuracy and reducing the number of image frames involved in determining the preset state of the imaging system, thereby improving the real-time performance of the motor position acquisition.

[0094] Furthermore, when judging whether adjacent frames of images meet the first threshold condition, the image frames acquired by the lens are sampled based on the first time interval; when judging whether adjacent frames of images meet the second threshold condition, the image frames acquired by the lens are sampled based on the second time interval. The first time interval is greater than the second time interval. With such a setting, a rough search of the preset state can be firstly realized based on the first threshold condition, and then a fine search of the preset state can be realized based on the second threshold condition, thereby improving the efficiency of the preset state judgment.

[0095] In one embodiment, running the motor to the target position includes: running the motor based on a third running direction until the motor runs to the target position; wherein the third running direction is opposite to the running direction of the motor at the previous moment.

[0096] When the imaging system is determined to be in a preset state by running the motor, the motor operation will exceed the peak value of the image clarity. Therefore, based on the running direction when determining whether the imaging system is in the preset state, that is, the opposite direction of the running direction at the previous moment, a third running direction is obtained, and the motor is operated based on the third running direction. In this embodiment, the movement direction of the motor when it runs to the focus position is quickly obtained through the running direction at the previous moment, which can improve the focusing speed.

[0097] Furthermore, in one embodiment, the operation speed of the motor when the motor is running to the target position is less than the operation speed of the motor before the target position is obtained. The operation speed of the motor when the motor is running to the target position can be set according to the application requirements. For example, the greater the motor load, the lower the speed; the smaller the motor load, the speed can be increased accordingly. The motor drives the lens to run, and the inertia exists, which may cause the motor to pass the target position. In this embodiment, by reducing the operation speed of the motor, the motor can be accurately placed at the target position.

[0098] Optionally, the motor movement can be stopped in advance when the motor reaches a target position based on real-time motor position feedback.

[0099] In one embodiment, Figure 2 A flowchart of another autofocus method is provided, such as Figure 2 The following steps are shown:

[0100] Step S201, initializing the motor. Optionally, the running speed of the motor is set, the initial running direction of the motor is set, and the motor is started.

[0101] Step S202, motor position processing. Due to the accuracy of the magnetic encoder itself, it is difficult to update the motor position in real time and accurately. Therefore, after the magnetic encoder obtains the motor position, it cannot be used directly as the motor position. Instead, the predicted position of the motor at the current moment and the observed position of the motor are needed to obtain the optimal estimated position of the motor, that is, the corrected target position of the motor. Figure 3 The flowchart of the motor position processing method in one embodiment is as follows:

[0102] Step S301, obtaining the motor operating parameters when the motor is initialized: pf0 = mf0, zf0 = mf0, Q, R, p0. Where Q is the predicted noise w of the motor t The covariance of , R is the measurement error variance, Q and R can be a random variable distribution or a constant, which can be adjusted according to the actual situation.

[0103] Step S302, calculating the predicted position of the motor at the current time t, and obtaining the observed position of the motor at the current time t. Calculating the predicted position of the motor includes:

[0104] pf t = pf t-1 +v t-1 Δt+w t , v t =v t-1

[0105] Among them, pf t-1 is the optimal estimated value of the motor at the previous moment (t-1), v t-1 is the motor speed at the last moment. Optionally, in this embodiment, the motor is moving at a constant speed as an example, then v t =v t-1 , w t Represents the error noise when predicting the motor's predicted position at the current moment.

[0106] Calculate the motor observed position zf t The formula includes:

[0107] zf t =mf t +e t

[0108] where mf t is the feedback value of the motor position from the magnetic encoder at the current moment, that is, the measured value of the motor position, e t is the measurement error noise.

[0109] Step S303, obtaining the optimal motor estimated position of the motor at the current time t according to the observed position and predicted position of the motor.

[0110] Optionally, calculate the optimal motor estimated position ef of the motor t :

[0111] ef t = pf t +k t *(zf t -pf t )

[0112]

[0113] where k t is the Kalman gain, It is the covariance matrix of the value corresponding to the predicted position at the current moment.

[0114] Step S304: after updating the optimal motor estimate, update the covariance matrix P t , and repeat step S302.

[0115] Optionally, the predicted position of the motor at the current moment t can be obtained based on the Bayesian filtering method, as well as the combination of the predicted position and the observed position, so as to obtain the optimal motor estimated position of the motor at the current moment t. Taking into account that the calculations during the Bayesian filtering solution are relatively complex, steps S302 to S304 calculate the optimal motor estimated position by using the Kalman filtering method. Specifically, this embodiment takes the motor position estimation of the autofocus as an example that basically satisfies the linear change relationship over time, and calculates the optimal motor estimated position based on the linear standard Kalman filter. It can be understood that when the state transfer function of the actual motor position is a nonlinear function, the optimal motor estimated position can also be calculated by extending the Kalman filter.

[0116] When executing step S202, steps S210 to S220 are synchronously executed until the focusing is completed, which includes the following steps:

[0117] Step S210, auto focus. For the ultra-telephoto imaging system, the motor load is relatively large, and it will perform acceleration and deceleration operations when starting and stopping. Therefore, in actual control, in order to ensure that the entire control is relatively smooth, the start and stop control of the motor should be reduced as much as possible. Based on this, this embodiment divides the entire focusing process into two stages: a large-range coarse search and a small-range fine search to complete the motor search for the clear image position.

[0118] Figure 4 FIG. 1 is a flow chart of a focus search method in an embodiment. Figure 4 As shown, it includes a large-scale coarse search stage and a small-scale fine search stage.

[0119] In the large-scale coarse search stage: set the image to sample the image frame at a time interval of t1. In the coarse search stage, in order to ensure that a roughly clear position can be found quickly, the time interval can be set relatively large. Optionally, set t1 = 500ms, and the value of t1 can be adjusted according to the actual situation. According to the sampling interval, obtain the current position of the motor. Optionally, in the current frame corresponding to the sampling interval, obtain the motor position fp based on step S302 cur Get the image clarity value fv of the current frame cur , the image clarity value represents the clarity of the image. The larger the value, the clearer the image. Calculate the clarity value of the current frame and the clarity value of the previous frame fv lst The ratio value R; where

[0120]

[0121] If R is less than the first threshold, it means that the motor position is far away from the clearest position, and the first threshold condition is met. At this time, the motor position corresponding to the current frame is recorded as fp limitThen the motor is controlled to search in reverse. Sampling is continued at intervals of t1 until it is determined again that the ratio R of the clarity value of the current frame to the clarity value of the previous frame is less than the first threshold value, then the coarse search stage is completed and the small range fine search stage is entered.

[0122] In the small range fine search stage: the motor is basically near the clear position. In order to ensure that the motor sampling position of the clearest image can be obtained, a relatively small image sampling time interval t2 needs to be set. Optionally, t2 = 50ms is set. The value of t2 can be adjusted according to the actual situation. The value of t2 is less than t1. The motor is set to move in the opposite direction of the coarse adjustment stage, that is, the third movement direction. Based on step S302, the motor position fp corresponding to the image frame at the sampling moment is obtained. cur And the image clarity value fv of the current frame cur , calculate the clarity value of the current frame and the previous frame fv lst When R is less than the second threshold, or the current motor position exceeds fp limit When , the fine search phase is completed, and the motor position fp when the image clarity value is the largest in the fine search phase is recorded final , that is, after reaching the target position, the motor stops.

[0123] Step S220: the motor stops. Optionally, the motor is set to move in the opposite direction to the fine search, and the motor position obtained from the motor processing module is obtained until the motor position reaches fp final , then stop the motor movement. Since the super telephoto lens group itself is large in size, the load is high during the DC motor drive process. When setting the motor to stop, due to inertia, it may exceed the final motor position. Therefore, according to the actual situation, the motor speed can be reduced during the motor stop process, and the motor movement can be stopped in advance based on the current position feedback.

[0124] Based on the same inventive concept, the embodiment of the present application also provides an autofocus device for implementing the autofocus method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations of one or more autofocus device embodiments provided below can refer to the limitations of the autofocus method above, and will not be repeated here.

[0125] In one embodiment, Figure 5 As shown, an automatic focusing device is provided, the imaging system includes a motor and a lens, and the device includes:

[0126] A focusing module, used to operate the motor and determine whether the imaging system is in a preset state according to the image acquired by the lens;

[0127] A position acquisition module, used to predict the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment when the imaging system is in a preset state, and to measure the observed position of the motor at the current moment;

[0128] The position correction module is used to combine the predicted position and the observed position to obtain the target position of the motor;

[0129] The running module is used to run the motor until the motor reaches the target position.

[0130] In some of the embodiments, the position correction module combines the predicted position and the observed position to obtain the target position including: obtaining the difference between the predicted position and the observed position; obtaining the weight of the difference based on the covariance matrix of the motor position at the previous moment, the noise when predicting the predicted position of the motor, and the measurement error of the observed position; obtaining a correction value based on the weight and the difference; and correcting the predicted position based on the correction value to obtain the target position.

[0131] In some embodiments, the position acquisition module predicts the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment, including: predicting the predicted position of the motor at the current moment according to the position, operating speed and movement direction of the motor at the previous moment. Optionally, the imaging system also includes a position encoder, and the observed position of the motor at the current moment measured by the position acquisition module includes: obtaining the measurement value output by the position encoder; combining the measurement error and the measurement value to obtain the observed position.

[0132] In some of the embodiments, the focusing module runs the motor, and determines whether the imaging system is in a preset state based on the image captured by the lens, including: running the motor based on a first running direction until the difference between the clarity of adjacent frame images captured by the lens meets a first threshold condition, and adjusting the first running direction of the lens; running the motor based on the adjusted first running direction until the difference between the clarity of adjacent frame images captured by the lens meets the first threshold condition again, and obtaining the motor operating range according to the position of the motor when the first threshold condition is met; and determining that the imaging system is in a preset state according to the clarity of the image captured by the lens within the motor operating range.

[0133] Furthermore, after the focusing module runs the motor based on the adjusted first running direction until the difference between the clarity levels of adjacent frame images acquired by the lens again meets the first threshold condition, the method also includes: running the motor based on a second running direction, the second running direction being opposite to the first running direction; when the difference between the clarity levels of adjacent frame images acquired by the lens meets the second threshold condition, obtaining a preset state of the imaging system according to the clarity of the image acquired by the lens during the operation of the motor.

[0134] In some embodiments, the operation module operates the motor to the target position, including: operating the motor based on a third operation direction until the motor reaches the target position; wherein the third operation direction is opposite to the operation direction of the motor at the previous moment. Optionally, the operation module operates the motor to the target position at a speed less than the speed of the motor before the target position is obtained.

[0135] Each module in the above-mentioned autofocus device can be implemented in whole or in part by software, hardware or a combination thereof. Each module 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 operations corresponding to each module.

[0136] In one embodiment, Figure 6 A structural schematic diagram of an imaging system is also provided, wherein the imaging system includes a motor, a lens, a memory, and a processor, wherein the memory stores a computer program, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program. The motor is connected to the lens, and the motor is used to drive the lens to move. The imaging system may include multiple lenses to obtain a lens group; the motor drives the lens group to move.

[0137] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0138] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0139] 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.

[0140] 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.

[0141] 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. An automatic focusing method, characterized in that: The imaging system includes a motor and a lens, and the method includes: running the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens; When the imaging system is in a preset state, the predicted position of the motor at the current moment is predicted according to the operating parameters of the motor at the previous moment, and the observed position of the motor at the current moment is measured; Combining the predicted position and the observed position to obtain a target position of the motor; The motor is operated until the motor reaches the target position.

2. The automatic focusing method according to claim 1, characterized in that: Combining the predicted position and the observed position to obtain the target position includes: Obtaining a difference between the predicted position and the observed position; Obtaining a weight of the difference according to a covariance matrix of the motor position at a previous moment predicted, noise when predicting the predicted position of the motor, and a measurement error; Obtaining a correction value according to the weight and the difference; The predicted position is corrected based on the correction value to obtain the target position.

3. The automatic focusing method according to claim 1, characterized in that: The predicting the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment comprises: The predicted position of the motor at the current moment is predicted based on the position, running speed and moving direction of the motor at the previous moment.

4. The automatic focusing method according to claim 1, characterized in that: The imaging system further includes a position encoder, and the observed position of the motor at the current moment obtained by the measurement includes: Obtaining a measurement value output by the position encoder; The observed position is obtained by combining the measurement error and the measurement value.

5. The automatic focusing method according to claim 1, characterized in that: The step of operating the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens comprises: Running the motor based on the first running direction until the difference between the clarity levels of adjacent frame images acquired by the lens meets a first threshold condition, and adjusting the first running direction of the motor; Running the motor based on the adjusted first running direction until the difference between the clarity levels of adjacent frame images acquired by the lens meets the first threshold condition again, and obtaining the motor running range according to the position of the motor when the first threshold condition is met; Whether the imaging system is in the preset state is determined according to the clarity of the image acquired by the lens within the operating range of the motor.

6. The automatic focusing method according to claim 5, characterized in that: Determining whether the imaging system is in the preset state according to the clarity of the image acquired by the lens within the operating range of the motor includes: operating the motor based on a second operating direction, the second operating direction being opposite to the first operating direction; When the difference between the clarity of adjacent frame images captured by the lens meets a second threshold condition, the preset state of the imaging system is obtained according to the clarity of the image captured by the lens during the operation of the motor.

7. The automatic focusing method according to claim 1, characterized in that: Said operating the motor to the target position comprises: The motor is operated based on a third operating direction until the motor reaches the target position; wherein the third operating direction is opposite to the operating direction of the motor at a previous moment.

8. The automatic focusing method according to claim 1 or 7, characterized in that: include: When the motor is operated to the target position, the operating speed of the motor is lower than the operating speed of the motor before the target position is obtained.

9. An automatic focusing device, characterized in that: The imaging system includes a motor and a lens, and the device includes: A focusing module, used for operating the motor and determining whether the imaging system is in a preset state according to the image acquired by the lens; A position acquisition module, used for predicting the predicted position of the motor at the current moment according to the operating parameters of the motor at the previous moment when the imaging system is in a preset state, and measuring the observed position of the motor at the current moment; A position correction module, used to obtain a target position of the motor by combining the predicted position and the observed position; An operating module is used to operate the motor until the motor reaches the target position.

10. An imaging system, characterized in that: The imaging system comprises a motor, a lens, a memory and a processor, wherein the motor is located inside the lens, the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 8 when executing the computer program.