Focus position determination method, device, electronic equipment and electric lens
By obtaining the focus range and return difference threshold of the electric zoom lens, combined with the offset motion strategy, the focus position determination method is optimized, which solves the problem of inaccurate focus position caused by the motor return difference, and improves the focus success rate and rate.
Patent Information
- Application Number
- CN202411896746.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-20
- Publication Date
- 2025-04-08
AI Technical Summary
During the focusing process, the actual focus position of the electric zoom lens is inaccurate due to the motor return journey, which makes the existing solutions cost high or the accuracy loss.
By obtaining the focus range and return difference threshold of the focus lens group at the initial position, the target position is determined, and by offsetting the motion strategy, the focus position is determined to control the movement of the focus lens group to record the image clarity of multiple positions.
The automatic focusing process of the electric lens is optimized, the focus success rate and rate are improved, and the focus position inaccurate problem caused by backhaul difference is solved without adding additional tolerances or costs.
Smart Images

Figure CN119788963A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automatic focusing technology, and in particular to a method and device for determining a focus position, an electronic device, and an electric lens. Background Art
[0002] Electric zoom lenses are increasingly used in the fields of security, surveillance, and smart devices. The performance of their autofocus function is directly related to the image quality and user experience of the device. When the zoom motor position is determined, the focus motor needs to be moved to make the picture clear. The algorithm that controls the movement of the focus motor and makes the picture reach the clearest state is called the autofocus algorithm. The autofocus algorithm determines the best focus point as quickly and accurately as possible by analyzing the image clarity at different focus positions. The current basic common methods include full search and hill climbing algorithms. Full search is the most accurate but time-consuming. The hill climbing algorithm determines the peak point in advance by detecting the rise and fall of clarity. It has a faster speed, but low stability. The current methods basically use the zoom table to determine the search range.
[0003] However, during the focusing process, due to the return difference of the motor, that is, when the motor rotates in the reverse direction, due to gear clearance and other reasons, there is a period of focus motor rotation after the reverse direction, but the lens does not move, resulting in a deviation between the theoretical coordinates and the actual coordinates, and further resulting in an error between the final motor stop position and the optimal position. One solution is to calibrate the return difference of each lens and compensate for it when the movement is reversed. The problem with this is that the production cost is too high and the error will increase with use and wear. Another solution is to measure the return difference of the motors of the same batch in the laboratory and take the average value for compensation. The problem with this is that the final accuracy will still be lost.
[0004] To address the above-mentioned problems, no effective solution has been proposed yet. Summary of the invention
[0005] The embodiments of the present invention provide a method and device for determining a focus position, an electronic device and a motorized lens, so as to at least solve the technical problem that the actual focus position is inaccurate due to the return difference of the motor.
[0006] According to one aspect of an embodiment of the present invention, a method for determining a focus position is provided, comprising: obtaining a focus range corresponding to a focus lens group at an initial position and a return difference threshold of the focus lens group, wherein the initial position is the current position of the focus lens group; determining a target position based on the focus range and the return difference threshold, wherein the range between the initial position and the target position is greater than the focus range; controlling the focus lens group to move from the initial position to the target position according to a moving direction of the focus lens group; controlling the focus lens group to move from the target position to the initial position based on a preset first moving step, and recording the clarity of images captured at multiple positions during the movement; determining the focus position of the focus lens group based on the clarity corresponding to the multiple positions.
[0007] Optionally, obtaining a focusing range corresponding to the focusing lens group at an initial position includes: determining a moving range of the focusing lens group based on an initial corresponding relationship and an object distance range of the target object to be measured, wherein the initial corresponding relationship is a relationship between the position of the focusing lens group, the position of the zoom lens group, and the position of the object to be measured; recording the clarity of images captured at multiple positions during the movement of the focusing lens group within the moving range until the recorded clarity decreases, and stopping moving the focusing lens group, wherein the current position of the focusing lens group is the initial position; and determining a focusing range based on the corresponding clarity at multiple positions.
[0008] Optionally, the moving range of the focusing lens group is determined based on an initial corresponding relationship and an object distance range of the target object to be measured, wherein the initial corresponding relationship is the relationship between the position of the focusing lens group, the position of the zoom lens group and the position of the object to be measured, including: determining an initial range based on the initial corresponding relationship and the object distance range of the target object to be measured; determining a tolerance distance based on the initial range; and determining a moving range based on the tolerance distance and the initial range.
[0009] Optionally, the clarity of images captured at multiple positions during the movement of the focusing lens group within the moving range is recorded until the recorded clarity decreases, and the moving of the focusing lens group is stopped, including: determining a second moving step of the focusing lens group within the moving range based on the position of the zoom lens group; based on the second moving step, controlling the focusing lens group to move multiple times in the moving range, and recording the clarity of the image captured at the corresponding position after each movement, until the recorded clarity decreases, and the moving of the focusing lens group is stopped.
[0010] Optionally, recording the clarity of images collected at multiple positions in the process of the focusing lens group moving within the moving range until the recorded clarity decreases, and stopping moving the focusing lens group, includes: controlling the focusing lens group to move unidirectionally from one end point to another end point in the moving range, and recording the clarity of the image collected at the corresponding position after each movement; when the recorded clarity meets a preset growth condition, controlling the focusing lens group to continue moving in the moving range based on the above-mentioned moving direction, and recording the clarity of the image collected at the corresponding position after each movement, until the recorded clarity decreases, and stopping moving the focusing lens group.
[0011] Optionally, it also includes: when the recorded clarity meets a preset decrease condition, controlling the focusing lens group to move within the moving range based on the opposite moving direction, and recording the clarity of the image captured at the corresponding position after each movement, until the recorded clarity decreases, and stopping moving the focusing lens group.
[0012] Optionally, based on the corresponding clarity at multiple positions, the focusing range is determined, including: based on the corresponding clarity at multiple positions, determining the position corresponding to the clarity reaching the target threshold as the reference position; based on the reference position, determining the symmetric position of the initial position with respect to the reference position; based on the symmetric position and the initial position, determining the focusing range.
[0013] Optionally, the method further includes: determining a compensation position based on a return difference threshold and a focus position; controlling the focus lens group to move to the compensation position, and then controlling the focus lens group to move to the focus position.
[0014] Optionally, the clarity of the captured image is determined based on the following method, including: obtaining the brightness of the environment in which the focusing lens group is located; determining a target gradient operator based on the brightness and a preset brightness threshold, wherein the gradient operator represents the rate of change of the grayscale value in the image; and calculating the clarity of the captured image based on the target gradient operator.
[0015] According to one aspect of an embodiment of the present invention, there is provided an electric lens group, comprising a zoom lens group, a zoom motor, a focus lens group, a focus motor and a controller of the focus motor, wherein the controller determines a focus position of the focus lens group based on any one of the above focus position determination methods.
[0016] According to one aspect of an embodiment of the present invention, a focusing position determining device is provided, comprising: an acquisition module, used to acquire a focusing range corresponding to a focusing lens group at an initial position and a return difference threshold of the focusing lens group, wherein the initial position is the current position of the focusing lens group; a first determination module, used to determine a target position based on the focusing range and the return difference threshold, wherein the range between the initial position and the target position is greater than the focusing range; a control module, used to control the focusing lens group to move from the initial position to the target position according to the moving direction of the focusing lens group; a recording module, used to control the focusing lens group to move from the target position to the initial position based on a preset first moving step, and record the clarity of images collected at multiple positions during the movement; a second determination module, used to determine the focusing position of the focusing lens group based on the clarity corresponding to the multiple positions.
[0017] According to another aspect of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned focus position determination methods.
[0018] According to another aspect of the present invention, there is provided an electronic device, comprising: a memory storing an executable program; and a processor for running the program, wherein any one of the above-mentioned focus position determination methods is executed when the program is run.
[0019] In an embodiment of the present invention, a method for determining a focus position is adopted, by obtaining a focus range corresponding to a focus lens group at an initial position and a return difference threshold of the focus lens group, wherein the initial position is the current position of the focus lens group; based on the focus range and the return difference threshold, a target position is determined, wherein a range between the initial position and the target position is greater than the focus range; according to a moving direction of the focus lens group, the focus lens group is controlled to move from the initial position to the target position; based on a preset first moving step, the focus lens group is controlled to move from the target position to the initial position, and the clarity of images collected at multiple positions during the movement is recorded; based on the clarity corresponding to multiple positions, the focus position of the focus lens group is determined, thereby achieving the purpose of optimizing the automatic focusing process of the electric lens, thereby realizing the technical effect of improving the focusing success rate and speed of the electric lens, and further solving the technical problem of inaccurate actual focus position due to the return difference of the motor. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] The drawings described herein are used to provide a further understanding of the present invention and constitute a part of this application. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the drawings:
[0021] Figure 1is a schematic flow chart of a method for determining a focus position according to an embodiment of the present invention;
[0022] Figure 2 is an optional definition change curve diagram according to an embodiment of the present invention;
[0023] Figure 3 is a matrix diagram of an optional normal gradient operator and a low-light gradient operator according to an embodiment of the present invention;
[0024] Figure 4 is a schematic diagram of an optional imaging system according to an embodiment of the present invention;
[0025] Figure 5 is a structural block diagram of a focus position determination device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0026] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme 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 should fall within the scope of protection of the present invention.
[0027] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0028] First, some nouns or terms that appear in the description of the embodiments of the present application are subject to the following explanations:
[0029] The gradient operator is a mathematical tool used for edge detection and feature extraction. It is mainly used to measure the degree of change of pixel values in a local area of an image, thereby calculating the clarity of the image.
[0030] A zoom table refers to a series of pre-calibrated position data that records in detail the positions of the lens groups that can achieve the best focus clarity at different object distances and zoom positions of the electric zoom lens.
[0031] Lost steps refer to the phenomenon that the motor fails to fully execute the predetermined number of steps. Long-term use or improper maintenance may cause wear of the internal components of the motor (such as gears and shafts), affecting the accuracy and performance of the motor and causing lost steps.
[0032] The return error refers to the phenomenon that when the motor rotates in the forward and reverse directions, there is an inconsistency between the actual displacement of the lens group and the motor command displacement due to the gap or elastic deformation in the structure (such as gears, worm gears, etc.).
[0033] ISO is the gain multiple used for image sensor exposure and is used as an indicator to measure the sensitivity of image sensors to light. It represents the ability of image sensors to capture images under given light conditions. The higher the ISO value, the higher the sensitivity of the sensor to light, and the clearer the image can be captured in darker environments.
[0034] Surveillance cameras in the security field often need to automatically adjust the focus at different time periods, different object distances, and different zoom requirements to ensure the clarity of the surveillance images. In current technologies, the search range setting based on the zoom table and the fixed step length control strategy will seriously affect the focusing success rate and speed when faced with complex situations such as fast-moving objects, frequent changes in obstructions, and motor return difference after long-term use of the lens.
[0035] Some possible solutions include: adopting higher-precision motors or improving motor drive circuits can improve focusing accuracy to a certain extent, but will significantly increase equipment cost and hardware complexity; using deep learning-based image analysis methods to accurately predict the optimal focusing point, although it can improve the focusing success rate, it has extremely high demands on computing resources and may cause the device to respond more slowly; through a more sophisticated calibration process, the accuracy of the zoom table can be improved and the search range can be reduced. However, this not only increases production costs, but also ignores the impact of performance changes after long-term use of the motor, and focusing problems are still difficult to avoid.
[0036] In order to solve the problem of inaccurate focus position caused by motor return difference, the present application proposes a focus position determination method. Through the strategy of offsetting movement, after two consecutive movements in different directions, the error between the ideal position and the actual position caused by the return difference is offset, which can ensure that even if the motor has a return difference, the focus position can be found, and the focusing lens group is finally moved to the focus position, and there will be no deviation between the actual position and the focus position due to the return difference. In the fine search stage and before the end of focusing, the present application controls the motor to perform offset movement, ensuring that the forward and backward movement directions are consistent, thereby eliminating the influence of the return difference on the focusing result, without the need to increase tolerance or cost.
[0037] According to an embodiment of the present invention, an embodiment of a method for determining a focus position is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0038] Figure 1 FIG. 1 is a flow chart of a method for determining a focus position according to an embodiment of the present invention. Figure 1 As shown, the method comprises the following steps:
[0039] Step S101, obtaining a focusing range corresponding to an initial position of the focusing lens group and a return difference threshold of the focusing lens group, wherein the initial position is a current position of the focusing lens group.
[0040] Optionally, in order to determine the focusing range of the focusing lens group, the focusing lens group can be roughly located through a rough search on the basis of the full search range, as the focusing range corresponding to the subsequent fine search stage, to improve the overall focusing speed. The initial position of the focusing lens group is the position where it stops after the rough search, and the focusing range is the target search range of the subsequent fine search process. In the rough search, when it is detected that the image clarity decreases from a maximum value, the focusing lens group stops moving, that is, it stays at the initial position. According to the above position and the position corresponding to the maximum clarity, the target search range of the subsequent fine search process, that is, the focusing range, can be determined. When the position of the stay changes, the corresponding focusing range will also change. For example, in the rough search stage, the moving step length of the focusing lens group can be step1, and the position coordinate corresponding to the maximum clarity that can be detected during the rough search process can be c. After the focusing lens group passes point c, the clarity value will decrease, so it stops moving. According to the moving step length of step1, the stop position can be obtained, that is, the coordinates of the initial position can be c-step1 or c+step1, so the focusing range can be [c-step1, c+step1].
[0041] Specifically, in the coarse search stage, a rough search range can be determined based on the pre-calibrated zoom curve and the position of the current zoom lens group; then, the focus lens group is moved within the above search range, and two exposure times are waited after each movement to ensure image acquisition, calculate the clarity value, and record the clarity value and its corresponding coordinates; finally, the position corresponding to the maximum clarity value in the recorded clarity values is selected as the center point of the above focus range, and the focus range is finally determined according to the position where the focus lens group stays. In the coarse search stage for determining the focus range, by reasonably setting the search step length, the accuracy of the search is guaranteed, and the focusing speed is taken into account, which is one of the key steps of the present invention to improve the success rate and speed of focusing.
[0042] The return difference refers to when the focus motor rotates in the opposite direction, due to reasons such as gear clearance, the motor rotates but the actual position of the lens does not change immediately, resulting in a deviation between the theoretical coordinates and the actual coordinates. Therefore, the focus lens group controlled by the focus motor will also have a position deviation. The return difference threshold, that is, the maximum return difference, is a key parameter to ensure the accuracy of the focusing operation. There are many ways to obtain the return difference threshold. Specifically, the average return difference of a batch of motors provided by the motor manufacturer can be used as a reference; the return difference threshold of a specific lens group can also be determined through laboratory measurements. During the test, the lens group is subjected to multiple forward and reverse operations, and the difference between the displacement of the motor and the actual movement of the lens is recorded. The average return difference is calculated as a basis for compensation in the subsequent algorithm. In the automatic focusing process of this embodiment, especially before the coarse search is completed and before entering the fine search, and before moving to the peak point after the fine search is completed, the motor is controlled to perform additional offsetting movements to eliminate the deviation caused by the return difference, thereby ensuring the continuity of the focusing process and the accuracy of the final focusing position.
[0043] As an optional embodiment, the execution subject of the method of this embodiment can be a controller for controlling the focus motor. The focus motor controls and drives the focus lens group to move. The controller can run a pre-programmed autofocus algorithm based on a microprocessor or microcontroller, and receive image clarity information and zoom position information in real time through the communication interface with the image processing unit, zoom motor and focus motor, and then calculate the position and step size that the focus motor should move. Not only can the precise control of the motor be achieved, but also through intelligent algorithms and strategy adjustments, key problems such as motor step loss accumulation, return difference and environmental adaptability are effectively solved, which significantly improves the speed and success rate of autofocus, especially in complex environments and after long-term use, its advantages are more obvious.
[0044] Step S102, determining a target position based on a focus range and a return difference threshold, wherein a range between the initial position and the target position is greater than the focus range.
[0045] Optionally, after acquiring the focus range, that is, after the rough search phase ends, the current position of the focus lens group, that is, the initial position, is located at one of the two end points of the focus range. If the focus lens group is directly moved in the opposite direction to the focus range to determine the focus position, for example, the focus lens group is located at c+step1 at this time, if it moves directly from c+step1 to c-step1, the moving direction is opposite to the moving direction of the previous stage, resulting in a return difference in the motor. Due to the return difference in the motor, the actual coordinates of each movement of the focus lens group will deviate from the theoretical coordinates, and ultimately the actual search range will be smaller than the focus range, that is, the focus lens group cannot search the entire focus range completely, which may result in the inability to find the best focus position. Therefore, the present invention designs an offset motion to eliminate the influence of the motor return difference. Specifically, a target position can be determined, and the target position can be a position outside the end point in the focus range far away from the initial position, and the distance between the target position and the above end point is determined based on the return difference threshold, and the range between the target position and the initial position is the target moving range where the focus position of the focus lens group is located. For example, when the initial position is c+step1, the corresponding moving direction of the previous stage is forward. At this time, the target position can be selected to be set in the focusing range [c-step1, c+step1], away from the endpoint of the initial position c+step1, that is, a position outside c-step1. The specific distance from c-step1 is determined based on the backlash difference threshold backlash, which can be c-step1-backlash; similarly, when the initial position is c-step1, the corresponding moving direction of the previous stage is reverse. At this time, the target position can be c+step1+backlash.
[0046] Step S103, controlling the focusing lens group to move from the initial position to the target position according to the moving direction of the focusing lens group.
[0047] Optionally, when controlling the focus lens group to move from the initial position to the target position, this process is opposite to the search process of the previous stage, that is, the final moving direction of the rough search stage. Therefore, this moving process will produce a return difference. In the previous step, the target position is set at a position outside the focusing range in order to solve the error caused by this return difference. If the target position is not set based on the return difference threshold, and the focus lens group is only controlled to move to the end point far from the initial position in the focusing range and multiple sharpnesses are recorded, the return difference caused by the reverse movement may cause the actual position of the focus lens group to not reach the end point far from the initial position in the above-mentioned focusing range, resulting in incomplete search in the next stage, that is, the fine search stage, and the focusing position may not be found.
[0048] The focusing lens group starts to move unidirectionally from the target position, and the moving direction of the focusing lens group is the same as that of the rough search stage. There will be no return difference problem during the movement, so the entire focusing range can be searched, avoiding the deviation between the theoretical position and the actual position of the focusing lens group caused by the return difference, which in turn affects the search process of the focusing lens group, so that the focusing lens group may not search the complete focusing range and miss the problem of the best focusing position, ensuring the accuracy of the focusing position, and no additional tolerance is required. For example, when the moving direction of the focusing lens group in the previous stage is forward, the corresponding initial position is c+step1, and the focusing lens group can be controlled to move from c+step1 to c-step1-backlash; on the contrary, when the moving direction of the focusing lens group in the previous stage is reverse, the corresponding initial position is c-step1, and the focusing lens group can be controlled to move from c-step1 to c+step1+backlash.
[0049] Step S104, based on a preset first moving step length, controlling the focusing lens group to move from the target position to the initial position, and recording the clarity of images collected at multiple positions during the moving process.
[0050] Optionally, after the target position is determined, a fine search can be continued. The focusing lens group can start from the target position and move to the other end point (initial position) to ensure that the moving direction of the focusing lens group in the fine search stage is the same as the moving direction at the end of the previous search stage, that is, the rough search stage, thereby avoiding the situation where the actual position does not match the ideal position due to the return difference in the reverse motion. Based on the preset first moving step, continue to record the image clarity value corresponding to each moving position of the focusing lens group until the entire range is searched, wherein the second moving step is a smaller moving step, which can be set based on actual experience, ensuring that the focusing lens group can find the clearest image position in a smaller range with a finer step. For example, the target position can be c-step1-backlash, the initial position can be c+step1, and the first moving step can be step2. Therefore, the above steps can be to move the focusing lens group from c-step1-backlash to c+step1, and collect the image clarity once every step2 distance.
[0051] Step S105, determining the focus position of the focusing lens group based on the clarity corresponding to the multiple positions.
[0052] Optionally, in the above steps, there is a maximum value among the clarity values corresponding to the multiple positions recorded, and therefore, the corresponding moving position is determined as the focus position of the focusing lens group. For example, the coordinate corresponding to the maximum clarity value among the multiple clarity values recorded above is d, that is, d is the focus position of the focusing lens group.
[0053] Through the above steps, the purpose of optimizing the automatic focusing of the electric lens is achieved, thereby achieving the technical effect of improving the success rate and speed of electric lens focusing, and further solving the technical problem of inaccurate actual focusing position due to the return difference of the motor.
[0054] As an optional embodiment, obtaining a focusing range corresponding to the focusing lens group at an initial position includes: determining a moving range of the focusing lens group based on an initial corresponding relationship and an object distance range of the target object to be measured, wherein the initial corresponding relationship is a relationship between the position of the focusing lens group, the position of the zoom lens group and the position of the object to be measured; recording the clarity of images collected at multiple positions during the movement of the focusing lens group within the moving range until the recorded clarity decreases, and stopping moving the focusing lens group, wherein the current position of the focusing lens group is the initial position; and determining a focusing range based on the corresponding clarity at multiple positions.
[0055] Optionally, obtaining the focus range corresponding to the initial position of the focus lens group in the target electric lens group can be performed in the rough search stage. Specifically, before the electric lens is produced or used, the relationship between the focus position of the lens group and the position of the object to be measured, that is, the so-called zoom curve or zoom table, can be obtained through experimental calibration. In practical applications, the object distance of the object to be measured may vary within a certain range. For example, it can be obtained by looking up the table that when the position of the zoom lens group is determined, the positions of the focus lens group corresponding to the minimum object distance and the maximum object distance are a and b respectively. Based on the above initial corresponding relationship and object distance range, the moving range of the focus lens group can be set. The focus lens group starts from one end point of the moving range and moves to the other end point. After each movement, wait for 2 exposure times, collect images and calculate the clarity. Record the clarity value and corresponding position of the focus lens group during the movement process until it is detected that the clarity begins to decrease, which means that it has exceeded the clarity peak point, and stop moving at this time. Among the clarity values recorded during the movement, find the coordinates corresponding to the maximum clarity value. With the coordinates as the center, the focus range can be determined to perform more accurate peak positioning.
[0056] By setting the moving range based on the initial correspondence and the object distance range, the focusing lens group can be quickly moved to the vicinity of the potential clarity peak position, significantly shortening the search time. Although the full search strategy can ensure that the clarity peak point is found, it takes a long time and is not suitable for scenarios that require a quick response. In this embodiment, by combining the coarse search and fine search stages, the search step size and range are dynamically adjusted to ensure both the search speed and the maximization of the focusing accuracy. In addition, each time the motor moves, it waits for 2 exposure times in order to have enough time to make a complete exposure at the current motor position to accurately characterize the clarity of this position. It is also possible to wait for more time, but the total focusing speed will be slower. It is also possible to wait for less time, but there is a probability that some errors will occur in the focusing result.
[0057] As an optional embodiment, the moving range of the focusing lens group is determined based on the initial corresponding relationship and the object distance range of the target object to be measured, wherein the initial corresponding relationship is the relationship between the position of the focusing lens group, the position of the zoom lens group and the position of the object to be measured, including: determining the initial range based on the initial corresponding relationship and the object distance range of the target object to be measured; determining the tolerance distance based on the initial range; determining the moving range based on the tolerance distance and the initial range.
[0058] Optionally, the initial correspondence refers to the mathematical mapping between the focus lens group position, the zoom lens group position and the position of the object under test when the electric lens is in the best focus state. This relationship is usually obtained through a series of calibration experiments during the lens group production or calibration stage, and aims to establish an accurate correspondence between the zoom and focus states of the lens group. When focusing, you can directly query the approximate range in which the focus may exist (due to errors, non-fixed object distance, etc., the focus position cannot be directly obtained), that is, the approximate interval where the clarity peak is located is directly obtained in the entire focusing stroke, which can significantly improve the focusing speed. However, if the motor loses too many steps, there may be no peak point in this interval, resulting in unsuccessful focusing. This is a common strategy for current automatic focusing algorithms. Figure 2 is an optional definition change curve diagram according to an embodiment of the present invention, such as Figure 2 As shown, under normal circumstances, the clarity curve around the focus will be peak-shaped. The more obvious the peak of the peak, the easier it is to be recognized and captured by the algorithm.
[0059] The initial range can be determined based on the object distance range. By querying the zoom table, the optimal focus position interval of the focusing lens group under the corresponding object distance can be obtained when the position of the zoom lens group is determined, that is, the initial range, with the position of the focusing lens group corresponding to the minimum object distance as the left endpoint and the position of the focusing lens group corresponding to the maximum object distance as the right endpoint. For example, the initial range can be obtained as [a, b] by looking up the table, where a and b are the optimal focus positions corresponding to the minimum object distance and the maximum object distance, respectively.
[0060] The setting of the tolerance distance takes into account the cumulative error of motor step loss, structural instability and other potential factors that may occur in the actual use of the electric lens. Since the motor will inevitably have problems of step loss and step over, the logical position and the actual position will deviate, and the deviation will accumulate over time, eventually resulting in the best clear position not being within this range, and it will not be able to focus clearly. The tolerance distance allows the focus search to be further expanded on the basis of the initial range, ensuring that even if there is a certain error, the best focus position can be found within the search range. The specific value of the tolerance distance can be determined based on the size of the initial range. For example, if the distance size of the initial range is ba, the tolerance distance can be set to 1.5 times ba.
[0061] The moving range can be extended to both ends of the initial range by a tolerance distance. This range takes into account all possible error factors to ensure the comprehensiveness and robustness of the focus search. For example, if the initial range is [a, b] and the tolerance distance is m, then the moving range can be [am, b+m]. During the search process, the focus motor starts from one end of the moving range and moves within the moving range according to the determined step length, while recording the image clarity value after each step. When it is detected that the clarity begins to decrease, it means that the best focus position has been exceeded, and the movement stops and enters the fine search stage.
[0062] As an optional embodiment, the clarity of images collected at multiple positions during the movement of the focusing lens group within the moving range is recorded until the recorded clarity decreases, and the moving of the focusing lens group is stopped, including: determining a second moving step of the focusing lens group within the moving range based on the position of the zoom lens group; based on the second moving step, controlling the focusing lens group to move multiple times in the moving range, and recording the clarity of the image collected at the corresponding position after each movement, until the recorded clarity decreases, and the moving of the focusing lens group is stopped.
[0063] Optionally, according to the current position of the zoom lens group, the present embodiment can adaptively adjust the moving step length of the focusing lens group, that is, the second moving step length, which can be set to step1, for example. Because the width of the "mountain" of the clarity curve of the zoom lens group at the telephoto and short focus positions is different, the short focus is wide and the long focus is narrow. If the same step length is used for rough search, the effect is often not good. Generally, there is a position that cannot trigger the preset condition normally, resulting in focusing failure. The "peak" of the clarity curve is steeper and narrower at the telephoto, and wider at the short focus. Therefore, in the present embodiment, a larger step length is used at the short focus to speed up the search speed, and a smaller step length is used at the telephoto to improve the search accuracy. Such a strategy ensures the optimal balance between focusing speed and accuracy. Some traditional automatic focusing algorithms may use a fixed step length for searching, regardless of the position of the zoom lens group. Although the complexity of the algorithm is simplified, the optimal focusing speed or accuracy may not be achieved in the telephoto or short focus state.
[0064] The focusing lens group searches within the moving range based on the determined second moving step length. After each movement, it waits for a certain exposure time to ensure sufficient imaging of the image, then collects the image and calculates its clarity. This series of clarity values and their corresponding positions are recorded. When it is detected that the clarity begins to decrease, it indicates that the focusing lens group has exceeded the peak of the clarity curve. At this time, it stops moving and enters the fine search stage to more accurately locate the best focus position.
[0065] As an optional embodiment, recording the clarity of images collected at multiple positions in the process of the focusing lens group moving within the moving range until the recorded clarity decreases, and stopping moving the focusing lens group, includes: controlling the focusing lens group to move unidirectionally from one end point to another end point in the moving range, and recording the clarity of the image collected at the corresponding position after each movement; when the recorded clarity meets a preset growth condition, controlling the focusing lens group to continue moving in the moving range based on the above-mentioned moving direction, and recording the clarity of the image collected at the corresponding position after each movement, until the recorded clarity decreases, and stopping moving the focusing lens group.
[0066] Optionally, the focusing lens group can start from the end point of the moving range and move unidirectionally toward the other end point; it can also start from a certain point in the moving range and move unidirectionally toward the end point away from this point. The unidirectional movement strategy avoids the extra time consumption and return error that may be caused by the reply search. After each movement, wait for enough exposure time to ensure the stability of the image, then collect the image and calculate its clarity. These clarity values and their corresponding positions are recorded for subsequent analysis. When the recorded clarity value begins to increase continuously and meets the preset growth condition, the focusing lens group continues to search in the current moving direction until the clarity value begins to decrease. Once the clarity value begins to decrease, it indicates that the focusing lens group has passed the peak point of the clarity curve. At this time, it stops moving and prepares to enter the fine search stage to determine the best focus position. Among them, the preset growth condition can be the continuous increase in clarity or the absolute change rate of the current clarity value compared to the minimum clarity. For example, the moving range is [am, b+m], the focusing lens group can start from am and move to b+m. When the recorded clarity value starts to increase continuously and meets the preset growth condition, it indicates that the clarity peak has not been reached. Therefore, continue to move in the above direction until the recorded clarity decreases, indicating that the clarity peak has been passed. Then you can stop moving and prepare to enter the next stage of the search process.
[0067] In addition, after determining that the focusing lens group can continue to move unidirectionally in the original moving direction, an additional tolerance distance can be added to the original moving range to allow the search range to exceed the moving range by an appropriate position to solve the problem of incomplete search range caused by motor step loss or step skipping. For example, the original moving range of the focusing lens group is [am, b+m]. When it is determined that the clarity change meets the preset uphill condition, that is, the growth condition, the focusing lens group can continue to move to the b+m+n position with the moving step length of step 1, where n is the newly added tolerance distance, which can be set based on the initial correspondence or actual experience.
[0068] As an optional embodiment, it also includes: when the recorded clarity meets a preset decrease condition, controlling the focusing lens group to move within the moving range based on the opposite moving direction, and recording the clarity of images captured at multiple positions until the recorded clarity decreases, and stopping moving the focusing lens group.
[0069] Optionally, when the recorded clarity value starts to decrease continuously and meets the preset decrease condition, it indicates that if the movement and recording continue in the above-mentioned moving direction, the clarity value will continue to decrease, and it is impossible to find a position with the maximum clarity value. Therefore, the focusing lens group can be moved and searched in the opposite moving direction, and the recorded clarity value will continue to increase until the clarity value begins to decrease. Once the clarity value begins to decrease, it indicates that the focusing lens group has passed the peak point of the clarity curve. At this time, it stops moving and prepares to enter the fine search stage to determine the best focus position. For example, the moving range is [am, b+m]. The focusing lens group can start from am and move to b+m. When the recorded clarity value continues to decrease and meets the preset decrease condition, it indicates that the clarity peak has been passed. Therefore, it is necessary to move in the opposite direction. The recorded clarity value begins to increase continuously until the recorded clarity decreases, indicating that the clarity peak has been passed. It can stop moving and prepare to enter the next stage of the search process.
[0070] The preset drop condition may be a continuous drop in clarity or an absolute change rate of the current clarity value compared to the maximum clarity, etc. Some algorithms stop searching based on only a single condition (such as reaching a preset number of steps or reaching the boundary of the moving range) without considering the trend of clarity changes. Near the peak point, this single condition may stop searching too early or too late, thus affecting the focusing accuracy.
[0071] Similarly, after determining that the focusing lens group moves in the opposite direction, an additional tolerance distance can be added to the original moving range to allow the search range to exceed the moving range by an appropriate position to solve the problem of incomplete search range caused by motor step loss or step skipping. For example, the original moving range of the focusing lens group is [am, b+m]. When it is determined that the clarity change meets the preset downhill condition, that is, the descending condition, the focusing lens group moves in the opposite direction and moves to the amn position with the first moving step length, where n is the newly added tolerance distance, which can be set based on the initial corresponding relationship or actual experience.
[0072] In addition, when the recorded clarity value neither meets the preset increase condition nor the preset decrease condition, the focusing lens group can be moved to the other end point of the moving range. For example, the focusing lens group can be moved to b+m, and the clarity values of all corresponding positions within the moving range are recorded, and comparison and selection are performed among all the data.
[0073] As an optional embodiment, the focusing range is determined based on the corresponding clarity at multiple positions, including: based on the corresponding clarity at multiple positions, determining the position corresponding to the clarity reaching the target threshold as the reference position; based on the reference position, determining the symmetric position of the initial position with respect to the reference position; based on the symmetric position and the initial position, determining the focusing range.
[0074] Optionally, through the above-mentioned movement process, the image clarity values corresponding to multiple positions of the focusing lens group within the moving range are recorded, and when the clarity value reaches the target threshold, that is, the maximum value, for the first time, the corresponding position is determined as the reference position. When the focusing lens group detects that the clarity value drops during the movement process, it will stop moving. Therefore, the initial position, that is, the stop position, is the position one moving step away from the maximum clarity value position. The reference position can be used as the center point of the focusing range. In order to ensure a more accurate range, the focusing range can be determined according to the size of the second moving step, that is, the focusing range can be determined according to the initial position, and the symmetrical point of the initial position with respect to the reference position is selected as the other end point of the focusing range.
[0075] For example, a maximum clarity value can be found among the corresponding clarity values at multiple positions, and the corresponding position coordinates can be recorded as c, the stopped position, that is, the initial position can be c+step1, and the symmetrical position can be c-stepl, so [c-step1, c+stepl] can be used as the focusing range, where step1 represents the second moving step. After the first stage of search, some focusing algorithms directly set a predefined fixed focusing range with the reference position as the center for subsequent search. This strategy may cause an inappropriate focusing range when the position of the zoom lens group changes greatly or the object distance range is not fixed, affecting the focusing speed and accuracy. The focusing range determination method provided in an embodiment of the present invention ensures that the subsequent focusing process can be carried out within a smaller and more precise range, thereby locating the optimal focusing position more quickly, while avoiding unnecessary searches and saving time and computing resources.
[0076] As an optional embodiment, it also includes: determining a compensation position based on a return difference threshold and a focus position; controlling the focusing lens group to move to the compensation position, and then controlling the focusing lens group to move to the focus position.
[0077] Optionally, according to the return difference threshold of the lens group, after determining the focus position, the focus lens group can be controlled to move to the compensation position first, and then quickly move to the focus position. This process can control the motor to perform offsetting movement, so that the movement direction of the focus lens group back to the focus position is the same as the direction in the above-mentioned movement process, effectively compensating for the position offset caused by the return difference when the motor moves in the reverse direction, and improving the accuracy of the final focus position. The focus position is between the target focus range, and the position where the focus lens group stopped in the previous step is at the other end of the search range, that is, the initial position. If the focus lens group is moved directly to the focus position, the movement direction of the focus lens group is opposite to the previous movement direction, so there will be a return difference, resulting in the focus lens group actually unable to reach the ideal focus position. By offsetting the movement, the focus lens group can be accurately positioned at the optimal clarity position, and high-precision focusing can be achieved even when there is a return difference in the motor.
[0078] For example, when the focusing range corresponding to the focusing lens group is [c-step1, c+step1], the focusing lens group can be moved to c-step1-backlash first, and then move from the current position to c+step1, where backlash represents the return difference threshold, that is, the maximum return difference. Then move the focusing lens group with the first moving step of step2, wait for 2 exposure times after each movement, and then record the clarity value and coordinates, and stop after reaching the c+step1 position. From the recorded clarity values, find the coordinates corresponding to the clarity peak as the focusing position, recorded as d, so the compensation position can be d-backlash, and finally control the focusing lens group to move to the d-backlash position, and then immediately move to the d position to complete the focusing process.
[0079] As an optional embodiment, the clarity of the captured image is determined based on the following method, including: obtaining the brightness of the environment in which the focusing lens group is located; determining a target gradient operator based on the brightness and a preset brightness threshold, wherein the gradient operator represents the rate of change of the grayscale value in the image; and calculating the clarity of the captured image based on the target gradient operator.
[0080] Optionally, during the autofocus process, the brightness information of the environment in which the focusing lens group is located can be first obtained. This can usually be achieved by measuring the exposure parameters of the image sensor, or by counting the average brightness of the image, exposure time, or using an ambient light sensor. The acquisition of ambient brightness provides a basis for the subsequent selection of a suitable gradient operator. For example, the ISO value can be obtained. ISO is the gain multiple used for image sensor exposure. Under automatic exposure, the larger the ISO, the higher the sensitivity of the lens group to light, which means the darker the ambient brightness.
[0081] According to the obtained ambient brightness and the preset brightness threshold, a gradient operator suitable for the current lighting conditions can be selected. In a high-brightness environment, a normal gradient operator is used; in a low-brightness environment, a low-light gradient operator is used. The low-light gradient operator can better detect edge information and details in the image in a low-light environment, and can maintain a high detection sensitivity even in insufficient light. Among them, the preset brightness threshold can be obtained by measuring the difference critical point of the clarity curve of the two operators under different light intensities in the laboratory. If the same gradient operator is used for image clarity evaluation regardless of the lighting conditions during the entire focusing process, it may cause difficulty in identifying the clarity curve in a low-light environment, affecting the focusing success rate and speed. For example, the iso used by the current automatic exposure can be obtained. If iso>threshold, the low-light gradient operator is used, otherwise the normal gradient operator is used, where threshold represents the preset brightness threshold.
[0082] The basis for judging the focus position can be the clarity of the collected image. It is generally believed that the richer the image detail information, the clearer the image. Commonly used clarity evaluation indicators include image gradient information in the time domain, or the size of high-frequency components in the frequency domain. The time domain gradient has the advantages of simple calculation and low hardware implementation cost. Therefore, the gradient operator can be selected to calculate the clarity of the image. The clarity is calculated by the gradient operator on the image. The gradient operator is a mathematical tool used for edge detection and feature extraction in digital image processing. It is mainly used to calculate the rate of change of pixel grayscale values in the image, thereby determining the edges and details of the image. In image analysis, the gradient can be understood as the rate of change of the grayscale value of the image in space, which can reflect the location of the grayscale value mutation in the image, that is, the edge or contour. It is usually used in the convolution operation of the image to estimate the gradient direction and size of the local area of the image by convolving with the grayscale matrix of the image. For example, Figure 3 It is a matrix diagram of an optional normal gradient operator and a low-light gradient operator according to an embodiment of the present invention. The above matrix can be convolved with the grayscale matrix of the image to estimate the gradient direction and size of the local area of the image, thereby obtaining the clarity of the image.
[0083] As an optional embodiment, a step flow of an optional focusing method is also provided, and the specific steps are as follows:
[0084] S1: Determine whether to use the normal gradient operator or the low-light gradient operator based on the iso currently used for automatic exposure. If iso>threshold, use the low-light gradient operator, otherwise use the normal gradient operator. Threshold represents the preset brightness threshold.
[0085] S2: Find the coarse search range [am, b+m] from the full search range using the pre-calibrated zoom curve and the set tolerance m.
[0086] S3: According to the position of the zoom motor, determine the coarse search step length step1 and set the maximum backlash difference as backlash.
[0087] S4: If the current position of the focus motor is less than am, the focus motor is controlled to move to the position of am; if the current position is greater than b+m, the focus motor is moved to the position of b+m; if the current position is between [am, b+m], the focus motor remains unchanged. The subsequent steps are described by taking the first case as an example.
[0088] S5: Start from the current position of the focus motor and move to b+m with the step length of step 1. This direction is recorded as the positive direction. After each movement, wait for 2 exposure times, and then record the sharpness value and coordinates in Group A. If Group A meets the preset conditions for going uphill, it will enter S6; if it meets the preset conditions for going downhill, it will proceed to S7; if it reaches the position b+m, it will enter S9, otherwise repeat S5.
[0089] S6: Continue to move to the b+m+n position with the step size of step 1, wait for 2 exposure times after each move, and then record the clarity value and coordinates into Group B. If Group B meets the preset conditions for going down the mountain or reaches the b+m+n position, enter S8.
[0090] S7: The focus motor moves in the reverse direction and moves toward amn with the step size of step 1. After each movement, it waits for 2 exposure times, and then records the clarity value and coordinates into Group B. If Group B meets the preset conditions for going downhill or reaches the amn position, it enters S8.
[0091] S8: Find the coordinate corresponding to the maximum clarity value from Group B and mark it as c.
[0092] S9: Find the coordinate corresponding to the maximum clarity value in Group A and mark it as c.
[0093] S10: Take [c-step1, c+step1] as the detailed search range.
[0094] S11: If the current focus motor movement direction is forward, the focus motor moves to c-step1-backlash, and then immediately moves to c-step1, and enters S12; if the current focus motor movement direction is reverse, the focus motor moves to c+step1+backlash, and then immediately moves to c+step1, and enters S13.
[0095] S12: Move to c+step1 with the step length of step2, wait for 2 exposure times after each move, then record the clarity value and coordinates into Group C, and enter S14 when reaching the position c+step1.
[0096] S13: Move to c-step1 with the step length of step2, wait for 2 exposure times after each move, then record the clarity value and coordinates into Group C, and enter S14 when reaching the c-step1 position.
[0097] S14: Find the coordinate corresponding to the sharpness peak value from Group C and mark it as d. If the current focus motor moving direction is forward, control the focus motor to move to the d-backlash position, and then immediately move to the d position; if the current focus motor moving direction is reverse, control the focus motor to move to the d+backlash position, and then immediately move to the d position.
[0098] S15: Focusing ends.
[0099] According to an embodiment of the present invention, there is provided an electric lens, comprising a zoom lens group, a zoom motor, a focus lens group, a focus motor and a controller of the focus motor, wherein the controller determines a focus position of the focus lens group based on any one of the above focus position determination methods.
[0100] Optionally, Figure 4 is a schematic diagram of an optional imaging system according to an embodiment of the present invention, such as Figure 4 As shown, the electric zoom lens has a zoom lens group and a focus lens group, which are controlled by a zoom motor and a focus motor respectively to achieve zoom and focus functions. The controller of the focus motor is a key component in the entire system responsible for controlling the movement of the focus motor. The focus position determination method provided in the embodiment of the present invention is used to guide the movement of the focus motor to achieve fast and accurate focusing. The controller of the focus motor combines the above-mentioned focus position determination method and determines the optimal focus position and strategy according to the current ambient brightness, zoom position and other information. The controller guides the movement of the focus motor through intelligent analysis and decision-making, avoiding problems such as inaccurate focusing and slow focusing speed that may occur in traditional focusing strategies, and effectively improves the focusing performance of the electric lens under various shooting conditions.
[0101] As an optional embodiment, test data of an electric lens applied to the focus position determination method of the embodiment of the present invention is also provided. Table 1 is an optional data comparison table of a lens applying the method in various scenarios according to the embodiment of the present invention and a current lens. As shown in Table 1, the core indicators of the automatic focusing algorithm are the focusing success rate and the focusing speed. Lens 1 is a lens applying the method proposed by the present invention, and lens 2 is a current lens. The innovation proposed by the present invention makes the focusing success rate and focusing speed of the applied lens in various test scenarios better than the current lens.
[0102]
[0103] Table 1 A data comparison table of an optional lens for applying the method in various scenarios according to an embodiment of the present invention and the current lens
[0104] According to an embodiment of the present invention, a focusing position determining device is provided. Figure 5 is a structural block diagram of a focus position determination device according to an embodiment of the present invention. Figure 5 As shown, the focus position determination device includes: an acquisition module 501, a first determination module 502, a control module 503, a recording module 504 and a second determination module 505. The focus range determination device is described below.
[0105] The acquisition module 501 is used to acquire the focusing range corresponding to the focusing lens group at the initial position and the return difference threshold of the focusing lens group, wherein the initial position is the current position of the focusing lens group.
[0106] The first determination module 502 is connected to the acquisition module 501 and is used to determine the target position based on the focus range and the return difference threshold, wherein the range between the initial position and the target position is larger than the focus range.
[0107] The control module 503 is connected to the first determination module 502 and is used to control the focus lens group to move from an initial position to a target position according to the moving direction of the focus lens group.
[0108] The recording module 504 is connected to the control module 503 and is used to control the focusing lens group to move from the target position to the initial position based on a preset first moving step, and to record the clarity of images collected at multiple positions during the movement.
[0109] The second determining module 505 is connected to the recording module 504 and is used to determine the focus position of the focusing lens group based on the clarity corresponding to the multiple positions.
[0110] It should be noted here that the above-mentioned acquisition module 501, first determination module 502, control module 503, recording module 504 and second determination module 505 correspond to steps S101 to S105 in the embodiment, and the instances and application scenarios implemented by the multiple modules are the same as the corresponding steps, but are not limited to the contents disclosed in the above-mentioned embodiments.
[0111] According to an embodiment of the present invention, a computer-readable storage medium is provided, the computer-readable storage medium including a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute any one of the above-mentioned focus position determination methods.
[0112] According to an embodiment of the present invention, an electronic device is provided, comprising: a memory storing an executable program; and a processor for running the program, wherein any one of the above-mentioned focus position determination methods is executed when the program is run.
[0113] According to an embodiment of the present invention, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the steps of any one of the above-mentioned focus position determination methods are implemented.
[0114] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0115] In the above embodiments of the present invention, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0116] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units can be a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.
[0117] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple units. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0118] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0119] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk and other media that can store program codes.
[0120] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for determining a focus position, characterized in that: include: Obtaining a focusing range corresponding to an initial position of the focusing lens group and a return difference threshold of the focusing lens group, wherein the initial position is a current position of the focusing lens group; Determining a target position based on the focus range and the return difference threshold, wherein a range between the initial position and the target position is greater than the focus range; According to the moving direction of the focusing lens group, controlling the focusing lens group to move from the initial position to the target position; Based on a preset first moving step length, controlling the focusing lens group to move from the target position to the initial position, and recording the clarity of images collected at multiple positions during the movement; Based on the sharpness corresponding to the multiple positions, the focus position of the focusing lens group is determined.
2. The method according to claim 1, characterized in that The step of obtaining the focusing range corresponding to the focusing lens group at the initial position includes: Determine the moving range of the focusing lens group based on the initial corresponding relationship and the object distance range of the target object to be measured, wherein the initial corresponding relationship is the relationship between the position of the focusing lens group, the position of the zoom lens group and the position of the object to be measured; Recording the clarity of images collected at multiple positions during the movement of the focusing lens group within the moving range until the recorded clarity decreases, and stopping moving the focusing lens group, wherein the current position of the focusing lens group is the initial position; The focus range is determined based on the corresponding sharpness at the multiple positions.
3. The method according to claim 2, characterized in that The moving range of the focusing lens group is determined based on the initial corresponding relationship and the object distance range of the target object to be measured, wherein the initial corresponding relationship is the relationship between the position of the focusing lens group, the position of the zoom lens group and the position of the object to be measured, including: Determining an initial range based on the initial corresponding relationship and the object distance range of the target object to be measured; Based on the initial range, determining a tolerance distance; The moving range is determined based on the tolerance distance and the initial range.
4. The method according to claim 2, characterized in that: The step of recording the clarity of images collected at multiple positions during the movement of the focusing lens group within the moving range until the recorded clarity decreases and stopping the movement of the focusing lens group comprises: Determining a second moving step length of the focusing lens group within the moving range based on the position of the zoom lens group; Based on the second moving step, the focusing lens group is controlled to move multiple times in the moving range, and the clarity of the image collected at the corresponding position after each movement is recorded until the recorded clarity decreases, and the moving of the focusing lens group is stopped.
5. The method according to claim 2, characterized in that: The step of recording the clarity of images collected at multiple positions during the movement of the focusing lens group within the moving range until the recorded clarity decreases and stopping the movement of the focusing lens group comprises: Controlling the focusing lens group to move unidirectionally from one end point to another end point in the moving range, and recording the clarity of an image collected at a corresponding position after each movement; When the recorded clarity meets the preset growth condition, the focusing lens group is controlled to continue to move in the moving range based on the above-mentioned moving direction, and the clarity of the image captured at the corresponding position after each movement is recorded until the recorded clarity decreases, and the moving of the focusing lens group is stopped.
6. The method according to claim 5, characterized in that Also includes: When the recorded clarity meets the preset decreasing condition, the focusing lens group is controlled to move in the moving range based on the opposite moving direction, and the clarity of the image captured at the corresponding position after each movement is recorded until the recorded clarity decreases, and the moving of the focusing lens group is stopped.
7. The method according to claim 2, characterized in that The determining the focus range based on the corresponding sharpness at the plurality of positions comprises: Based on the clarity corresponding to the multiple positions, determine the position corresponding to the clarity reaching the target threshold as the reference position; Based on the reference position, determining a symmetrical position of the initial position with respect to the reference position; The focus range is determined based on the symmetric position and the initial position.
8. The method according to claim 1, characterized in that Also includes: Determining a compensation position based on the return difference threshold and the focus position; The focusing lens group is controlled to move to the compensation position, and then the focusing lens group is controlled to move to the focusing position.
9. The method according to any one of claims 1 to 8, characterized in that: The clarity of the captured image is determined based on the following methods, including: Obtaining the brightness of the environment in which the focusing lens group is located; Determining a target gradient operator according to the brightness and a preset brightness threshold, wherein the gradient operator represents a rate of change of grayscale values in the image; Based on the target gradient operator, the clarity of the acquired image is calculated.
10. An electric lens, comprising a zoom lens group, a zoom motor, a focus lens group, a focus motor and a controller of the focus motor, characterized in that: The controller determines the focus position of the focusing lens group based on the focus position determination method according to any one of claims 1 to 9.
11. A focus position determination device, characterized in that: include: An acquisition module, used to acquire a focusing range corresponding to an initial position of the focusing lens group and a return difference threshold of the focusing lens group, wherein the initial position is a current position of the focusing lens group; A first determination module, configured to determine a target position based on the focus range and the return difference threshold, wherein a range between the initial position and the target position is greater than the focus range; A control module, used for controlling the focusing lens group to move from the initial position to the target position according to the moving direction of the focusing lens group; A recording module, configured to control the focusing lens group to move from the target position to the initial position based on a preset first moving step length, and to record the clarity of images collected at multiple positions during the movement; The second determination module is used to determine the focus position of the focusing lens group based on the clarity corresponding to the multiple positions.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium includes a stored executable program, wherein when the executable program is executed, the device where the computer-readable storage medium is located is controlled to execute the focus position determination method according to any one of claims 1 to 9.
13. An electronic device, characterized in that: include: A memory storing an executable program; A processor is used to run the program, wherein the program executes the focus position determination method described in any one of claims 1 to 9 when running.
14. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the focus position determination method according to any one of claims 1 to 9 are implemented.
Citation Information
Cited By
Optical lens focusing processing method and device, equipment and medium
CN121691907A