A zoom following method, system and device with automatic switching of focus curves
By acquiring and calibrating the focus curve, dynamically switching the zoom follow curve, and comparing the clarity in real time, the problem of synchronous movement of the focus motor and zoom motor during zooming was solved, thereby improving image stability and the accuracy of video tracking and monitoring.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-23
- Publication Date
- 2026-03-24
AI Technical Summary
Existing technologies cannot effectively solve the problem of synchronous movement of the focusing motor and zoom motor during zooming, resulting in decreased image clarity and poor image stability, which in particular affects the accuracy and stability of video tracking and monitoring in video surveillance.
By acquiring several focus curves, the focus position of the zoom motor is calibrated using an autofocus algorithm. The zoom follow curve is dynamically switched, and the sharpness comparison is adjusted in real time to determine the optimal focus curve and keep it within the adjacent range to avoid image blurring.
It improves image stability, enhances the accuracy and stability of video tracking and monitoring, avoids the blur-clarity-blur changes in the image, and adapts to dynamic adjustments when the target moves or disappears.
Smart Images

Figure CN117528249B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of video surveillance technology, specifically to a method, system, and device for automatically switching focus curves and following zoom levels. Background Technology
[0002] With the development of digitalization, networking, and high-definition in the video surveillance industry, integrated cameras with zoom tracking and autofocus functions are becoming increasingly widely used. Zoom tracking, in particular, adjusts the focus motor in real-time based on the lens tracking curve (also known as the focus curve, usually a curve with a certain curvature; lens manufacturers provide several basic focus curves for different object distances) during zooming to ensure image clarity throughout the zoom process. However, since most integrated cameras use separate control for the focus and zoom motors, and motors are mechanical components with inherent physical characteristics such as response time, acceleration, and reverse pause time, and both the focus and zoom motors can only move linearly, it is difficult to maintain synchronized movement of the focus and zoom motors during zooming. This causes the focus position to shift during zooming, affecting image clarity and resulting in loss of detail. While this may not be a significant issue for ordinary cameras, it is crucial to avoid image detail loss during zooming, especially in real-time video surveillance and other image acquisition applications.
[0003] Therefore, existing technologies employ a precise switching of focus curves during the zoom process of integrated cameras to ensure high-resolution images are captured when the switched focus curve is applied. Specifically, existing technologies first calibrate multiple focus curves (1m, 2m, 3m, 4m, 5m, 6m, 7m, 8m, 9m, 10m, 11m, 12m, 13m, 14m, 15m, 16m, 17m, 18m, 19m, 20m), then run all focus curves under the current zoom level, and select the focus curve with the highest resolution as the zoom-following reference curve based on the resolution under different focus curves in the current environment. The motor then moves smoothly according to this reference curve, ensuring that the image remains sharp within the depth of field during zooming in this environment. However, existing technologies still have the following technical problems:
[0004] 1. Running all the focus curves takes a lot of time, which leads to low efficiency in determining the zoom level to follow the reference curve;
[0005] 2. During the operation of all focus curves, the image will show obvious blur-clarity-blur changes, resulting in poor image stability and causing visual discomfort to the viewer, especially in cases of long-term monitoring or when frequent switching of focus curves is required.
[0006] 3. If the target moves or disappears during zooming, the camera cannot automatically switch to the focus curve required for the new target. The camera cannot adjust the focus in time, resulting in blurring or flickering of the moving target in the zoomed image, which reduces the accuracy and stability of video tracking and monitoring. Summary of the Invention
[0007] To address the aforementioned technical problems, this invention proposes a zoom following method, system, and device with automatic focus curve switching, aiming to directly find a suitable curve during zooming and dynamically adjust the curve as the target moves to adapt to changes in the target.
[0008] Therefore, the present invention adopts the following technical solution: a zoom following method for automatic switching of focus curves, comprising the following steps:
[0009] Step 102: Obtain several focusing curves;
[0010] Step 104: The focus position corresponding to the zoom motor point on the focus curve is calibrated by the autofocus algorithm to obtain the calibrated focus curve. The set of all the calibrated focus curves is recorded as the zoom follow curve and stored in the lens.
[0011] Step 106: During the zoom process, set the initial next switching direction of the zoom following curve to be from the near focal end to the far focal end, calculate the image sharpness obtained at the zoom motor point on the current zoom following curve, and record it as the first sharpness.
[0012] Step 108: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor point on the switched zoom follow curve, and record it as the second sharpness;
[0013] Step 110: Compare the first sharpness and the second sharpness, determine the next switching direction of the preferred focus curve and the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve.
[0014] Step 112: Repeat steps 108-110 until the doubling process is complete.
[0015] The focusing curve represents how the focal length of a lens changes at different object distances. Different lenses have different focusing curves, and lens manufacturers provide basic focusing curves for several object distances. The zoom process refers to the operation of the zoom motor and focusing motor according to a zoom follower curve in the set. The direction from the near focal end to the far focal end is the opposite direction to the optical device, that is, the direction of movement from the near end to the far end of the lens or objective lens. When the lens or objective lens is focused at the near focal end, it provides the closest distance to a sharp image, while when it is focused at the far focal end, it provides the farthest distance to a sharp image.
[0016] The technical concept of this invention is as follows: First, several focusing curves are obtained, i.e., the basic focusing curves of the lens at several object distances; second, the focusing position corresponding to the zoom motor point on one of the focusing curves, i.e., the focusing motor position, is calibrated using an autofocus algorithm to obtain a calibrated focusing curve. Similarly, other calibrated focusing curves are obtained. The set of all calibrated focusing curves is then recorded as the zoom following curve and bound to the lens. In subsequent zooming processes, the zoom following curve bound to the lens can be directly read for switching operations; next, during the zooming process, the initial next switching direction of the zoom following curve is set to from the near focal end to the far focal end. Follow-focusing is performed at the focusing position associated with the zoom motor point on the current zoom following curve, and the sharpness of the acquired image is calculated and recorded as the first sharpness; then, based on the initial next switching direction, the next zoom following curve is switched, and the image sharpness acquired at the zoom motor point on the switched zoom following curve is calculated and recorded as the second sharpness; then the first sharpness is... The image sharpness and the second sharpness are compared. Based on the comparison result, the preferred focus curve and the next switching direction of the zoom follow curve are determined, and the second sharpness is recorded as the first sharpness. That is, the zoom follow curve corresponding to the second sharpness at this time is used as the current zoom follow curve. The next switching direction is used to keep the next zoom follow curve within the range of the zoom follow curve adjacent to the preferred focus curve. Then, the next zoom follow curve is switched based on the next switching direction, and the image sharpness obtained at the zoom motor position on the switched zoom follow curve is calculated and recorded as the second sharpness. By continuously and dynamically switching the zoom follow curve, adjusting the next switching direction, and performing sharpness comparison in real time, the final switching can be achieved within the range of the zoom follow curve adjacent to the preferred focus curve. Moreover, when the target moves or disappears during the zoom process, due to the real-time sharpness comparison, the present invention can dynamically adjust the switching of the zoom follow curve and find the preferred focus curve required for the new target in a timely manner.
[0017] By continuously and dynamically switching the zoom-following curve, adjusting the next switching direction, and performing real-time sharpness comparisons, without having to run all the focus curves before determining the appropriate one, the system can quickly achieve switching within the range of the zoom-following curve adjacent to the preferred focus curve. This avoids obvious blur-sharp-blur changes in the image, significantly improving image stability. Furthermore, during zooming, when the target moves or disappears, the real-time sharpness comparisons allow for dynamic adjustment of the zoom-following curve switching when the target's movement or disappearance causes a sudden change in image sharpness, enabling the timely search for the preferred focus curve required for the new target. This, to a certain extent, improves the accuracy and stability of video tracking and monitoring.
[0018] Preferably, in step 110, the first sharpness and the second sharpness are compared, and the next switching direction of the preferred focus curve and the zoom follow curve is determined based on the comparison result. The second sharpness is recorded as the first sharpness. The next switching direction is used to keep the next zoom follow curve within the range of the zoom follow curve adjacent to the preferred focus curve, including:
[0019] The first sharpness and the second sharpness are compared. If the first sharpness is greater than the second sharpness, the zoom-following curve corresponding to the first sharpness is recorded as the preferred focus curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is recorded as the first sharpness. If the first sharpness is less than the second sharpness, the zoom-following curve corresponding to the second sharpness is recorded as the preferred focus curve, the current switching direction is kept as the next switching direction, and the second sharpness is recorded as the first sharpness.
[0020] Preferably, in step 104, the focus position corresponding to the zoom motor point on the focus curve is calibrated using an autofocus algorithm to obtain a calibrated focus curve. The set of all calibrated focus curves is recorded as the zoom following curve and stored in the lens, including:
[0021] The focusing position corresponding to the zoom motor point on the focusing curve is calibrated by using an autofocus algorithm to obtain the calibrated focusing curve.
[0022] The calibration focusing curve is subjected to curve fitting to obtain several fitted focusing curves;
[0023] The set of all the calibrated focus curves and the fitted focus curves is denoted as the zoom follow curve and stored in the lens.
[0024] Preferably, the step of calibrating the focus position corresponding to the zoom motor point on the focus curve using an autofocus algorithm to obtain the calibrated focus curve includes:
[0025] Step 302: Divide the focusing curve into several zoom motor positions, and run the zoom motor along the focusing curve;
[0026] Step 304: When the zoom motor runs to a zoom motor position, the autofocus algorithm is used to determine and record the focus position corresponding to the current zoom motor position, and the zoom motor continues to run along the focus curve.
[0027] Step 306: Repeat step 304 until the focus position corresponding to the last zoom motor point is recorded. Record the focus curve corresponding to the focus position of the zoom motor point as the calibration focus curve.
[0028] Preferably, in step 106, the calculation of the image sharpness obtained at the zoom motor position on the current zoom follow curve, denoted as the first sharpness, includes:
[0029] Run along the current zoom follow curve to several zoom motor points, and calculate the image sharpness at each zoom motor point.
[0030] Calculate the average sharpness of all acquired images and record the average as the first sharpness.
[0031] In step 108, the step of switching to the next zoom-following curve based on the next switching direction, and calculating the image sharpness obtained at the zoom motor position on the switched zoom-following curve, denoted as the second sharpness, includes:
[0032] Based on the next switching direction, switch to the next zoom follow curve, run along the switched zoom follow curve for several zoom motor positions, and calculate the image sharpness at each zoom motor position.
[0033] The average sharpness of all acquired images is calculated, and this average is recorded as the second sharpness.
[0034] Preferably, comparing the first sharpness and the second sharpness includes:
[0035] Set an offset value and calculate the sum of the second sharpness and the offset value;
[0036] The sum of the first sharpness and the second sharpness is compared with the offset value.
[0037] A zoom-following system with automatic focus curve switching includes:
[0038] The focus curve acquisition module is used to acquire several focus curves;
[0039] The focus curve calibration module is used to calibrate the focus position corresponding to the zoom motor point on the focus curve through an autofocus algorithm, obtain the calibration focus curve, and record the set of all the calibration focus curves as the zoom follow curve and store it in the lens.
[0040] The initial first sharpness calculation module is used to set the initial next switching direction of the zoom follow curve to be from the near focal end to the far focal end during the zoom process, and calculate the image sharpness obtained at the zoom motor point on the current zoom follow curve, which is recorded as the first sharpness.
[0041] The zoom-following curve switching module is used to perform the following steps:
[0042] Step 402: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor position on the switched zoom follow curve, and record it as the second sharpness;
[0043] Step 404: Compare the first sharpness and the second sharpness, determine the next switching direction of the preferred focus curve and the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve.
[0044] Step 406: Repeat steps 402-404 until the doubling process is complete.
[0045] Preferably, in the zoom-following curve switching module, the first sharpness and the second sharpness are compared, and a preferred focus curve and the next switching direction of the zoom-following curve are determined based on the comparison result. The second sharpness is recorded as the first sharpness. The next switching direction is used to keep the next zoom-following curve within the range of the zoom-following curve adjacent to the preferred focus curve. Specifically:
[0046] The first resolution and the second resolution are compared. If the first resolution is greater than the second resolution, the zoom following curve corresponding to the first resolution is recorded as the preferred zoom following curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second resolution is recorded as the first resolution. If the first resolution is less than the second resolution, the zoom following curve corresponding to the second resolution is recorded as the preferred zoom following curve, the current switching direction is kept as the next switching direction, and the second resolution is recorded as the first resolution.
[0047] An electronic device, including a processor and a memory;
[0048] The processor is connected to the memory;
[0049] The memory is used to store executable program code;
[0050] The processor runs a program corresponding to the executable program code stored in the memory to execute a zoom-following method for automatic focus curve switching, as described above.
[0051] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a zoom-following method for automatic switching of focus curves as described above.
[0052] The beneficial technical effects of this invention include at least the following: It employs a zoom-following method, system, and device with automatic focus curve switching. By continuously and dynamically switching the zoom-following curve, adjusting the next switching direction, and performing real-time sharpness comparison, it eliminates the need to run all focus curves before determining a suitable curve. This allows for rapid switching within the range of zoom-following curves adjacent to the preferred focus curve, thus avoiding significant blur-sharp-blur changes in the image and greatly improving image stability. Furthermore, during zooming, when the target moves or disappears, the real-time sharpness comparison enables dynamic adjustment of the zoom-following curve switching and timely search for the preferred focus curve required for the new target when the target's movement or disappearance causes a sudden change in image sharpness. This, to a certain extent, improves the accuracy and stability of video tracking and monitoring.
[0053] Other features and advantages of the present invention will be disclosed in detail in the following detailed description and accompanying drawings. Attached Figure Description
[0054] The invention will be further described below with reference to the accompanying drawings:
[0055] Figure 1 This is a flowchart of the zoom-following method for automatic switching of focus curves according to an embodiment of the present invention.
[0056] Figure 2 This is a schematic diagram illustrating the zoom-following principle of automatic focus curve switching in an embodiment of the present invention.
[0057] Figure 3 This is a flowchart illustrating the method for obtaining the calibration focus curve according to an embodiment of the present invention.
[0058] Figure 4 This is a schematic diagram of the zoom-following system for automatic switching of focus curves according to an embodiment of the present invention.
[0059] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present invention. Detailed Implementation
[0060] The technical solutions of the embodiments of the present invention will be explained and described below with reference to the accompanying drawings. However, the following embodiments are only preferred embodiments of the present invention and not all of them. Other embodiments obtained by those skilled in the art based on the embodiments in the implementation methods without creative effort are all within the protection scope of the present invention.
[0061] In the following description, terms such as “inner,” “outer,” “upper,” “lower,” “left,” and “right” are used only to indicate orientation or positional relationship for the convenience of describing the embodiments and simplifying the description, and are not intended to indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the present invention.
[0062] This application provides a zoom-following method for automatic focus curve switching, please refer to the appendix. Figure 1 This includes the following steps:
[0063] Step 102: Obtain several focusing curves.
[0064] The focus curve represents how the focal length of the lens changes at different object distances. Different lenses have different focus curves, and lens manufacturers will provide the basic focus curves of the lens at several object distances.
[0065] Step 104: The focus position corresponding to the zoom motor point on the focus curve is calibrated by the autofocus algorithm to obtain the calibrated focus curve. The set of all calibrated focus curves is recorded as the zoom follow curve and stored in the lens.
[0066] The focusing position refers to the position of the focusing motor. Autofocus algorithms include, but are not limited to, the following:
[0067] 1. Hill Climbing: This algorithm uses image sharpness as the objective function. Based on changes in image sharpness, it adjusts the position of the focusing motor corresponding to the zoom motor point on the focusing curve. The algorithm continuously tries different focusing positions, calculates image sharpness, and decides whether to move towards a sharper direction or stop moving based on changes in sharpness. Through iterative processes, hill climbing can find a locally optimal focusing position that maximizes image sharpness or reaches a preset threshold.
[0068] 2. Contrast-based method: This algorithm determines the quality of the focus position by measuring the contrast of the image. Images are acquired at different focal length positions, the contrast of the images is calculated, and the position with the highest contrast is selected as the focus position.
[0069] 3. Phase detection: This algorithm uses phase difference for focus detection. The phase detection algorithm uses a phase difference sensor in the lens to measure the phase difference of light rays from different directions, thereby determining the focus position.
[0070] 4. Depth-based method: This algorithm uses depth sensors or image depth information for focus detection. It determines the focus position by measuring the distance to different objects.
[0071] 5. Edge-based detection: This algorithm determines the focus position by detecting edge information in an image. Edge detection algorithms can find edge features in an image by calculating image gradients and detecting edge contours, thereby determining the focus position.
[0072] It is understood that in this embodiment, the focusing position corresponding to the zoom motor point on the focusing curve is calibrated by the autofocus algorithm to obtain the calibrated focusing curve. Although it is only a calibration method for one focusing curve, the calibration methods for other focusing curves can be referred to this calibration method to obtain all the calibrated focusing curves. Therefore, this embodiment will not elaborate further here.
[0073] Understandably, calibrating the focus position corresponding to the zoom motor point on the focus curve is a program independent of the zoom process. After calibration, the set of all calibrated focus curves is recorded as the zoom follow curve, and these zoom follow curve data are saved in a file and bound to the lens. Subsequently, each time the lens's main program executes the zoom process, it will read the stored zoom follow curve data to run the zoom motor and focus motor and perform the zoom follow curve switching operation.
[0074] Step 106: During the zoom process, set the initial next switching direction of the zoom following curve to be from the near focal end to the far focal end, calculate the image sharpness obtained at the zoom motor point on the current zoom following curve, and record it as the first sharpness.
[0075] The zoom process refers to the operation of the zoom motor and focus motor according to a zoom follower curve in the set. The direction from the near focal end to the far focal end is the opposite direction to the optical device, that is, the direction of movement from the near end of the lens or objective lens to the far end. When the lens or objective lens is focused at the near focal end, it can provide the closest distance to a sharp image, while when the lens or objective lens is focused at the far focal end, it can provide the farthest distance to a sharp image.
[0076] Step 108: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor position on the switched zoom follow curve, and record it as the second sharpness.
[0077] The calculation methods for image sharpness at zoom motor points on the current zoom-following curve and at zoom motor points on the switched zoom-following curve are similar to the existing methods for calculating image sharpness. Therefore, this embodiment will not elaborate further.
[0078] Step 110: Compare the first sharpness and the second sharpness, determine the preferred focus curve and the next switching direction of the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve.
[0079] It is understandable that recording the second sharpness as the first sharpness means taking the zoom-following curve corresponding to the second sharpness as the current zoom-following curve, so that the subsequent execution of step 108, "switching to the next zoom-following curve based on the next switching direction, calculating the image sharpness obtained by the zoom motor position on the switched zoom-following curve, and recording it as the second sharpness", continuously and dynamically switching the zoom-following curve, adjusting the next switching direction, and performing sharpness comparison in real time.
[0080] It is understandable that keeping the next zoom follower curve within the range of the zoom follower curves adjacent to the preferred focus curve means that the next zoom follower curve is either one of the two zoom follower curves adjacent to the preferred focus curve, or the zoom follower curve corresponding to the preferred focus curve.
[0081] Step 112: Repeat steps 108-110 until the doubling process is complete.
[0082] The technical concept of this embodiment is as follows: First, several focus curves are obtained, namely, the basic focus curves of the lens at several object distances; second, the focus position corresponding to the zoom motor point on one of the focus curves is calibrated using an autofocus algorithm to obtain a calibrated focus curve, and the other calibrated focus curves are obtained similarly. Then, the set of all calibrated focus curves is recorded as the zoom following curve and bound to the lens; next, during the zoom process, the initial next switching direction of the zoom following curve is set to from the near focal end to the far focal end, and follow-focusing is performed at the focus position associated with the zoom motor point on the current zoom following curve, and the sharpness of the acquired image is calculated and recorded as the first sharpness; then, the next zoom following curve is switched based on the initial next switching direction. The image sharpness acquired at the zoom motor point on the zoom-following curve after switching is calculated and recorded as the second sharpness. The first and second sharpnesses are then compared, and based on the comparison result, the preferred focus curve and the next switching direction of the zoom-following curve are determined. The second sharpness is recorded as the first sharpness, and the zoom-following curve corresponding to the second sharpness at this point is taken as the current zoom-following curve. The next switching direction is used to keep the next zoom-following curve within the range of the zoom-following curve adjacent to the preferred focus curve. Next, based on the next switching direction, the next zoom-following curve is switched, and the image sharpness acquired at the zoom motor point on the switched zoom-following curve is calculated and recorded as the second sharpness… until the zooming process ends. By continuously and dynamically switching the zoom-following curve, adjusting the next switching direction, and performing real-time sharpness comparison, the final switching within the range of the zoom-following curve adjacent to the preferred focus curve can be quickly achieved. Moreover, during the zooming process, when the target moves or disappears, due to the real-time sharpness comparison, this embodiment can dynamically adjust the switching of the zoom-following curve and promptly find the preferred focus curve required for the new target.
[0083] By continuously and dynamically switching the zoom-following curve, adjusting the next switching direction, and performing real-time sharpness comparisons, without having to run all the focus curves before determining the appropriate one, the system can quickly achieve switching within the range of the zoom-following curve adjacent to the preferred focus curve. This avoids obvious blur-sharp-blur changes in the image, significantly improving image stability. Furthermore, during zooming, when the target moves or disappears, the real-time sharpness comparisons allow for dynamic adjustment of the zoom-following curve switching when the target's movement or disappearance causes a sudden change in image sharpness, enabling the timely search for the preferred focus curve required for the new target. This, to a certain extent, improves the accuracy and stability of video tracking and monitoring.
[0084] In one embodiment of this specification, step 110 involves comparing a first sharpness and a second sharpness, determining a preferred focus curve and a next switching direction for the zoom-following curve based on the comparison result, and recording the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom-following curve within the range of a zoom-following curve adjacent to the preferred focus curve, including:
[0085] The first sharpness and the second sharpness are compared. If the first sharpness is greater than the second sharpness, the zoom-following curve corresponding to the first sharpness is recorded as the preferred focus curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is recorded as the first sharpness. If the first sharpness is less than the second sharpness, the zoom-following curve corresponding to the second sharpness is recorded as the preferred focus curve, the current switching direction is kept as the next switching direction, and the second sharpness is recorded as the first sharpness.
[0086] For example, please refer to the appendix. Figure 2 Taking a target object 3m away from the lens and the lens storing four zoom-following curves corresponding to object distances of 1m, 2m, 3m, and 4m respectively as an example, with the horizontal axis representing the zoom motor position and the vertical axis representing the focus motor position, the specific implementation of the zoom-following method with automatic focus curve switching proposed in this embodiment is as follows:
[0087] During zooming, the initial next switching direction of the zoom follower curve is set from the near focal length to the far focal length. The current zoom follower curve is the zoom follower curve corresponding to an object distance of 1m. The focus position associated with the zoom motor position on the current zoom follower curve (i.e., the attached focus position) is... Figure 2 Point 1) is used for follow-focusing, and the sharpness of the acquired image is calculated and recorded as the first sharpness; then, based on the initial next switching direction, the next zoom follow curve is switched to the zoom follow curve corresponding to a 2m object distance, and the zoom motor position on the 2m object distance zoom follow curve (i.e., the attached point) is calculated. Figure 2 The image sharpness obtained at point 2) is denoted as the second sharpness. The first and second sharpness are then compared. Since the target object is 3m from the lens, it can be understood that the first sharpness is less than the second sharpness. Therefore, the zoom-following curve corresponding to the second sharpness at a 2m object distance is designated as the preferred focus curve. The current switching direction is maintained as the next switching direction, and the second sharpness is designated as the first sharpness. Next, based on the next switching direction, the next zoom-following curve is switched to the zoom-following curve corresponding to a 3m object distance. The zoom motor position on the 3m object distance zoom-following curve (i.e., the attached image) is calculated. Figure 2The image sharpness obtained at point 3) is denoted as the second sharpness. The first sharpness and the second sharpness are then compared. If the first sharpness is less than the second sharpness, the zoom-following curve corresponding to the second sharpness at a 3m object distance is designated as the preferred focus curve. The current switching direction is maintained as the next switching direction, and the second sharpness is designated as the first sharpness. Next, based on the next switching direction, the next zoom-following curve is switched to the zoom-following curve corresponding to a 4m object distance. The zoom motor position (i.e., the attached image) on the 4m object distance zoom-following curve is calculated. Figure 2 The image sharpness obtained at point 4) is denoted as the second sharpness. The first and second sharpnesses are then compared. Since the target object is 3m from the lens, it can be understood that the first sharpness is greater than the second sharpness. Therefore, the zoom-following curve corresponding to the first sharpness at a 3m distance is designated as the preferred focus curve. The opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is designated as the first sharpness. Next, based on the next switching direction, the next zoom-following curve is switched to the zoom-following curve corresponding to a 3m distance. The zoom motor position on the 3m distance zoom-following curve (i.e., the attached image) is calculated. Figure 2 The image sharpness obtained at point 5 is recorded as the second sharpness. The first sharpness and the second sharpness are then compared. If the first sharpness is less than the second sharpness, the zoom-following curve corresponding to the second sharpness at a 3m object distance is recorded as the preferred focus curve. The current switching direction is kept as the next switching direction, and the second sharpness is recorded as the first sharpness. Next, based on the next switching direction, the next zoom-following curve is switched to the zoom-following curve corresponding to a 2m object distance. The zoom motor position (i.e., the attached image) on the zoom-following curve at a 2m object distance is calculated. Figure 2 The image sharpness obtained at point 6) is recorded as the second sharpness. The first and second sharpnesses are then compared. Since the target object is 3m from the lens, it can be understood that the first sharpness is greater than the second sharpness. Therefore, the zoom-following curve corresponding to the first sharpness at a 3m object distance is recorded as the preferred focus curve. The opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is recorded as the first sharpness... until the zoom process ends. For the remaining curve switching process, please refer to the appendix. Figure 2 Points 7, 8, 9, 10, 11, 12, and 13 in this embodiment will not be described again here.
[0088] As can be seen, the zoom-following method with automatic focus curve switching proposed in this embodiment continuously and dynamically switches the zoom-following curve, adjusts the next switching direction, and performs real-time sharpness comparison. During the third sharpness comparison, the optimal focus curve is found, and the switching continues within the range of zoom-following curves adjacent to the optimal focus curve, provided the target does not move during zooming. Compared to existing technologies that run all focus curves before determining a suitable curve, this method not only improves the efficiency of determining the optimal focus curve but also avoids significant blur-sharp-blur changes in the image, greatly improving image stability. Furthermore, during zooming, when the target moves or disappears, the real-time sharpness comparison allows for dynamic adjustment of the zoom-following curve switching when the target's movement or disappearance causes a sudden change in image sharpness. This enables timely finding of the optimal focus curve required for the new target and ultimately switching within the range of zoom-following curves adjacent to the optimal focus curve, thus improving the accuracy and stability of video tracking and monitoring to a certain extent.
[0089] In one embodiment of this specification, step 104 involves calibrating the focus position corresponding to the zoom motor point on the focus curve using an autofocus algorithm to obtain a calibrated focus curve. The set of all calibrated focus curves is then recorded as the zoom following curve and stored in the lens, including:
[0090] The focusing position corresponding to the zoom motor point on the focusing curve is calibrated by using an autofocus algorithm to obtain the calibrated focusing curve.
[0091] Curve fitting is performed on the calibration focusing curve to obtain several fitted focusing curves;
[0092] The set of all calibrated focus curves and the fitted focus curves is recorded as the zoom follow curve and stored in the lens.
[0093] In this embodiment, the methods for performing curve fitting on the calibration focusing curve to obtain several fitted focusing curves include, but are not limited to, the following:
[0094] 1. Interpolation Fitting Method: The interpolation fitting method constructs a fitted curve by interpolating between a known set of data points to approximate the shape of the focusing curve. It builds a continuous curve based on known data points in the calibrated focusing curve to represent its shape. The fitted curve can be a smooth curve or a polynomial curve, depending on the fitting accuracy and practical requirements.
[0095] 2. Least Squares Method: The least squares method selects the optimal curve parameters by minimizing the sum of squared errors between the fitted curve and the actual data.
[0096] 3. Gaussian Fitting Method: This method uses a Gaussian function to fit the focusing curve. The Gaussian function has good fitting performance and mathematical expression ability, and can accurately describe the shape of the focusing curve.
[0097] 4. Polynomial Fitting Method: This method uses polynomial functions to fit the focusing curve. Polynomial functions can adapt to different curve shapes by increasing the polynomial order, but excessively high orders may lead to overfitting.
[0098] 5. Spline interpolation: This method uses spline interpolation to fit the focused curve. Spline interpolation can approximate the actual curve using piecewise polynomials, resulting in good smoothness and fitting performance.
[0099] In this case, if multiple focus curves are fitted from the calibration focus curve using curve fitting, it is usually not necessary to calibrate the focus positions corresponding to the zoom motor points on the fitted focus curves. This is because the calibration focus curve already provides the relationship between the zoom motor points and focus positions at different focal lengths, and the fitted curves are modeled based on these known relationships. Although the fitted focus curves usually do not require additional calibration, some adjustments and optimizations may be needed in practical applications to achieve the best autofocus performance.
[0100] Since the number of calibrated focus curves is relatively small, directly switching curves based on the calibrated focus curves may cause abrupt changes in the image, which may cause visual discomfort to the viewer. Therefore, this embodiment performs curve fitting on the calibrated focus curves to obtain more focus curves. The set of all calibrated focus curves and the fitted focus curves is then recorded as the zoom following curve for subsequent curve switching, making the image smoother when switching curves and further improving the stability of the image.
[0101] In one embodiment of this specification, please refer to the appendix. Figure 3 The focusing position corresponding to the zoom motor point on the focusing curve is calibrated using an autofocus algorithm to obtain the calibrated focusing curve, including:
[0102] Step 302: Divide the focusing curve into several zoom motor positions and run the zoom motor along the focusing curve;
[0103] Step 304: When the zoom motor runs to a zoom motor position, the autofocus algorithm is used to determine the focus position corresponding to the current zoom motor position and record it, and the zoom motor continues to run along the focus curve.
[0104] Step 306: Repeat step 304 until the focus position corresponding to the last zoom motor point is recorded. Record the focus curve corresponding to the focus position of the zoom motor point as the calibration focus curve.
[0105] In one embodiment of this specification, step 106 involves calculating the image sharpness at the zoom motor position on the current zoom tracking curve, denoted as the first sharpness, including:
[0106] Run along the current zoom follow curve to several zoom motor points, and calculate the image sharpness at each zoom motor point.
[0107] Calculate the average sharpness of all acquired images and record the average as the first sharpness.
[0108] In step 108, based on the next switching direction, the next zoom-following curve is switched, and the image sharpness obtained at the zoom motor position on the switched zoom-following curve is calculated and denoted as the second sharpness, including:
[0109] Based on the next switching direction, switch to the next zoom follow curve, run along the switched zoom follow curve for several zoom motor positions, and calculate the image sharpness at each zoom motor position.
[0110] The average sharpness of all acquired images is calculated, and this average is recorded as the second sharpness.
[0111] Preferably, the more zoom motor points that run along the zoom-following curve, the longer it takes to calculate the image sharpness at each zoom motor point and average it, thus slowing down the curve switching speed. However, fewer zoom motor points that run along the zoom-following curve may also result in insufficient image sharpness accuracy. Therefore, this embodiment preferably uses three zoom motor points that run along the zoom-following curve and calculates the average image sharpness at the three zoom motor points. This ensures the efficiency of determining the preferred focus curve while improving the accuracy of the acquired image sharpness, thereby improving the accuracy of curve switching to a certain extent.
[0112] In one embodiment of this specification, comparing a first sharpness and a second sharpness includes:
[0113] Set the offset value and calculate the sum of the second sharpness and the offset value;
[0114] Compare the first and second sharpness values with the sum of the offset values.
[0115] The specific offset value can be set according to the zoom level of the actual lens.
[0116] It is understood that the technical solution provided in this embodiment can be applied to the appendix. Figure 2 In the corresponding embodiment, the sum of the first sharpness, the second sharpness, and the offset value is compared. If the first sharpness is greater than the sum of the second sharpness and the offset value, the zoom-following curve corresponding to the first sharpness is recorded as the preferred focus curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is recorded as the first sharpness. If the first sharpness is less than the sum of the second sharpness and the offset value, the zoom-following curve corresponding to the second sharpness is recorded as the preferred focus curve, the current switching direction is kept as the next switching direction, and the second sharpness is recorded as the first sharpness.
[0117] In the actual process of the zoom motor and focus motor running along the zoom follow curve, the larger the zoom ratio, the less the image contains, and therefore the smaller the obtained image sharpness value. Therefore, in this embodiment, when judging the first sharpness and the second sharpness, an offset value is added according to the change in sharpness. The first sharpness and the second sharpness are compared with the sum of the offset value, and the judgment rule is appropriately adjusted to adapt to different magnifications, so as to judge the image sharpness more accurately.
[0118] An embodiment of this specification also provides a zoom-following system with automatic focus curve switching, similar in concept to the aforementioned zoom-following method with automatic focus curve switching. Please refer to the appendix. Figure 4 ,include:
[0119] Focus curve acquisition module 1 is used to acquire several focus curves;
[0120] The focus curve calibration module 2 is used to calibrate the focus position corresponding to the zoom motor position on the focus curve through the autofocus algorithm, obtain the calibration focus curve, and record the set of all calibration focus curves as the zoom follow curve and store it in the lens.
[0121] The initial first sharpness calculation module 3 is used to set the initial next switching direction of the zoom follow curve to be from the near focal end to the far focal end during the zoom process, and calculate the image sharpness obtained at the zoom motor point on the current zoom follow curve, which is recorded as the first sharpness.
[0122] The zoom-following curve switching module 4 is used to perform the following steps:
[0123] Step 402: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor position on the switched zoom follow curve, and record it as the second sharpness;
[0124] Step 404: Compare the first sharpness and the second sharpness, determine the preferred focus curve and the next switching direction of the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve.
[0125] Step 406: Repeat steps 402-404 until the doubling process is complete.
[0126] In one embodiment of this specification, in the zoom-following curve switching module 4, a first sharpness and a second sharpness are compared, and a preferred focus curve and the next switching direction of the zoom-following curve are determined based on the comparison result. The second sharpness is recorded as the first sharpness, and the next switching direction is used to keep the next zoom-following curve being switched within the range of the zoom-following curve adjacent to the preferred focus curve. Specifically:
[0127] The first resolution and the second resolution are compared. If the first resolution is greater than the second resolution, the zoom following curve corresponding to the first resolution is recorded as the preferred zoom following curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second resolution is recorded as the first resolution. If the first resolution is less than the second resolution, the zoom following curve corresponding to the second resolution is recorded as the preferred zoom following curve, the current switching direction is kept as the next switching direction, and the second resolution is recorded as the first resolution.
[0128] One embodiment of this specification also provides an electronic device; please refer to the appendix. Figure 5 This includes a processor 501 and a memory 505;
[0129] Processor 501 is connected to memory 505;
[0130] Memory 505 is used to store executable program code;
[0131] The processor 501 reads the executable program code stored in the memory 505 to run the program corresponding to the executable program code, so as to execute a zoom following method for automatic switching of focus curves as described above.
[0132] As attached Figure 5 As shown, the electronic device 500 may include at least one processor 501, at least one network interface 504, a user interface 503, a memory 505, and at least one communication bus 502.
[0133] The communication bus 502 can be used to realize the connection and communication of the above components.
[0134] The user interface 503 may include buttons, and the optional user interface may also include a standard wired interface or a wireless interface.
[0135] The network interface 504 may include, but is not limited to, Bluetooth modules, NFC modules, Wi-Fi modules, etc.
[0136] The processor 501 may include one or more processing cores. The processor 501 connects to various parts within the electronic device 500 using various interfaces and lines. It executes various functions and processes data by running or executing instructions, programs, code sets, or instruction sets stored in the memory 505, and by calling data stored in the memory 505. Optionally, the processor 501 may be implemented using at least one hardware form of DSP, FPGA, or PLA. The processor 501 may integrate one or more of the following: CPU, GPU, and modem. The CPU primarily handles the operating system, user interface, and applications; the GPU is responsible for rendering and drawing the content required for display; and the modem handles wireless communication. It is understood that the modem may also not be integrated into the processor 501 and may be implemented as a separate chip.
[0137] The memory 505 may include RAM or ROM. Optionally, the memory 505 may include a non-transitory computer-readable medium. The memory 505 may be used to store instructions, programs, code, code sets, or instruction sets. The memory 505 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch function, sound playback function, image playback function, etc.), instructions for implementing the above-described method embodiments, etc.; the data storage area may store data involved in the above-described method embodiments, etc. Optionally, the memory 505 may also be at least one storage device located remotely from the aforementioned processor 501. As a computer storage medium, the memory 505 may include an operating system, a network communication module, a user interface module, and a zoom-following application for automatic focus curve switching.
[0138] One embodiment of this specification also provides a computer-readable storage medium storing a computer program that, when executed by processor 501, implements a zoom-following method for automatic focus curve switching as described above. If the various components of the aforementioned electronic device are implemented as software functional units and sold or used as independent products, they can be stored in the computer-readable storage medium.
[0139] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this specification are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in or transmitted through a computer-readable storage medium. The computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, Digital Subscriber Line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device such as a server or data center that integrates one or more available media. The available media may be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., Digital Versatile Discs (DVDs)), or semiconductor media (e.g., Solid State Disks (SSDs)).
[0140] The above description is merely a preferred embodiment disclosed in this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of protection involved in this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-disclosed concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0141] Furthermore, while the operations are described in a specific order, this should not be construed as requiring these operations to be performed in the specific order shown or in a sequential order. In certain environments, multitasking and parallel processing may be advantageous. Similarly, while several specific implementation details are included in the above discussion, these should not be construed as limiting the scope of this disclosure. Certain features described in the context of individual embodiments may also be implemented in combination in a single embodiment. Conversely, various features described in the context of a single embodiment may also be implemented individually or in any suitable sub-combination in multiple embodiments.
Claims
1. A zoom-following method for automatic switching of focus curves, characterized in that, Includes the following steps: Step 102: Obtain several focusing curves; Step 104: The focus position corresponding to the zoom motor point on the focus curve is calibrated by the autofocus algorithm to obtain the calibrated focus curve. The set of all the calibrated focus curves is recorded as the zoom follow curve and stored in the lens. Step 106: During the zoom process, set the initial next switching direction of the zoom following curve to be from the near focal end to the far focal end, calculate the image sharpness obtained at the zoom motor point on the current zoom following curve, and record it as the first sharpness. Step 108: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor point on the switched zoom follow curve, and record it as the second sharpness; Step 110: Compare the first sharpness and the second sharpness, determine the next switching direction of the preferred focus curve and the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve. Step 112: Repeat steps 108-110 until the doubling process is complete; The comparison between the first sharpness and the second sharpness includes: Set an offset value and calculate the sum of the second sharpness and the offset value; The sum of the first sharpness and the second sharpness is compared with the offset value.
2. The zoom-following method for automatic switching of focus curves as described in claim 1, characterized in that, Step 110: Compare the first sharpness and the second sharpness, determine the preferred focus curve and the next switching direction of the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve within the range of the zoom follow curve adjacent to the preferred focus curve, including: The first sharpness and the second sharpness are compared. If the first sharpness is greater than the second sharpness, the zoom-following curve corresponding to the first sharpness is recorded as the preferred focus curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second sharpness is recorded as the first sharpness. If the first sharpness is less than the second sharpness, the zoom-following curve corresponding to the second sharpness is recorded as the preferred focus curve, the current switching direction is kept as the next switching direction, and the second sharpness is recorded as the first sharpness.
3. A zoom-following method for automatic switching of focus curves as described in any one of claims 1 or 2, characterized in that, Step 104: The focus position corresponding to the zoom motor point on the focus curve is calibrated using an autofocus algorithm to obtain a calibrated focus curve. The set of all calibrated focus curves is recorded as the zoom following curve and stored in the lens, including: The focusing position corresponding to the zoom motor point on the focusing curve is calibrated by using an autofocus algorithm to obtain the calibrated focusing curve. The calibration focusing curve is subjected to curve fitting to obtain several fitted focusing curves; The set of all the calibrated focus curves and the fitted focus curves is denoted as the zoom follow curve and stored in the lens.
4. The zoom-following method for automatic switching of focus curves as described in claim 3, characterized in that, The step of calibrating the focus position corresponding to the zoom motor point on the focus curve using an autofocus algorithm to obtain the calibrated focus curve includes: Step 302: Divide the focusing curve into several zoom motor positions, and run the zoom motor along the focusing curve; Step 304: When the zoom motor runs to a zoom motor position, the autofocus algorithm is used to determine and record the focus position corresponding to the current zoom motor position, and the zoom motor continues to run along the focus curve. Step 306: Repeat step 304 until the focus position corresponding to the last zoom motor point is recorded. Record the focus curve corresponding to the focus position of the zoom motor point as the calibration focus curve.
5. A zoom-following method for automatic focus curve switching as described in any one of claims 1 or 2, characterized in that, In step 106, the calculation of the image sharpness obtained at the zoom motor position on the current zoom tracking curve, denoted as the first sharpness, includes: Run along the current zoom follow curve to several zoom motor points, and calculate the image sharpness at each zoom motor point. Calculate the average sharpness of all acquired images and record the average as the first sharpness. In step 108, the step of switching to the next zoom-following curve based on the next switching direction, and calculating the image sharpness obtained at the zoom motor position on the switched zoom-following curve, denoted as the second sharpness, includes: Based on the next switching direction, switch to the next zoom follow curve, run along the switched zoom follow curve for several zoom motor positions, and calculate the image sharpness at each zoom motor position. The average sharpness of all acquired images is calculated, and this average is recorded as the second sharpness.
6. A zoom-following system with automatic focus curve switching, characterized in that, include: The focus curve acquisition module is used to acquire several focus curves; The focus curve calibration module is used to calibrate the focus position corresponding to the zoom motor point on the focus curve through an autofocus algorithm, obtain the calibration focus curve, and record the set of all the calibration focus curves as the zoom follow curve and store it in the lens. The initial first sharpness calculation module is used to set the initial next switching direction of the zoom follow curve to be from the near focal end to the far focal end during the zoom process, and calculate the image sharpness obtained at the zoom motor point on the current zoom follow curve, which is recorded as the first sharpness. The zoom-following curve switching module is used to perform the following steps: Step 402: Based on the next switching direction, switch to the next zoom follow curve, calculate the image sharpness obtained at the zoom motor position on the switched zoom follow curve, and record it as the second sharpness; Step 404: Compare the first sharpness and the second sharpness, determine the next switching direction of the preferred focus curve and the zoom follow curve based on the comparison result, and record the second sharpness as the first sharpness. The next switching direction is used to keep the next zoom follow curve in the range of the zoom follow curve adjacent to the preferred focus curve. Step 406: Repeat steps 402-404 until the doubling process is complete; The comparison between the first sharpness and the second sharpness includes: Set an offset value and calculate the sum of the second sharpness and the offset value; The sum of the first sharpness and the second sharpness is compared with the offset value.
7. The zoom-following system with automatic focus curve switching as described in claim 6, characterized in that, In the zoom-following curve switching module, the first sharpness and the second sharpness are compared, and the preferred focus curve and the next switching direction of the zoom-following curve are determined based on the comparison result. The second sharpness is recorded as the first sharpness. The next switching direction is used to keep the next zoom-following curve within the range of the zoom-following curve adjacent to the preferred focus curve. Specifically: The first resolution and the second resolution are compared. If the first resolution is greater than the second resolution, the zoom following curve corresponding to the first resolution is recorded as the preferred zoom following curve, the opposite direction of the current switching direction is taken as the next switching direction, and the second resolution is recorded as the first resolution. If the first resolution is less than the second resolution, the zoom following curve corresponding to the second resolution is recorded as the preferred zoom following curve, the current switching direction is kept as the next switching direction, and the second resolution is recorded as the first resolution.
8. An electronic device, characterized in that, Including the processor and memory; The processor is connected to the memory; The memory is used to store executable program code; The processor runs a program corresponding to the executable program code stored in the memory to execute a zoom-following method for automatic switching of focus curves as described in any one of claims 1 to 5.
9. A computer-readable storage medium, characterized in that, It stores a computer program that, when executed by a processor, implements a zoom-following method for automatic switching of focus curves as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Method for synchronizing focusing operation and zooming operation
CN103728813A
Imaging device, method for controlling imaging device, and control program for imaging device
CN111133355A
Zoom lens zoom following method
CN116027514A