Object distance estimation method and device in zoom focusing

By estimating and correcting the object distance during the zoom focus process, the problem of image sharpness jitter during the zoom process is solved, and the continuous clarity and smoothness of the image during the zoom process is achieved.

CN119653230APending Publication Date: 2025-03-18SHENZHEN MICROBT ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311201660.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-09-15
Publication Date
2025-03-18

AI Technical Summary

Technical Problem

During the zoom process, the image clarity may be significantly jittery, causing the image to be sometimes blurred and clear, affecting the fluency of the zoom process.

Method used

Through a method of estimating object distance in zoom focus, the initial object distance and the detection direction and step length of the detection frame are used to detect the position of the focus motor to obtain the clarity evaluation value, and the initial object distance is corrected based on these evaluation values ​​to obtain the correct object distance to match the moving step length of the zoom motor.

Benefits of technology

This method can reduce image clarity jitter during the zoom process, so that the image always remains clear during the zoom process, and improve the fluency of the zoom process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119653230A_ABST
    Figure CN119653230A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides an object distance estimation method and device in zoom focusing. The method comprises the following steps: determining an initial object distance at the beginning of a current period; the current period comprises a preset number of detection frames, and the detection direction of each detection frame comprises a first detection direction or a second detection direction; determining a detection step length corresponding to each detection frame in the current period; based on the initial object distance, position detection of a focusing motor is carried out according to the detection direction and the detection step length of each detection frame, and a definition evaluation value corresponding to each detection frame is obtained; and correcting the initial object distance at the target frame of the current period based on the definition evaluation values corresponding to all the detection frames in the current period to obtain a corrected object distance. According to the embodiment of the invention, the condition that the image definition is jittered in the zooming process can be reduced, so that the image can be always kept clear in the zooming process.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of video surveillance technology, and in particular to a method and device for estimating object distance in variable magnification focusing. Background Art

[0002] High-magnification cameras have the functions of zooming and auto-focusing, and are widely used in the field of video surveillance. The lens group of a high-magnification camera includes a zoom lens group and a focus lens group, which are driven by a zoom motor and a focus motor respectively. During the zooming process, the focal length will change because the zoom motor drives the zoom lens group to move, and the original clear image may not be focused on the imaging medium such as the image sensor, resulting in blurred images. Therefore, during the zooming process, synchronous focusing is required so that the focus lens group changes synchronously according to the position of the zoom lens group to maintain accurate focus and keep the image clear at all times.

[0003] However, during the zooming process, the image clarity may fluctuate significantly, that is, the image may appear clear and blurry at times, making it difficult to keep the image clear throughout the entire zooming process, thus affecting the smoothness of the zooming process. Summary of the invention

[0004] The embodiments of the present invention provide a method and device for estimating object distance in zoom focusing, which can reduce the jitter of image clarity during the zoom process, so that the image remains clear during the zoom process, and improve the smoothness of the zoom process.

[0005] In a first aspect, an embodiment of the present invention discloses a method for estimating object distance in variable magnification focusing, which is applied to an image acquisition device, and the method includes:

[0006] At the beginning of a current cycle, an initial object distance is determined; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction;

[0007] Determine a detection step size corresponding to each detection frame in the current cycle;

[0008] Based on the initial object distance, the position of the focus motor is detected according to the detection direction and the detection step length of each detection frame to obtain a clarity evaluation value corresponding to each detection frame;

[0009] At the target frame of the current cycle, the initial object distance is corrected based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.

[0010] In a second aspect, an embodiment of the present invention discloses an object distance estimation device in variable magnification focusing, which is applied to an image acquisition device, and the device includes:

[0011] An initial object distance determination module, used to determine the initial object distance at the beginning of a current cycle; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction;

[0012] A detection step length determination module, used to determine the detection step length corresponding to each detection frame in the current cycle;

[0013] A detection module, configured to detect the position of a focus motor based on the initial object distance and in accordance with a detection direction and a detection step length of each detection frame, and obtain a clarity evaluation value corresponding to each detection frame;

[0014] The object distance correction module is used to correct the initial object distance at the target frame of the current cycle based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.

[0015] In a third aspect, an embodiment of the present invention discloses a machine-readable medium having instructions stored thereon. When the instructions are executed by one or more processors of a device, the device executes the object distance estimation method in variable magnification focusing as described in one or more of the above.

[0016] The embodiments of the present invention include the following advantages:

[0017] The object distance estimation method in zoom focusing provided by the embodiment of the present invention can estimate a relatively accurate object distance as the initial object distance of the next frame in each cycle through object distance estimation during the zoom process of the lens, and perform FOCUS detection in the FAR direction and the NEAR direction based on the initial object distance, and estimate the object distance of the current scene according to the detection result, and perform periodic correction on the estimated object distance, so that the moving step length of the focus motor and the moving step length of the zoom motor are more matched. The cycle of object distance correction in the embodiment of the present invention is shorter than the cycle of object distance detection, and the length of the cycle is adjustable. Through periodic object distance correction, small-step and fast correction can be achieved, and the wrong object distance can be corrected in time. The jitter of image clarity caused by inaccurate object distance during the zoom process can be reduced, so that the image can always remain clear during the zoom process, and the smoothness of the zoom process is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0019] Figure 1is a flowchart of an embodiment of a method for estimating object distance in variable magnification focusing of the present invention;

[0020] Figure 2 is a schematic diagram of lens curves corresponding to various preset object distances;

[0021] Figure 3 It is a structural block diagram of an embodiment of an object distance estimation device in variable magnification focusing of the present invention. DETAILED DESCRIPTION

[0022] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0023] The terms "first", "second", etc. in the specification and claims of the present invention are used to distinguish similar objects, and are not used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable when appropriate, so that the embodiments of the present invention can be implemented in an order other than those illustrated or described here, and the objects distinguished by "first", "second", etc. are generally of one type, and the number of objects is not limited. For example, the first object can be one or more. In addition, the term "and / or" in the specification and claims is used to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. In the embodiments of the present invention, the term "multiple" refers to two or more, and other quantifiers are similar.

[0024] In order to facilitate understanding of the technical solution of the present invention, some technical terms involved in the present invention are introduced below.

[0025] Zoom focus: Keep the focus accurate during the zoom process, so that the image can always remain clear. FV: Clarity rating value, used to measure the clarity of the image. The larger the value is, the higher the clarity is for the same scene. ZOOM: Zoom. FOCUS: Focus. Follow focus: Synchronize the focus during the zoom process to keep the image clear. Movement: The lens and the main control board are integrated, and the AF (Automatic Focus) program can be run normally.

[0026] Reference Figure 1 , shows a flowchart of an embodiment of a method for estimating object distance in variable magnification focusing of the present invention, the method can be applied to an image acquisition device, and the method may include the following steps:

[0027] Step 101: determining an initial object distance at the beginning of a current cycle; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction;

[0028] Step 102: Determine the detection step length corresponding to each detection frame in the current cycle;

[0029] Step 103: Based on the initial object distance, the position of the focus motor is detected according to the detection direction and detection step length of each detection frame to obtain a clarity evaluation value corresponding to each detection frame;

[0030] Step 104 : at the target frame of the current cycle, the initial object distance is corrected based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.

[0031] The object distance estimation method in variable magnification focusing provided by the embodiment of the present invention can be applied to an image acquisition device, which can be an electronic device with an image acquisition function, such as a high-magnification camera, etc. The image acquisition device can capture images or videos.

[0032] The lens curve can reflect the mapping relationship between the position of the zoom motor and the position of the focus motor at a certain object distance. During the magnification process, if the current actual object distance can be accurately obtained, the lens curve corresponding to the actual object distance can be used to control the movement of the zoom motor and the focus motor to make the image focused and clear. According to the imaging formula 1 / f=1 / u+1 / v, when the object distance u (that is, the distance between the optical rear principal point of the lens and the photographed object) is fixed, there is a corresponding relationship between the focal length f and the image distance v, so the lens curves corresponding to different object distances can be pre-configured in the camera. Among them, the lens curve corresponding to a certain object distance can represent the mapping relationship between the position of the zoom motor and the position of the focus motor at the object distance. Refer to Figure 2 , shows a schematic diagram of lens curves corresponding to various preset object distances. The embodiment of the present invention does not limit the preset object distances. For example, the preset object distances may include 1m, 3m, 5m, 10m, and 20m, etc. The image acquisition device may pre-store lens curves corresponding to the preset object distances. Figure 2In the coordinate system shown, the horizontal axis of the lens curve represents the position of the zoom motor when it moves, and the vertical axis represents the position of the focus motor when it moves. The ZOOM value represents the position of the zoom motor. The end with the smallest ZOOM value in the coordinate system is the W end (the end with the smallest magnification), and the end with the largest ZOOM value is the T end (the end with the largest magnification). The FOCUS value represents the position of the focus motor. The end with a smaller FOCUS value in the coordinate system is the FAR end, and the end with a larger FOCUS value is the NEAR end. When the zoom motor and the focus motor move along the trajectory indicated by the lens curve corresponding to a certain object distance, the camera can capture a clear image.

[0033] Since the image depth of field is larger at small magnifications, the near and far views are basically in focus after the autofocus is clear. Figure 2 From the lens curves shown, the lens curves corresponding to different object distances are basically overlapped at small magnifications, and the focus motor position when the focus is clear at small magnifications falls on multiple lens curves at the same time; while at large magnifications, due to the small depth of field, the lens curves corresponding to different object distances are scattered at large magnifications, and different positions of the focus motor correspond to different object distances. When the shooting scene and shooting angle remain unchanged (object distance remains unchanged), when the zoom stops, as long as the auto focus is completed once at a large magnification, the image can remain clear during subsequent zooming.

[0034] However, for shooting scenes where the object distance changes, when performing zoom focusing, not only must the image be focused quickly and accurately when the zoom stops, but the image must also remain focused throughout the entire zoom process. This requires that the current actual object distance can be accurately obtained during the zoom process, so that the lens curve used can be switched, so that the image captured after switching the lens curve has higher clarity.

[0035] In order to obtain the current actual object distance, you can use the object distance trial method to switch the lens curves under different object distances, determine the current actual object distance by observing and comparing the FV values, and then decide which lens curve to use under the object distance, and repeat this process.

[0036] However, in actual shooting scenes, because the actual object distance is unknown, it is necessary to constantly switch the object distance to change the lens curve. Only after obtaining the corresponding FV value can it be determined whether the current object distance is more suitable for the current scene. The object distance trial cycle is long, and the object distance may have changed, resulting in inaccurate trial object distance. The trial object distance oscillates around the actual object distance, and the image changes from blurred to clear. It is difficult to solve the problem of image clarity jitter during the zoom process.

[0037] To solve this problem, the embodiment of the present invention periodically performs object distance correction, and through object distance estimation, a relatively accurate object distance can be estimated in each cycle as the initial object distance of the next frame. Compared with the object distance trial method, the cycle of correcting the object distance can be shortened, and the problem of image clarity jitter during the zoom process can be solved. Compared with the object distance trial, the embodiment of the present invention performs FOCUS detection, and the control of FOCUS detection is more precise and easy to calculate.

[0038] It should be noted that the zoom focus may include two directions, direction A is specified as changing from a small magnification to a large magnification, and direction B is specified as changing from a large magnification to a small magnification. In the embodiment of the present invention, the zoom direction of the current cycle is direction A, that is, changing from a small magnification to a large magnification. For direction B, the zoom focus process can be performed on the basis of direction A.

[0039] Specifically, the essence of zoom focusing is that during the zoom process, for each movement of the ZOOM motor (zoom motor), the focus motor movement step (curFocusStep) that matches the current movement step (curZoomStep) of the ZOOM motor can be determined. This allows accurate zoom focusing to be achieved, achieving synchronous focusing during the zoom process and keeping the image clear throughout the process.

[0040] In order to determine curFocusStep that matches curZoomStep, an embodiment of the present invention performs FOCUS detection during the movement of the ZOOM motor (i.e., the magnification process). In each cycle, FOCUS detection is performed in a first detection direction (such as the FAR direction) and a second detection direction (such as the NEAR direction) through detection frames. The initial object distance of the current cycle is corrected according to the detection result (the FV value obtained by the detection) to obtain a more accurate object distance (such as the corrected object distance, which is closer to the actual object distance). The next step position of the FOCUS motor can be determined through the corrected object distance and the movement step length curZoomStep of the ZOOM motor, thereby obtaining curFocusStep that matches curZoomStep. In this way, periodic detection is performed during the magnification process to achieve synchronous focusing during the magnification process, thereby keeping the image clear throughout the process.

[0041] In the embodiment of the present invention, object distance correction is performed periodically during the zoom process. The length of the period can be set according to actual needs. For example, in the scene of shooting static objects, since the object distance is basically fixed, the period can be set longer; in the scene of shooting moving objects, since the object distance will change rapidly, the period can be set shorter. In the embodiment of the present invention, the period of object distance correction can be adjusted as needed. For example, the shortest period can be set to 3 frames to achieve rapid correction of object distance, so that in the scene of shooting moving objects, the image can always be kept clear when tracking moving objects.

[0042] A cycle includes a preset number of detection frames, and a detection direction of a detection frame includes a first detection direction or a second detection direction. The first detection direction may be a FAR direction, and the second detection direction may be a NEAR direction. Of course, in practical applications, the first detection direction may be a NEAR direction, and the second detection direction may be a FAR direction, which is not limited in the embodiment of the present invention.

[0043] In one example, 7 frames are set as one cycle, the 1st to 4th frames are detection frames, and the 5th to 7th frames are non-detection frames; wherein the 1st frame detects in the FAR direction, the 2nd frame detects in the NEAR direction, the 3rd frame detects in the NEAR direction, and the 4th frame detects in the FAR direction. Of course, the embodiment of the present invention does not limit the detection direction of each detection frame, and it is only necessary to ensure that half of the detection frames in one cycle are in the FAR direction and half are in the NEAR direction.

[0044] At the beginning of the current cycle, the initial object distance can be determined. For the first cycle at the beginning of zooming, the initial object distance can be the object distance when autofocus is completed, such as the object distance obtained when autofocus is completed after the last zooming is stopped; starting from the second cycle, the initial object distance can be the corrected object distance of the previous cycle.

[0045] For each detection frame in the current cycle, determine the detection step length (such as focusProbeStep) corresponding to each detection frame. The detection step length is used to indicate the amplitude of the detection. The larger the detection step length, the larger the detection amplitude. Each detection frame can use the same or different detection step lengths. The detection step length can be calculated according to a preset algorithm. Based on the initial object distance, the position of the focus motor is detected (i.e., FOCUS detection) according to the detection direction and detection step length of each detection frame, and the clarity evaluation value (FV value) corresponding to each detection frame can be obtained. Among them, FOCUS detection can detect the vicinity of the position of the focus motor through the detection step length, so as to achieve the purpose of detecting the FAR end and the NEAR end of the initial object distance. At the target frame of the current cycle, the clarity evaluation values ​​corresponding to all detection frames in the current cycle can be obtained, so that the initial object distance can be corrected based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain the corrected object distance.

[0046] The target frame refers to a frame in the current cycle that can obtain the clarity evaluation values ​​corresponding to all detection frames in the current cycle, or can be a frame specified in the current cycle. For example, when the current cycle contains 7 frames of images, the target frame can be the 7th frame. For another example, when the current cycle contains 5 frames of images, the target frame can be the 5th frame. For another example, when the current cycle contains 10 frames of images, the target frame can be the 7th frame; and so on.

[0047] Compared with the object distance detection method, the embodiment of the present invention quickly obtains a relatively accurate initial object distance, directly uses the lens curve corresponding to the initial object distance, and corrects the initial object distance of the current cycle through FOCUS detection, so that the next cycle can directly use the corrected object distance of the previous cycle as the initial object distance, which can shorten the time for correcting the object distance.

[0048] The embodiment of the present invention provides an object distance estimation method in zoom focusing, which can be applied to any zoom focusing method. In the process of lens zooming, the embodiment of the present invention can estimate a relatively accurate object distance as the initial object distance of the next frame in each cycle through object distance estimation, and perform FOCUS detection in the FAR direction and the NEAR direction based on the initial object distance. The object distance of the current scene is estimated according to the detection result, and the initial object distance is corrected so that the moving step length of the focus motor is more matched with the moving step length of the zoom motor. The period of object distance correction in the embodiment of the present invention is shorter than that of object distance detection, and object distance correction is performed periodically, with small-step rapid correction, which can correct the unclear problem caused by wrong object distance in time, prevent clarity jitter during zooming, and enable the image to always remain clear during zooming, thereby improving the smoothness of the zooming process.

[0049] In an optional embodiment of the present invention, the step 103 of performing position detection of the focus motor according to the detection direction and detection step length of each detection frame based on the initial object distance to obtain a clarity evaluation value corresponding to each detection frame may include:

[0050] For the current detection frame in the current cycle, the next position of the zoom motor is determined according to the current position of the zoom motor and the moving step of the zoom motor; the next position of the focus motor is determined according to the next position of the zoom motor and the initial object distance; the moving step of the focus motor corresponding to the current detection frame is determined according to the current position of the focus motor and the next position of the focus motor; the moving step of the focus motor corresponding to the current detection frame is updated based on the detection direction and the detection step corresponding to the current detection frame to obtain an updated step; after driving the focus motor to move based on the detection direction of the current detection frame and the updated step, a clarity evaluation value corresponding to the current detection frame is calculated.

[0051] For each frame in the current cycle (including detection frames and non-detection frames), the moving step length of the focus motor corresponding to each frame (such as curFocusStep) can be calculated by the following steps: Step 1) According to the current position of the zoom motor (such as curZoomPos) and the moving step length of the zoom motor (such as curZoomStep), determine the next position of the zoom motor (such as nextZoomPos); wherein curZoomPos can be directly read and curZoomStep can be preset. According to curZoomPos and curZoomStep, the next position of the zoom motor nextZoomPos can be obtained. Step 2) According to the next position of the zoom motor nextZoomPos and the target object distance, the lens curve corresponding to the target object distance is searched to determine the next position of the focus motor (such as recorded as nextFocusPos); wherein, for the target frame in the current cycle (such as the 7th frame), the target object distance is the corrected object distance obtained by correcting the initial object distance based on the detection results of the 1st to 4th detection frames; for the 1st to 6th frames in the current cycle, the target object distance is the initial object distance. Step 3) According to the current position of the focus motor (such as recorded as curFocusPos) and the next position of the focus motor nextFocusPos, the moving step length curFocusStep of the focus motor is determined; wherein, curFocusPos can be directly read.

[0052] The zoom motor's moving step length (curZoomStep) refers to the distance the zoom motor moves this time. The larger the curZoomStep value, the greater the focal length change and the more obvious the image field angle change. The focus motor's moving step length (curFocusStep) refers to the distance the focus motor moves this time, which is used to control the image focus range. The larger the curFocusStep value, the greater the focus range.

[0053] At the beginning of the current cycle, a relatively accurate initial object distance is directly estimated. For each frame before the target frame in the current cycle, the lens curve corresponding to the initial object distance is directly used; for the target frame in the current cycle and each frame after the target frame (if the target frame is not the last frame), the lens curve corresponding to the corrected object distance is used. The corrected object distance is the object distance value obtained by correcting the initial object distance based on the detection result of the detection frame. Furthermore, the corrected object distance obtained in the current cycle can be used as the initial object distance of the next cycle.

[0054] It can be understood that, taking a cycle of 7 frames as an example, for each frame, the curFocusStep corresponding to each frame can be calculated according to the above steps 1) to 3), thereby driving the focus motor to move.

[0055] For each detection frame in the current cycle, after determining the curFocusStep corresponding to the detection frame, the curFocusStep corresponding to the detection frame is also updated based on the detection direction and detection step length (such as denoted as focusProbeStep) corresponding to the detection frame. For example, the first frame in the current cycle detects in the FAR direction. Among them, detecting in the FAR direction means detecting the FOCUS step length in the direction of a farther object distance based on the initial object distance. For example, for the first frame, if the initial object distance is 6 meters, detection can be performed in the direction of an object distance of 7 meters to calculate the corresponding FV value. Therefore, after determining the curFocusStep corresponding to the first frame in the above step 3), it is also necessary to update the curFocusStep corresponding to the first frame determined at this time based on the detection direction and detection step length corresponding to the first frame, such as subtracting the detection step length of the first frame to obtain the final curFocusStep corresponding to the first frame (the updated step length of the first frame). The second frame in the current cycle detects in the NEAR direction. Among them, detection in the NEAR direction means detecting the FOCUS step length in the direction of a closer object distance based on the initial object distance. For example, for the second frame, if the initial object distance is 6 meters, detection can be performed in the direction of an object distance of 5 meters to calculate the corresponding FV value. Therefore, after determining the curFocusStep corresponding to the second frame in the above step 3), it is also necessary to update the curFocusStep corresponding to the second frame determined at this time based on the detection direction and detection step length corresponding to the second frame, such as adding the detection step length of the second frame to obtain the final curFocusStep corresponding to the second frame.

[0056] In an optional embodiment of the present invention, updating the moving step length of the focus motor corresponding to the current detection frame based on the detection direction and the detection step length corresponding to the current detection frame may include:

[0057] If the detection direction of the current detection frame is the first detection direction, subtracting the detection step length of the current detection frame from the moving step length of the focus motor corresponding to the current detection frame;

[0058] If the detection direction of the current detection frame is the second detection direction, the moving step length of the focus motor corresponding to the current detection frame is added to the detection step length of the current detection frame.

[0059] Taking the above example, assuming that the current detection frame is the first frame of the current cycle, after determining the moving step length of the focus motor corresponding to the first frame in step 3 (for ease of distinction, recorded here as curFocusStep1), since the detection direction of the first frame is the FAR direction, curFocusStep1=curFocusStep1-focusProbeStep1, where focusProbeStep1 is the detection step length of the first frame. For another example, when the current detection frame is the second frame of the current cycle, after determining the moving step length of the focus motor corresponding to the second frame in step 3 (such as recorded as curFocusStep2), since the detection direction of the second frame is the NEAR direction, curFocusStep2 is updated to be curFocusStep2+focusProbeStep2, where focusProbeStep2 is the detection step length of the second frame.

[0060] In an optional embodiment of the present invention, the driving the focus motor to move based on the detection direction of the current detection frame and the update step size may include:

[0061] If the update step size corresponding to the current detection frame is less than 0, the focus motor is driven to move toward the first detection direction by the absolute value of the update step size; if the update step size corresponding to the current detection frame is greater than 0, the focus motor is driven to move toward the second detection direction by the absolute value of the update step size.

[0062] Taking the above example, for the first frame, if curFocusStep1 is less than 0, the focus motor is driven to move the distance |curFocusStep1| in the first detection direction, and the clarity evaluation value corresponding to the first frame can be calculated to indicate the clarity of the image captured at this time; if curFocusStep2 is greater than 0, the focus motor is driven to move the distance |curFocusStep1| in the second detection direction, and the clarity evaluation value corresponding to the first frame can be calculated. The same applies to the second frame. If the update step is equal to 0, it does not move.

[0063] In an optional embodiment of the present invention, the method may further include: for the current detection frame, searching a preset mapping table according to the current position of the zoom motor and the current zoom speed level to obtain the moving step length of the zoom motor; wherein the preset mapping table records the mapping relationship between the position of the zoom motor and the moving step length of the zoom motor at different zoom speed levels. It is understandable that when the current frame is a non-detection frame, the same method can be used to obtain the moving step length of the zoom motor corresponding to the current frame.

[0064] In practical applications, if the user needs a slower zoom speed, the object can be clearly seen at any time when the recorded video is stopped. In this case, a single zoom speed will not meet the user's needs. To solve this problem, the embodiment of the present invention can provide multiple zoom speeds. Furthermore, the multiple zoom speeds can be divided into different levels, which are called zoom speed levels in the embodiment of the present invention.

[0065] The moving step length (curZoomStep) of the zoom motor can be obtained by querying a preset mapping table, wherein the preset mapping table records the mapping relationship between the position of the zoom motor and the moving step length of the zoom motor at different zoom speed levels.

[0066] When the zoom in direction A starts, the preset mapping table is first searched according to the current zoom speed level to obtain the current step length (curZoomStep) that the ZOOM motor is to move.

[0067] The preset mapping table can be obtained in advance through debugging configuration, in which the mapping relationship between the position of the zoom motor and the moving step length of the zoom motor at different zoom speed levels is recorded. Table 1 shows an example of a preset mapping table in an embodiment of the present invention.

[0068] Table 1

[0069] Pos 0 4000 6000 8000 9000 9600 10088 10188 Lev1 64 56 48 36 24 16 8 4 Lev2 128 96 72 48 36 20 10 4 Lev3 256 188 160 128 40 28 12 4

[0070] As shown in Table 1, the first line is the position Pos of the zoom motor, the second line is the curZoomStep corresponding to each Pos under the zoom speed level Lev1, the third line is the curZoomStep corresponding to each Pos under the zoom speed level Lev2, and the fourth line is the curZoomStep corresponding to each Pos under the zoom speed level Lev3.

[0071] Among them, different zoom speed levels may include preset zoom speeds. In a specific implementation, different zoom speed levels may correspond to different preset mapping tables, or a preset mapping table for infinitely variable speeds may be implemented through a preset mapping table corresponding to a high zoom speed level and a preset mapping table corresponding to a low zoom speed level.

[0072] In an embodiment of the present invention, the zoom speed level can be adjusted according to actual needs, and the zoom focusing effect can still be guaranteed after adjusting the zoom speed level, which can solve the problem that changing the zoom speed will affect the zoom focusing effect or the zoom speed is difficult to adjust in a single zoom speed scenario. In an embodiment of the present invention, the zoom speed can be set to multiple levels or to achieve infinite speed change, and the zoom focusing process can be adaptively adjusted according to the current zoom speed level, so that the user can select the desired zoom speed and still keep the image clear during the zoom process.

[0073] It should be noted that the embodiment of the present invention does not limit the length of a cycle and the number of detection frames in a cycle.

[0074] In an optional embodiment of the present invention, the number of frames included in the current cycle can be determined according to the cycle mode of the current cycle, and the cycle mode may include one of a long cycle, a medium cycle or a short cycle; wherein the long cycle includes (FvDelay+6+n) frames, n is a custom value, such as any one of n=0, 1, 2, 3... etc.; the medium cycle includes (FvDelay+4) frames; the short cycle includes (FvDelay+2) frames; FvDelay is the number of interval frames required for performing a detection on a detection frame to obtain the clarity evaluation value of the detection.

[0075] FvDelay may be different depending on the movement configuration of the camera. One movement of the zoom motor will trigger the movement of the focus motor. The number of frames between obtaining a frame of raw image captured by the camera and calculating the FV value of the frame of raw image is FvDelay. In the embodiment of the present invention, FvDelay=3 is taken as an example, that is, the first frame triggers the movement of the zoom motor and the focus motor, and the FV value when the movement of the zoom motor and the focus motor is completed can be calculated in the fourth frame. Then, the number of frames required for the definition evaluation value of one detection is 3, so FvDelay is 3.

[0076] Through the embodiments of the present invention, the object distance can be corrected in time when the object distance changes during the zoom process. For example, for an image acquisition device with a frame rate of 25 frames and FvDelay=3, the minimum correction cycle can reach 200ms / time, and the higher the frame rate, the smaller the FvDelay, the shorter the minimum cycle time, and the smoother the zoom focus adjustment process.

[0077] The embodiment of the present invention sets three cycle modes to be applicable to shooting scenes in different situations. Among them, the medium cycle is applicable to most shooting scenes. When it is necessary to track a moving object, it is necessary to correct the object distance more quickly and frequently. At this time, a short cycle can be used, such as one cycle containing 5 frames of images. In the short cycle mode, only two detection frames (such as the 1st frame and the 2nd frame) may be included, the 1st frame detects in the FAR direction, the 2nd frame detects in the NEAR direction, and the 3rd frame to the 5th frame are non-detection frames. When shooting static objects or the system performance is tight, a long cycle can be used, that is, one cycle contains 9 frames of images. Of course, the long cycle can also contain 10 frames or 11 frames, etc., which is not limited by the embodiment of the present invention. The number of detection frames and the detection method contained in the long cycle and the medium cycle are the same, but the calculation frequency is reduced.

[0078] The short-cycle mode only needs to perform one set of detection (one FAR direction detection and one NEAR direction detection are called one set of detection). It is faster and more accurate when tracking moving objects, and can solve the problem of poor focus tracking of moving objects. The medium-cycle mode can be applied to most shooting scenes. It performs two sets of detections, and the detection results are more accurate. The long-cycle mode can be applied to image acquisition devices that run many algorithms and have insufficient chip performance to ensure basic zoom focusing effects. In specific implementations, the corresponding cycle mode can be set according to actual needs.

[0079] It should be noted that the embodiments of the present invention are mainly described by taking the medium cycle as an example, and the processing methods of the long cycle and the short cycle are similar, and they can be referred to each other.

[0080] The embodiment of the present invention does not limit the detection direction of the detection frame and the order of the detection frames. For example, in the above example, the current cycle is the medium cycle mode, and the 1st frame to the 4th frame are detection frames. The 1st frame detects in the FAR direction, the 2nd frame detects in the NEAR direction, the 3rd frame detects in the NEAR direction, and the 4th frame detects in the FAR direction. Since FvDelay=3, in the 4th frame, the FV value detected in the 1st frame can be calculated and recorded (such as recorded as far1Fv); in the 5th frame, the FV value detected in the 2nd frame can be calculated and recorded (such as recorded as near1Fv); in the 6th frame, the FV value detected in the 3rd frame can be calculated and recorded (such as recorded as near2Fv); in the 7th frame, the FV value detected in the 4th frame can be calculated and recorded (such as recorded as far2Fv). Therefore, in the 7th frame, the detection results of the two FAR directions and the two NEAR directions have been collected, and the initial object distance can be corrected according to the above detection results to obtain the corrected object distance.

[0081] It is understandable that, in a specific implementation, the first frame may detect in the FAR direction, the second frame may detect in the NEAR direction, the third frame may detect in the FAR direction, and the fourth frame may detect in the NEAR direction; or, the first frame may detect in the NEAR direction, the second frame may detect in the FAR direction, the third frame may detect in the FAR direction, the fourth frame may detect in the NEAR direction, and so on. The embodiment of the present invention does not limit the detection direction and sequence, and only needs to record the detection direction of each detection frame and the sequence of each detection frame, and correspond each FV value to the corresponding detection direction during calculation.

[0082] In an optional embodiment of the present invention, determining the detection step length corresponding to each detection frame in the current cycle in step 102 may include:

[0083] Step S11, for the current detection frame in the current cycle, searching the lens curves at the preset object distances based on the current position of the zoom motor to obtain a first value and a second value; the first value is the position of the focus motor obtained by searching the lens curve at the maximum object distance among the preset object distances based on the current position of the zoom motor, and the second value is the position of the focus motor obtained by searching the lens curve at the minimum object distance among the preset object distances based on the current position of the zoom motor;

[0084] Step S12: Calculate the detection step length of the current detection frame according to the current position of the zoom motor, the first value, and the second value.

[0085] For each detection frame in the current cycle, the embodiment of the present invention may calculate a detection step length for each detection frame.

[0086] For example, for the first frame, the lens curves at each preset object distance are searched based on the current position of the zoom motor (curZoomPos), such as Figure 2 The lens curves at the preset object distances shown are used to obtain a first value (such as maxFocus) and a second value (such as minFocus). maxFocus is the position of the focus motor obtained by searching the lens curve at the maximum object distance based on curZoomPos, and minFocus is the position of the focus motor obtained by searching the lens curve at the minimum object distance based on curZoomPos.

[0087] For example, the minimum object distance may be 1 m, and the maximum object distance may be 10000 m. For the same curZoomPos, the smaller the object distance, the larger the position of the corresponding FOCUS motor.

[0088] According to curZoomPos, maxFocus and minFocus, the detection step size of frame 1 is calculated. For other detection frames, the method of calculating the detection step size is the same.

[0089] Furthermore, the step S12 of calculating the detection step length of the current detection frame according to the current position of the zoom motor, the first value and the second value may include:

[0090] If the current position of the zoom motor is in the first interval, the detection step length of the current detection frame is determined to be 0; the first interval is the position interval of the zoom motor corresponding to the overlapped part of the lens curve under each preset object distance;

[0091] If the current position of the zoom motor is in the second interval, the detection step of the current detection frame is calculated according to the preset adjustment factor, the first value and the second value; the second interval is the position interval of the zoom motor corresponding to the scattered part of the lens curve under the preset object distances.

[0092] like Figure 2 As shown in the figure, when the zoom direction is direction A, that is, the ZOOM value (the position of the ZOOM motor) increases from small to large, which is from left to right in the coordinate system. The lens curves corresponding to different object distances are basically overlapped in the first section, and gradually dispersed in the second section. During the zoom process in direction A, after the ZOOM motor moves to the position corresponding to the scattered point of the lens curve, it is unknown which lens curve should be selected. Therefore, it is necessary to estimate the object distance and continuously correct the object distance during the zoom process. Among them, the scattered point refers to the point where the overlap of the lens curve under each preset object distance ends and the scattered point begins to appear.

[0093] The embodiment of the present invention divides the ZOOM value corresponding to the lens curve at each preset object distance into at least two intervals, the first interval is the ZOOM value interval corresponding to the overlapping part of the lens curve, and the second interval is the ZOOM value interval corresponding to the dispersed part of the lens curve.

[0094] In the first interval, the lens curves corresponding to various object distances basically coincide, that is, the depth of field of the lens is large in this stage. No matter which lens curve is selected, when the image is in focus, the position of the ZOOM motor and the position of the FOCUS motor are basically the same. Therefore, FOCUS detection is not required in this stage, and the detection step is set to 0.

[0095] In the second interval, the lens curves corresponding to the various object distances no longer overlap, but are dispersed, and selecting different lens curves will directly affect whether the image can be focused clearly. Therefore, in the second interval, the detection step length of the detection frame can be calculated according to the preset adjustment factor, the first value, and the second value to detect the difference in lens curves at different object distances.

[0096] Exemplarily, in the second interval, the detection step length focusProbeStep can be calculated by the following formula:

[0097] focusProbeStep = |maxFocus - minFocus| / spiltfactor (1)

[0098] Among them, spiltfactor is a preset adjustment factor, which can be used to adjust the size of the detection step length. The value of spiltfactor can be set according to actual needs. For example, the value of spiltfactor can be set to 30 or 200. Using formula (1), the detection step length can be set smaller, and the detection cycle can be set shorter, which is equivalent to small-step fast adjustment, and can achieve fast and accurate estimation of the actual object distance.

[0099] In an optional embodiment of the present invention, the method may further include:

[0100] The position of the zoom motor corresponding to the lens curve at each preset object distance is divided into a first interval and a second interval based on a first dividing point; the first dividing point can be a ZOOM value corresponding to a scattered point of the lens curve at each preset object distance, and the ZOOM value from 0 to the scattered point is the first interval, and the ZOOM value greater than the scattered point is the second interval.

[0101] like Figure 2 As shown, assuming that the ZOOM value corresponding to the scattered point is 4000, the first division point is 4000, the first interval includes the position of the ZOOM motor in the interval [0,4000), and the second interval includes the position of the ZOOM motor in the interval greater than or equal to 4000.

[0102] In an optional embodiment of the present invention, the method may further include:

[0103] A second dividing point is determined in the second interval; and the second interval is divided into a first sub-interval and a second sub-interval based on the second dividing point, thereby obtaining three intervals.

[0104] like Figure 2As shown in the figure, the lens curves at different object distances have a transition process from coincidence to dispersion. When the dispersion begins, the lens curves are still close to coincidence, and then gradually pull away from each other. In the initial stage of dispersion, the difference between the lens curves at each object distance is very small. At this time, if a smaller detection step is used, it is difficult to detect the difference at a smaller object distance. For example, the initial object distance is 6 meters, and the actual object distance is 20 meters. In the early stage of lens curve dispersion, if the detection step is calculated using formula (1), the calculated detection step is small. At this time, the difference between the lens curves at each object distance is very small, resulting in the detection of image clarity values ​​of 5 meters and 7 meters being similar. Therefore, it is difficult to accurately estimate the actual object distance using a smaller detection step. When the dispersion distance of each lens curve is large, a smaller detection step can be used to detect the difference at a smaller object distance. For example, if the initial object distance is 6 meters, in the middle and late stages of lens curve dispersion, due to the large difference between the lens curves at each object distance, the image clarity values ​​detected at 5 meters and 7 meters will be greatly different. A smaller detection step can be used to accurately estimate the actual object distance.

[0105] Therefore, the embodiment of the present invention can further subdivide the second interval, and subdivide the dispersion part of each lens curve into an early dispersion period (first sub-interval) and a middle and late dispersion period (second sub-interval), and different detection step calculation methods can be used for different sub-intervals.

[0106] In one example, the embodiment of the present invention divides the position of the ZOOM motor corresponding to the lens curve at each preset object distance into the following three intervals: the first interval corresponds to before the lens curve dispersion point, such as Figure 1 The position of the ZOOM motor is in the interval [0,4000); the second interval (also called the first sub-interval) corresponds to the early dispersion of the lens curve, such as the position of the ZOOM motor in the interval [4000,7000); the third interval (also called the second sub-interval) corresponds to the middle and late dispersion of the lens curve, such as the position of the ZOOM motor is greater than or equal to 7000. During the zoom process, the position of the ZOOM motor is in different intervals, and different methods can be used to calculate the detection step of the current detection frame.

[0107] Furthermore, for the current detection frame, if curZoomPos is in the first interval at this time, the detection step of the current detection frame can be set to focusProbeStep = 0, and detection is not required. If curZoomPos is in the second interval at this time, the difference in the lens curves at each object distance is very small, and it is not sensitive to a smaller detection step. Therefore, the detection step of the current detection frame can be set to a specified value, and the specified value can be a preset value greater than the detection step calculated by formula (1), such as a specified value of 18. Still taking the above-mentioned initial object distance of 6 meters and the actual object distance of 20 meters as an example, if the specified value 18 is used as the detection step of the current frame at this time, the detection can be extended to 10 meters and 3 meters, and the clarity value of 10 meters will be significantly greater than 3 meters, and the estimated object distance will be closer to the actual object distance of 20 meters; compared with using formula (1), using the specified value as the detection step in the second stage can more accurately estimate the actual object distance and improve the effect of zoom focus. If curZoomPos is in the third stage at this time, since the difference in lens curves at different object distances is large at this time, it is more sensitive to a smaller detection step. Therefore, formula (1) can be used to calculate the detection step of the current detection frame.

[0108] It should be noted that the above division of the ZOOM value corresponding to the lens curve under each preset object distance into two intervals or three intervals is only for exemplary description, and the embodiment of the present invention does not limit the number of divided intervals. For example, the third interval can be further divided into two sub-intervals, thereby dividing into the following four intervals: the first interval corresponds to before the lens curve scatter point, such as Figure 1 The position of the ZOOM motor is in the interval [0,4000); the second interval corresponds to the initial dispersion of the lens curve, such as the position of the ZOOM motor in the interval [4000,7000); the third interval corresponds to the middle dispersion of the lens curve, such as the position of the ZOOM motor in the interval [7000,10000); the fourth interval corresponds to the late dispersion of the lens curve, such as the position of the ZOOM motor in the interval greater than or equal to 10000. When divided into four intervals, for the first interval and the fourth interval, the detection step of the current frame can be set to focusProbeStep = 0. For the second interval, the specified value can be used as the detection step of the current frame. For the third interval, the detection step of the current frame can be calculated using formula (1).

[0109] Of course, the embodiment of the present invention does not limit the position of the division points of each interval, and can be debugged according to the experimental data in the actual scene. For example, the first division point can be 5084, the second division point can be 9000, and the third division point can be 10056. These three division points can be used to divide the ZOOM value into four intervals.

[0110] In an optional embodiment of the present invention, after the detection step length of the current detection frame is calculated using formula (1), the calculated detection step length may be limited by a preset step length limit value, as follows:

[0111] focusProbeStep=MIN(focusProbeStep,MaxStep) (2)

[0112] focusProbeStep=MAX(focusProbeStep,MinStep) (3)

[0113] Among them, the MIN function is used to return the smaller value of the two, and the MAX function is used to return the larger value of the two. MinStep and MaxStep are step limit values, which can be configured as needed. MinStep is the minimum step limit value, and MaxStep is the maximum step limit value. The above formulas (2) and (3) can be used to limit the calculated detection step size to MinStep and MaxStep to avoid unreasonable calculated detection step size (such as too large or too small). In an example, MinStep=2 and MaxStep=72 are set.

[0114] In an optional embodiment of the present invention, after calculating the detection step length of the current detection frame in step S12, the method may further include:

[0115] Step S21, determining the amplitude coefficient according to the type of the target currently being photographed;

[0116] Step S22: multiply the detection step length of the current frame by the amplitude coefficient, and use the obtained result as the detection step length of the current detection frame.

[0117] In a specific implementation, the detection step length calculated in step S12 may be used as a benchmark detection step length, and the benchmark detection step length may be directly used by default.

[0118] Furthermore, the amplitude coefficient is determined according to the type of the target currently being photographed, and the reference detection step length is adjusted using the amplitude coefficient to obtain the detection step length actually required for the current detection frame. For example, if a moving object needs to be tracked, the amplitude coefficient can be increased to increase the detection step length, so that the image can be kept clear during the process of following the focus of the moving object.

[0119] Different amplitude coefficients can be set for moving objects of different target types. For example, for the current detection frame, when it is determined that the target type to be photographed is a person, the amplitude coefficient can be determined to be 1.5, and the detection step length of the current detection frame is the detection step length of the benchmark multiplied by 1.5; when it is determined that the target type to be photographed is a vehicle, the amplitude coefficient can be determined to be 2.5, and the detection step length of the current detection frame is the detection step length of the benchmark multiplied by 2.5.

[0120] The embodiments of the present invention can estimate the object distance of a moving object in real time, so that the image can be kept clear during the process of following the focus of the moving object. Real-time estimation of the object distance of a moving object refers to the object distance estimation performed when the target detection algorithm detects a specified target (such as a person or a vehicle) and sends a target detection frame. Compared with the object distance estimation for non-moving objects, the goal of real-time object distance estimation for moving objects is to limit the clarity calculation range to the target detection frame.

[0121] In an optional embodiment of the present invention, the step 104 of correcting the initial object distance based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain the corrected object distance may include:

[0122] Step S31, obtaining the clarity evaluation values ​​corresponding to all detection frames in the current cycle;

[0123] Step S32, summing the clarity evaluation values ​​in the first detection direction to obtain a first sum value, and summing the clarity evaluation values ​​in the second detection direction to obtain a second sum value;

[0124] Step S33, calculating a focus correction value based on the first sum value and the second sum value;

[0125] Step S34, searching for a lens curve corresponding to the initial object distance based on the initial object distance and the next position of the zoom motor to obtain the next position of the focus motor;

[0126] Step S35, using the focus correction value to correct the next position of the focus motor to obtain a corrected position of the focus motor;

[0127] Step S36, searching the lens curves at each preset object distance based on the next step position of the zoom motor and the corrected position of the focus motor to obtain the corrected object distance.

[0128] Taking the medium cycle mode as an example, at the 7th frame, the detection results of two FAR directions and two NEAR directions have been collected. At this time, the clarity evaluation value obtained by detecting each detection frame in the current cycle can be obtained, such as far1Fv, near1Fv, near2Fv and far2Fv.

[0129] The clarity evaluation values ​​in the first detection direction are summed to obtain a first sum value, and the clarity evaluation values ​​in the second detection direction are summed to obtain a second sum value.

[0130] Specifically, a first sum value farSumFv=far1Fv+far2Fv is calculated, and a second sum value nearSumFv=near1Fv+near2Fv is calculated.

[0131] Based on the first sum value farSumFv and the second sum value nearSumFv, a focus correction value (such as focusDiff) can be calculated. The focus correction value focusDiff refers to the correction value of the theoretical position of the FOCUS motor calculated at the current object distance (such as the initial object distance), and the corrected object distance can be determined based on the focus correction value. focusDiff is converted into the difference in the position of the FOCUS motor by detecting the difference in the FV value of the frame and combining the adjustment coefficient, so as to correct the position of the FOCUS motor and further obtain the corrected object distance.

[0132] It should be noted that, in the short cycle mode, one cycle includes 5 frames, and the first frame and the second frame are set as detection frames. Since only one detection in the FAR direction and one detection in the NEAR direction are performed, the FV value obtained by detecting the first frame is far1Fv, and the FV value obtained by detecting the second frame is near1Fv. There is no far2Fv and near2Fv in the short cycle mode. In order to make the calculation method of the first sum and the second sum in different cycle modes the same, a unified formula (such as the following formulas (4) to (7)) can be used to calculate the corrected object distance. In the embodiment of the present invention, in the short cycle mode, the far1Fv obtained by detecting the first frame is assigned to far2Fv, and the near1Fv obtained by detecting the second frame is assigned to near2fv; that is, far2fv=far1fv, near2fv=near1fv; the object distance correction is performed in the last frame of the short cycle, and the correction method is the same as that of the medium cycle.

[0133] For the long cycle mode, the object distance correction method is the same as that for the medium cycle. Furthermore, for the long cycle, the target frame can be the same as that for the medium cycle. For example, the target frame is the 7th frame. The difference is that for the medium cycle, the 7th frame is the last frame; for the long cycle, the 7th frame is not the last frame. The only difference between the long cycle and the medium cycle is that the frequency of object distance correction for the long cycle is relatively low.

[0134] In the embodiment of the present invention, in the short cycle mode and the medium cycle mode, the target frame is the last frame of the current cycle; in the long cycle mode, the target frame is the FvDelay+4th frame of the current cycle.

[0135] In an optional embodiment of the present invention, the step S33 of calculating the focus correction value based on the first sum value and the second sum value may include:

[0136] The first intermediate result fvDiff is calculated based on the first sum value and the second sum value according to the following formula:

[0137] fvDiff = (farSumFv-nearSumFv) / (MAX(nearSumFv,farSumFv) / Th) (4)

[0138] Among them, farSumFv is the first sum value, nearSumFv is the second sum value, Th is the preset threshold value, and the value of Th can be set as needed;

[0139] Based on the first intermediate result, the focus correction value focusDiff is calculated according to the following formula:

[0140] focusDiff=(fvDiff×K1+fvDiff / 2×sig)×K2+ AveProbeStep×K3×(1+sig)(5)

[0141] Among them, AveProbeStep is the average detection step size of the current cycle, sig is the second intermediate result, sig is calculated based on the difference between the clarity evaluation value of the first detection direction and the clarity evaluation value of the second detection direction, and K1, K2 and K3 are correction amplitude factors.

[0142] Furthermore, in the medium cycle mode or the long cycle mode, when sig>=0, K2=0; when sig<0, K2=-1. In the short cycle mode, K2=1.

[0143] In a specific implementation, AveProbeStep may be an average value of the detection step lengths of each detection frame in the current cycle. Alternatively, in a specific implementation, each detection frame may use the same detection step length, and AveProbeStep is the same detection step length used for each detection frame.

[0144] Exemplarily, the second intermediate result sig may be calculated by the following formula:

[0145] sig = fv1Diff × fv2Diff (6)

[0146] Among them, fv1Diff=far1Fv-near1Fv, fv2Diff=far2Fv-near2Fv. It can be understood that, in the short cycle mode, sig=fv1Diff.

[0147] After the focus correction value focusDiff is calculated, the lens curve corresponding to the initial object distance is searched based on the initial object distance and the next position nextZoomPos of the zoom motor to obtain the next position nextFocusPos of the focus motor. The focus correction value focusDiff can be used to correct the next position nextFocusPos of the focus motor by the following formula to obtain the corrected position of the focus motor (e.g., denoted as mFocusPos):

[0148] mFocusPos = nextFocusPos – focusDiff (7)

[0149] Based on the next step position nextZoomPos of the zoom motor and the corrected position mFocusPos of the focus motor, the lens curves at each object distance are searched to obtain a corrected object distance (such as newDist) after correcting the initial object distance.

[0150] Furthermore, in order to prevent the calculated newDist from being too large or too small in extreme cases, newDist can be limited by the following formula:

[0151] newDist=MAX(MIN(MaxDistStep+curDist,newDist),curDist-MaxDistStep)(8)

[0152] Among them, MaxDistStep is the object distance estimation threshold, and the value of MaxDistStep is adjustable, which is used to limit the maximum value of the calculated corrected object distance, such as setting MaxDistStep to 500.

[0153] Therefore, in the target frame of the current cycle, the corrected object distance newDist can be calculated and used as the initial object distance of the next cycle.

[0154] For the target frame of the current cycle, the lens curve corresponding to newDist can be searched according to nextZoomPos and newDist to obtain the corresponding nextFocusPos, and curFocusPos can be directly read, thereby calculating curFocusStep=curFocusPos-nextFocusPos.

[0155] Through the embodiments of the present invention, accurate zoom focusing can be achieved for scenes of shooting still objects or moving objects, so that the image remains clear throughout the entire zooming process, and the smoothness of the zooming process is improved. In a specific implementation, different parameters and different clarity calculation ranges can be set for different shooting scenes to achieve better zoom focusing effects in different shooting scenes.

[0156] The parameters include but are not limited to the above correction amplitude factors (K1, K2 and K3) and the preset threshold Th. The definition calculation range is adjusted by the above object distance estimation threshold (MaxDistStep).

[0157] In one example, for a scene of photographing a stationary object, K1=1, K2=5, K3=1, Th=80 may be set; and MaxDistStep=1000 may be set.

[0158] For a scene of shooting a moving object, K1=2, K2=7, K3=1.2, Th=40 may be set; and MaxDistStep=500 may be set.

[0159] After calculating the moving step length of the focus motor corresponding to each frame (such as curFocusStep), the focus motor can be driven to move according to the moving step length of the focus motor corresponding to the frame and the movement direction of the focus motor; wherein, if the moving step length of the focus motor is less than 0, the movement direction is consistent with the first detection direction; if the moving step length of the focus motor is greater than 0, the movement direction is consistent with the second detection direction.

[0160] Specifically, for each frame in the current cycle, after calculating the nextFocusPos corresponding to the frame, the curFocusPos corresponding to the frame can be directly read, so the curFocusStep corresponding to the frame can be calculated as curFocusPos-nextFocusPos. If curFocusStep is less than 0 at this time, the focus motor is moved by a distance of |curFocusStep| in the first detection direction (such as the FAR direction). If curFocusStep is greater than 0 at this time, the focus motor is moved by a distance of |curFocusStep| in the second detection direction (such as the NEAR direction).

[0161] Through the embodiment of the present invention, for each frame in the current cycle, the curZoomStep that the ZOOM motor needs to move and the curFocusStep that the FOCUS motor needs to move to shoot the frame image can be calculated, and the FOCUS motor can be driven to move in combination with the movement direction of the FOCUS motor. In this way, the object distance correction is continuously performed in each cycle to achieve more accurate zoom focus, so that the image remains clear throughout the process, and the jitter of the image clarity during the zoom process is reduced.

[0162] The following takes shooting 7 frames in one cycle as an example to illustrate the variable magnification focusing process of the present invention. Specifically, at the beginning of the current cycle, the initial object distance (such as denoted as curDist) is determined.

[0163] For the first frame, detect in the FAR direction, obtain the current curZoomPos and the current zoom speed level, look up the preset mapping table, and get the corresponding curZoomStep; calculate nextZoomPos = curZoomPos(+ / -)curZoomStep; calculate the detection step focusProbeStep of the first frame according to the lens curve table corresponding to curZoomPos and curDist; obtain the corresponding nextFocusPos according to the lens curve corresponding to nextZoomPos and curDist, thereby calculating curFocusStep = curFocusPos-nextFocusPos; wherein curFocusPos can be directly read; update the calculated curFocusStep to: curFocusStep = curFocusStep-focusProbeStep, and obtain curFocusStep of the first frame. If curFocusStep is less than 0, the FOCUS motor is driven to move the distance |curFocusStep| in the FAR direction; if curFocusStep is greater than 0, the FOCUS motor is driven to move the distance |curFocusStep| in the NEAR direction.

[0164] It should be noted that, in nextZoomPos=curZoomPos(+ / -)curZoomStep, when the zoom direction is direction A, the value in the formula is "+"; when the zoom direction is direction B, the value in the formula is "-"; the same applies to the following.

[0165] For the second frame, detect in the NEAR direction, obtain the current curZoomPos (due to the movement of the ZOOM motor, the curZoomPos of the second frame is different from that of the first frame) and the current zoom speed level, look up the preset mapping table, and obtain the corresponding curZoomStep; calculate nextZoomPos = curZoomPos (+ / -) curZoomStep; according to the lens curve table corresponding to the curZoomPos and curDist, calculate the detection step focusProbeStep of the second frame; according to the lens curve corresponding to the nextZoomPos and curDist, obtain the corresponding nextFocusPos, thereby calculating curFocusStep = curFocusPos-nextFocusPos; wherein curFocusPos can be directly read; update the calculated curFocusStep to: curFocusStep = curFocusStep + focusProbeStep, and obtain curFocusStep of the second frame. If curFocusStep is less than 0, the FOCUS motor is driven to move the distance |curFocusStep| in the FAR direction; if curFocusStep is greater than 0, the FOCUS motor is driven to move the distance |curFocusStep| in the NEAR direction.

[0166] The third and fourth frames are similar to the first two frames and will not be described again here.

[0167] Frame 5 is similar to frame 6, but the difference from the first four frames is that the calculated curFocusStep does not need to be updated using the detection step size.

[0168] For the 5th frame, get the current curZoomPos and the current zoom speed level, look up the preset mapping table, and get the corresponding curZoomStep; calculate nextZoomPos = curZoomPos (+ / -) curZoomStep; according to the lens curve corresponding to nextZoomPos and curDist, get the corresponding nextFocusPos, from which curFocusStep = curFocusPos-nextFocusPos can be calculated; where curFocusPos can be directly read to get curFocusStep of the 5th frame. If curFocusStep is less than 0, drive the FOCUS motor to move the distance of |curFocusStep| in the FAR direction; if curFocusStep is greater than 0, drive the FOCUS motor to move the distance of |curFocusStep| in the NEAR direction.

[0169] The sixth frame is similar to the fifth frame and will not be described again here.

[0170] For the 7th frame, the detection results of all detection frames in this cycle can be obtained at this time, and the initial object distance is corrected based on the obtained detection results to obtain the corrected object distance newDist. Get the current curZoomPos and the current zoom speed level, look up the preset mapping table, and get the corresponding curZoomStep; calculate nextZoomPos = curZoomPos (+ / -) curZoomStep; according to the lens curve corresponding to nextZoomPos and newDist, get the corresponding nextFocusPos, thereby calculating curFocusStep = curFocusPos-nextFocusPos; where curFocusPos can be directly read to get curFocusStep of the 7th frame. If curFocusStep is less than 0, drive the FOCUS motor to move the distance of |curFocusStep| in the FAR direction; if curFocusStep is greater than 0, drive the FOCUS motor to move the distance of |curFocusStep| in the NEAR direction.

[0171] For the 8th frame (entering the next cycle at this time), the initial object distance curDist of this cycle is newDist of the previous cycle, and the processing of the next cycle is entered according to the processing method of the previous cycle.

[0172] The embodiment of the present invention describes the zoom focusing process in direction A. In the zoom process in direction B, the corrected object distance of the current scene is known, and the ZOOM motor and FOCUS motor of the lens can be moved according to the lens curve corresponding to the corrected object distance.

[0173] Furthermore, in the same shooting scene, when the zoom direction A reaches the maximum magnification, the object distance after the autofocus is completed can be recorded. This object distance is the most accurate object distance after the zoom is completed (called the reference object distance). In the same shooting scene later, the lens curve corresponding to the reference object distance can be directly used to calculate the corresponding ZOOM step length (curZoomStep) and FOCUS step length (curFocusStep). After each zoom stop, the reference object distance after the autofocus is completed can be recorded as the initial object distance of the first cycle when the next zoom starts.

[0174] Furthermore, embodiments of the present invention can provide two zoom focusing modes: learning mode and non-learning mode. When a large area of ​​objects block the shooting scene and the originally recorded reference object distance is changed, the clarity will decrease after one zoom. At this time, the corrected new object distance can be obtained again after automatic focusing, and the zoom focusing process can remain clear. This method is called learning mode. The zoom focusing process before learning can use the zoom focusing method described above, and the recorded reference object distance can be used directly after learning. When the scene changes, re-learning can be done. Whether to enable the learning mode can be selected by the user. If the non-learning mode is used, the zoom focusing method described above is used directly; if the learning mode is used, the zoom focusing method described above can be used when switching to the corresponding scene for the first time. The learning mode can be applied to monitoring scenes such as pan-tilt cameras and tube cameras in fixed positions; the non-learning mode can be applied to various types of monitoring and zoom equipment such as drones.

[0175] The learning mode can include the following two situations: In the first situation, when the object distance of the current scene is unknown during the first zooming, the zoom focusing method described above is used to periodically estimate and correct the object distance. After the zooming is completed, the automatic focus is triggered to obtain the accurate object distance (reference object distance). At this time, the object distance of the current scene is learned. In the second situation: No operation is performed, but the intelligent algorithm detects that the scene has changed (such as the appearance of a large area of ​​​​object occlusion, etc.), then the automatic focus is triggered once, and the accurate object distance (reference object distance) is obtained again after the focusing is completed. At this time, the object distance of the current scene is learned.

[0176] The object distance estimation method in zoom focusing provided by the embodiment of the present invention can estimate a relatively accurate object distance as the initial object distance of the next frame in each cycle through object distance estimation during the zoom process of the lens, and perform FOCUS detection in the FAR direction and the NEAR direction based on the initial object distance, and estimate the object distance of the current scene according to the detection result, and perform periodic correction on the estimated object distance, so that the moving step length of the focus motor and the moving step length of the zoom motor are more matched. The cycle of object distance correction in the embodiment of the present invention is shorter than the cycle of object distance detection, and the length of the cycle is adjustable. Through periodic object distance correction, small-step and fast correction can be achieved, and the wrong object distance can be corrected in time. The jitter of image clarity caused by inaccurate object distance during the zoom process can be reduced, so that the image can always remain clear during the zoom process, and the smoothness of the zoom process is improved.

[0177] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.

[0178] Reference Figure 3 , shows a structural block diagram of an embodiment of an object distance estimation device in variable magnification focus of the present invention, the device can be applied to a video acquisition device, and the device may include:

[0179] The initial object distance determination module 301 is used to determine the initial object distance at the beginning of the current cycle; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction;

[0180] A detection step length determination module 302 is used to determine the detection step length corresponding to each detection frame in the current cycle;

[0181] A detection module 303 is used to detect the position of the focus motor based on the initial object distance according to the detection direction and detection step length of each detection frame to obtain a clarity evaluation value corresponding to each detection frame;

[0182] The object distance correction module 304 is used to correct the initial object distance at the target frame of the current cycle based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.

[0183] Optionally, the detection module includes:

[0184] A first determination submodule, configured to determine, for a current detection frame in the current cycle, a next step position of the zoom motor according to a current position of the zoom motor and a moving step length of the zoom motor;

[0185] A second determination submodule, used to determine a next position of the focus motor according to the next position of the zoom motor and the initial object distance;

[0186] A third determination submodule, used to determine the moving step length of the focus motor corresponding to the current detection frame according to the current position of the focus motor and the next step position of the focus motor;

[0187] A moving step length updating submodule, used to update the moving step length of the focus motor corresponding to the current detection frame based on the detection direction and the detection step length corresponding to the current detection frame to obtain an updated step length;

[0188] The movement calculation submodule is used to calculate the clarity evaluation value corresponding to the current detection frame after driving the focus motor to move based on the detection direction of the current detection frame and the update step size.

[0189] Optionally, the device further comprises:

[0190] A mapping query module is used to search a preset mapping table for the current detection frame according to the current position of the zoom motor and the current zoom speed level to obtain the moving step of the zoom motor; wherein the preset mapping table records the mapping relationship between the position of the zoom motor and the moving step of the zoom motor at different zoom speed levels.

[0191] Optionally, the detection step length determination module includes:

[0192] A numerical query submodule, for searching, for a current detection frame in the current cycle, the lens curves at each preset object distance based on the current position of the zoom motor, to obtain a first numerical value and a second numerical value; the first numerical value is the position of the focus motor obtained by searching the lens curve at the maximum object distance among the preset object distances based on the current position of the zoom motor, and the second numerical value is the position of the focus motor obtained by searching the lens curve at the minimum object distance among the preset object distances based on the current position of the zoom motor;

[0193] The detection step length calculation submodule is used to calculate the detection step length of the current detection frame according to the current position of the zoom motor, the first value and the second value.

[0194] Optionally, the detection step length calculation submodule includes:

[0195] a first calculation unit, configured to determine that the detection step length of the current detection frame is 0 if the current position of the zoom motor is in a first interval; the first interval is a position interval of the zoom motor corresponding to the overlapped portion of the lens curve under each preset object distance;

[0196] A second calculation unit is used to calculate the detection step of the current detection frame according to a preset adjustment factor, the first value and the second value if the current position of the zoom motor is in a second interval; the second interval is a position interval of the zoom motor corresponding to the scattered part of the lens curve under each preset object distance.

[0197] Optionally, the second calculation unit is specifically configured to calculate the detection step length of the current detection frame according to the following formula:

[0198] focusProbeStep=|maxFocus-minFocus| / spiltfactor

[0199] Among them, spiltfactor is a preset adjustment factor, maxFocus is a first value, and minFocus is a second value.

[0200] Optionally, the device further includes a detection step length updating module, which is specifically used to:

[0201] The amplitude coefficient is determined according to the type of the target currently photographed; the obtained result is used as the detection step length of the current detection frame, and the obtained result is updated as the detection step length of the detection frame.

[0202] Optionally, the moving step size updating submodule is specifically used to:

[0203] If the detection direction of the current detection frame is the first detection direction, subtracting the detection step length of the current detection frame from the moving step length of the focus motor corresponding to the current detection frame;

[0204] If the detection direction of the current detection frame is the second detection direction, the moving step length of the focus motor corresponding to the current detection frame is added to the detection step length of the current detection frame.

[0205] Optionally, the mobile computing submodule is specifically used to:

[0206] If the update step size corresponding to the current detection frame is less than 0, the focus motor is driven to move toward the first detection direction by the absolute value of the update step size; if the update step size corresponding to the current detection frame is greater than 0, the focus motor is driven to move toward the second detection direction by the absolute value of the update step size.

[0207] Optionally, the number of frames included in the current cycle is determined according to a cycle mode of the current cycle, and the cycle mode includes one of a long cycle, a medium cycle or a short cycle; wherein the long cycle includes (FvDelay+6+n) frames, and n is a custom value; the medium cycle includes (FvDelay+4) frames; the short cycle includes (FvDelay+2) frames; FvDelay is the number of interval frames required for performing a detection on a detection frame and obtaining the clarity evaluation value of the detection.

[0208] Optionally, the object distance correction module includes:

[0209] A result acquisition submodule is used to obtain the clarity evaluation values ​​corresponding to all detection frames in the current cycle;

[0210] a summing submodule, configured to sum the clarity evaluation values ​​in the first detection direction to obtain a first sum value, and sum the clarity evaluation values ​​in the second detection direction to obtain a second sum value;

[0211] A focus correction calculation submodule, configured to calculate a focus correction value based on the first sum value and the second sum value;

[0212] A first search submodule is used to search for a lens curve corresponding to the initial object distance based on the initial object distance and the next position of the zoom motor to obtain the next position of the focus motor;

[0213] A correction submodule, used to correct the next position of the focus motor using the focus correction value to obtain a corrected position of the focus motor;

[0214] The second search submodule is used to search for lens curves at various preset object distances based on the next step position of the zoom motor and the corrected position of the focus motor to obtain the corrected object distance.

[0215] Optionally, the focus correction calculation submodule is specifically used to:

[0216] The first intermediate result fvDiff is calculated based on the first sum value and the second sum value according to the following formula:

[0217] fvDiff=(farSumFv-nearSumFv) / (MAX(nearSumFv, farSumFv) / Th);

[0218] Among them, farSumFv is the first sum value, nearSumFv is the second sum value, and Th is the preset threshold;

[0219] Based on the first intermediate result, the focus correction value focusDiff is calculated according to the following formula:

[0220] focusDiff=(fvDiff×K1+fvDiff / 2×sig)×K2+AveProbeStep×K3×(1+sig);

[0221] Among them, AveProbeStep is the average detection step size of the current cycle, sig is the second intermediate result, sig is calculated based on the difference between the clarity evaluation value of the first detection direction and the clarity evaluation value of the second detection direction, and K1, K2 and K3 are correction amplitude factors.

[0222] Optionally, the magnification change direction of the current cycle is from a small magnification to a large magnification.

[0223] Optionally, the initial object distance is the object distance when autofocusing is completed, or the initial object distance is the corrected object distance of the previous cycle.

[0224] The object distance estimation device in zoom focusing provided by the embodiment of the present invention can estimate a relatively accurate object distance as the initial object distance of the next frame in each cycle through object distance estimation during the zoom process of the lens, perform FOCUS detection in the FAR direction and the NEAR direction based on the initial object distance, estimate the object distance of the current scene according to the detection result, and perform periodic correction on the estimated object distance so that the moving step length of the focus motor and the moving step length of the zoom motor are more matched. The cycle of object distance correction in the embodiment of the present invention is shorter than the cycle of object distance detection, and the length of the cycle is adjustable. Through periodic object distance correction, small-step and fast correction can be achieved, and the wrong object distance can be corrected in time. The jitter of image clarity caused by inaccurate object distance during the zoom process can be reduced, so that the image can always remain clear during the zoom process, and the smoothness of the zoom process is improved.

[0225] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0226] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0227] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0228] The embodiment of the present invention also provides a non-temporary computer-readable storage medium, when the instructions in the storage medium are executed by a processor of a device (server or terminal), the device can execute the above Figure 1The description of the variable magnification focusing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer program product or computer program embodiment involved in this application, please refer to the description of the method embodiment of this application.

[0229] Those skilled in the art will readily appreciate other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. The present invention is intended to cover any variations, uses or adaptations of the present invention that follow the general principles of the present invention and include common knowledge or customary techniques in the art not disclosed by the present invention. The description and examples are to be regarded as exemplary only, and the true scope and spirit of the present invention is indicated by the following claims.

[0230] It should be understood that the present invention is not limited to the exact construction that has been described above and shown in the drawings and that various modifications and changes may be made without departing from the scope thereof. The scope of the present invention is limited only by the appended claims.

[0231] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

[0232] The above is a detailed introduction to the object distance estimation method and device in variable magnification focusing provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea; at the same time, for general technical personnel in this field, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A method for estimating object distance in variable magnification focusing, characterized in that: Applied to an image acquisition device, the method comprises: At the beginning of a current cycle, an initial object distance is determined; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction; Determine a detection step size corresponding to each detection frame in the current cycle; Based on the initial object distance, the position of the focus motor is detected according to the detection direction and the detection step length of each detection frame to obtain a clarity evaluation value corresponding to each detection frame; At the target frame of the current cycle, the initial object distance is corrected based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.

2. The method according to claim 1, characterized in that Based on the initial object distance, the position of the focus motor is detected according to the detection direction and the detection step length of each detection frame to obtain a clarity evaluation value corresponding to each detection frame, including: For a current detection frame in the current cycle, determining a next step position of the zoom motor according to a current position of the zoom motor and a moving step length of the zoom motor; Determining a next position of a focus motor according to a next position of the zoom motor and the initial object distance; Determining a moving step length of the focus motor corresponding to the current detection frame according to the current position of the focus motor and the next step position of the focus motor; Based on the detection direction and the detection step length corresponding to the current detection frame, the moving step length of the focus motor corresponding to the current detection frame is updated to obtain an updated step length; After driving the focus motor to move based on the detection direction of the current detection frame and the update step length, a clarity evaluation value corresponding to the current detection frame is calculated.

3. The method according to claim 2, characterized in that The method further comprises: For the current detection frame, a preset mapping table is searched according to the current position of the zoom motor and the current magnification speed level to obtain the moving step of the zoom motor; wherein the preset mapping table records the mapping relationship between the position of the zoom motor and the moving step of the zoom motor at different magnification speed levels.

4. The method according to claim 1, characterized in that The determining the detection step length corresponding to each detection frame in the current cycle includes: For the current detection frame in the current cycle, the lens curves at the preset object distances are searched based on the current position of the zoom motor to obtain a first value and a second value; the first value is the position of the focus motor obtained by searching the lens curve at the maximum object distance among the preset object distances based on the current position of the zoom motor, and the second value is the position of the focus motor obtained by searching the lens curve at the minimum object distance among the preset object distances based on the current position of the zoom motor; The detection step length of the current detection frame is calculated according to the current position of the zoom motor, the first value, and the second value.

5. The method according to claim 4, characterized in that The step of calculating the detection step length of the current detection frame according to the current position of the zoom motor, the first value, and the second value includes: If the current position of the zoom motor is in the first interval, the detection step length of the current detection frame is determined to be 0; the first interval is the position interval of the zoom motor corresponding to the overlapped part of the lens curve under each preset object distance; If the current position of the zoom motor is in the second interval, the detection step of the current detection frame is calculated according to the preset adjustment factor, the first value and the second value; the second interval is the position interval of the zoom motor corresponding to the scattered part of the lens curve under the preset object distances.

6. The method according to claim 5, characterized in that The calculating the detection step length of the current detection frame according to the preset adjustment factor, the first value and the second value includes: The detection step length of the current detection frame is calculated according to the following formula: focusProbeStep=|maxFocus-minFocus| / spiltfactor Among them, spiltfactor is a preset adjustment factor, maxFocus is a first value, and minFocus is a second value.

7. The method according to claim 4, characterized in that After calculating the detection step length of the current detection frame, the method further includes: Determine the amplitude coefficient according to the type of target currently being photographed; The detection step length of the current frame is multiplied by the amplitude coefficient, and the obtained result is used as the detection step length of the current detection frame.

8. The method according to claim 2, characterized in that: The updating of the moving step length of the focus motor corresponding to the current detection frame based on the detection direction and the detection step length corresponding to the current detection frame includes: If the detection direction of the current detection frame is the first detection direction, subtracting the detection step length of the current detection frame from the moving step length of the focus motor corresponding to the current detection frame; If the detection direction of the current detection frame is the second detection direction, the moving step length of the focus motor corresponding to the current detection frame is added to the detection step length of the current detection frame.

9. The method according to claim 2, characterized in that: The step of driving the focus motor to move based on the detection direction of the current detection frame and the update step size includes: If the update step size corresponding to the current detection frame is less than 0, the focus motor is driven to move toward the first detection direction by the absolute value of the update step size; if the update step size corresponding to the current detection frame is greater than 0, the focus motor is driven to move toward the second detection direction by the absolute value of the update step size.

10. The method according to claim 1, characterized in that The number of frames included in the current cycle is determined according to the cycle mode of the current cycle, and the cycle mode includes one of a long cycle, a medium cycle or a short cycle; wherein the long cycle includes (FvDelay+6+n) frames, and n is a custom value; the medium cycle includes (FvDelay+4) frames; the short cycle includes (FvDelay+2) frames; FvDelay is the number of interval frames required for performing a detection on a detection frame and obtaining the clarity evaluation value of the detection.

11. The method according to claim 1, characterized in that: The correcting the initial object distance based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain the corrected object distance includes: Obtaining clarity evaluation values ​​corresponding to all detection frames in the current cycle; Summing the clarity evaluation values ​​of the first detection direction to obtain a first sum value, and summing the clarity evaluation values ​​of the second detection direction to obtain a second sum value; calculating a focus correction value based on the first sum value and the second sum value; Finding a lens curve corresponding to the initial object distance based on the initial object distance and the next position of the zoom motor to obtain the next position of the focus motor; Using the focus correction value to correct the next step position of the focus motor to obtain a corrected position of the focus motor; Based on the next step position of the zoom motor and the corrected position of the focus motor, the lens curves at each preset object distance are searched to obtain the corrected object distance.

12. The method according to claim 11, characterized in that The calculating the focus correction value based on the first sum value and the second sum value includes: The first intermediate result fvDiff is calculated based on the first sum value and the second sum value according to the following formula: fvDiff=(farSumFv-nearSumFv) / (MAX(nearSumFv, farSumFv) / Th); Among them, farSumFv is the first sum value, nearSumFv is the second sum value, and Th is the preset threshold; Based on the first intermediate result, the focus correction value focusDiff is calculated according to the following formula: focusDiff=(fvDiff×K1+fvDiff / 2×sig)×K2+AveProbeStep×K3×(1+sig); Among them, AveProbeStep is the average detection step size of the current cycle, sig is the second intermediate result, sig is calculated based on the difference between the clarity evaluation value of the first detection direction and the clarity evaluation value of the second detection direction, and K1, K2 and K3 are correction amplitude factors.

13. The method according to claim 1, characterized in that The magnification direction of the current cycle is from a small magnification to a large magnification.

14. The method according to claim 1, characterized in that The initial object distance is the object distance when the autofocus is completed, or the initial object distance is the corrected object distance of the previous cycle.

15. An object distance estimation device in variable magnification focusing, characterized in that: Applied to an image acquisition device, the device comprises: An initial object distance determination module, used to determine the initial object distance at the beginning of a current cycle; the current cycle includes a preset number of detection frames, and the detection direction of each detection frame includes a first detection direction or a second detection direction; A detection step length determination module, used to determine the detection step length corresponding to each detection frame in the current cycle; A detection module, configured to detect the position of a focus motor based on the initial object distance and in accordance with a detection direction and a detection step length of each detection frame, and obtain a clarity evaluation value corresponding to each detection frame; The object distance correction module is used to correct the initial object distance at the target frame of the current cycle based on the clarity evaluation values ​​corresponding to all detection frames in the current cycle to obtain a corrected object distance.