Focusing method, electronic equipment and computer readable storage medium
By acquiring and clustering the sharpness evaluation values of the focus points in the camera, and adjusting the focus motor to adapt to different scenes, the problem of low focusing efficiency of the camera after scene switching is solved, and fast and clear imaging is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2025-12-09
- Publication Date
- 2026-04-21
AI Technical Summary
Existing cameras struggle to adapt to changes in target objects in different scenes after scene switching, resulting in low focusing efficiency.
By acquiring the image block sharpness evaluation values at multiple focal points during the camera's focusing process, the focal points matching the evaluation peak are determined. Based on the distribution of these points, clustering is performed to obtain the point step size interval and reference focal points. The focusing motor is then adjusted to adapt to the current scene.
It enables rapid and effective clear imaging of target objects in different scenarios, improving focusing adaptability and efficiency.
Smart Images

Figure CN121908131A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of camera focusing technology, and in particular to a focusing method, electronic device, and computer-readable storage medium. Background Technology
[0002] The focusing effect of a camera directly affects the imaging quality of objects within a scene. With the widespread use of cameras, camera focusing has become an important research topic. Conventional focusing methods can pre-calibrate targets in different areas within a single scene, thus enabling focusing on the targets within that scene. However, they struggle to adaptively adapt to changes in targets under different scenes and cannot efficiently image targets according to requirements. Therefore, improving the adaptability and efficiency of focusing for different scenes has become an urgent problem to be solved. Summary of the Invention
[0003] The main technical problem addressed by this application is to provide a focusing method, electronic device, and computer-readable storage medium that can improve the adaptability and focusing efficiency for different scenarios.
[0004] To address the aforementioned technical problems, a first aspect of this application provides a focusing method, comprising: acquiring multiple focal points of a focusing motor of a camera during the focusing process, and a sharpness evaluation value of each image block in an image acquired at each focal point; determining an evaluation peak value corresponding to the sharpness evaluation value of each image block and a focal point matching the evaluation peak value; clustering the focal points matching the evaluation peak value based on the distribution of the focal points matching the evaluation peak value to obtain multiple point step size intervals and a reference focal point matching each point step size interval; acquiring a target step size interval selected for the camera from all the point step size intervals; and adjusting the focusing motor based on the reference focal point matching the target step size interval.
[0005] To address the aforementioned technical problems, a second aspect of this application provides an electronic device comprising: a memory and a processor coupled to each other, wherein the memory stores program data, and the processor invokes the program data to execute the method described in the first aspect.
[0006] To address the aforementioned technical problems, a third aspect of this application provides a computer-readable storage medium storing program data thereon, wherein the program data, when executed by a processor, implements the method described in the first aspect.
[0007] The beneficial effects of this application are as follows: Unlike existing technologies, this application obtains multiple focal points of the focusing motor during the focusing process of the camera, as well as the sharpness evaluation value of each image block in the images acquired at each of the multiple focal points. It determines the evaluation peak value corresponding to the sharpness evaluation value of each image block as the focal point changes, and the focal point matching the evaluation peak value. Therefore, during the camera's focusing process for any scene, the change in sharpness evaluation value and the evaluation peak value of each image block are determined on a per-block basis. Recording the focal point matching each evaluation peak value yields the required focal point value for target objects at different object distances. Based on the distribution of the focal point values matching the evaluation peak values, these focal point values are clustered to cluster similar distributions, resulting in multiple point step size intervals and a reference focal point value matching each point step size interval. This ensures that the point step size intervals and reference focal point values are adapted to target objects within the corresponding object distance intervals in the current scene. The system acquires the target step size range selected for the camera from all point step size ranges, and adjusts the focusing motor according to the reference focus point matched by the target step size range. This allows for rapid adjustment of the focusing motor to achieve focusing according to specified requirements, and efficient clear imaging of the corresponding target objects in the scene. Attached Figure Description
[0008] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. Wherein: Figure 1 This is a flowchart illustrating one implementation method of the method focused on in this application; Figure 2 This is a schematic diagram illustrating an application scenario of one embodiment of the object distance curve in this application; Figure 3 This is a flowchart illustrating another implementation of the focusing method of this application; Figure 4 This is a schematic diagram illustrating an application scenario of one implementation method for the change trend of the sharpness evaluation value in this application; Figure 5 This is a schematic diagram of the structure of one embodiment of the electronic device of this application; Figure 6 This is a schematic diagram of one embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0009] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments, and different implementation methods can be adaptively combined. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0010] In this paper, the terms "system" and "network" are often used interchangeably. The term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the character " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this paper means two or more.
[0011] The focusing method provided in this application is used to focus a camera, and its corresponding execution subject is a processing unit capable of image processing.
[0012] Please see Figure 1 , Figure 1 This is a flowchart illustrating one embodiment of the method focused on in this application. The method includes: S101: Acquire multiple focal points of the focusing motor during the focusing process of the camera, as well as the sharpness evaluation value of each image block in the image acquired at each focal point, and determine the evaluation peak value corresponding to the sharpness evaluation value of each image block and the focal point that matches the evaluation peak value.
[0013] Specifically, the camera acquires multiple focal points of the focusing motor during the focusing process, as well as the sharpness evaluation value of each image block in the images acquired at each of the multiple focal points. The camera then determines the peak value of the sharpness evaluation value of each image block as the focal point changes, and the focal point that matches the peak value.
[0014] It's important to note that the complete focusing process of a camera includes the adjustment of the zoom motor and the focus motor. When the camera switches scenes, the zoom motor first adjusts its position to zoom in, ensuring that objects in the scene are imaged at an appropriate size. Then, the focus motor adjusts its position to achieve a clear image of the objects. The focus motor's position adjustment is performed after the zoom motor's position has been fixed. Once the zoom motor's position is fixed, as the focus motor adjusts its position, the peak value of the sharpness evaluation differs depending on the object distance. In other words, the change in the focus point that matches the peak value reflects the difference in the object distance.
[0015] Furthermore, the focal point of the focusing motor corresponds to its position in the spatial system. During the adjustment process, the focal point of the focusing motor has an adjustment direction and an adjustment step size. The adjustment direction can be adjusted bidirectionally, and the adjustment step size can change with the adjustment process.
[0016] For clarity, please refer to Figure 2 , Figure 2 This is a schematic diagram illustrating an application scenario of one embodiment of the object distance curve in this application. Each type of camera corresponds to an object distance curve, which characterizes whether the zoom motor and focus motor maintain sharpness along the curve at a specified object distance. Figure 2 In the diagram, the horizontal axis represents the position of the zoom motor, and the vertical axis represents the position of the focusing motor. Different curves represent different object distances, where inf represents infinity and near represents nearness. Figure 2 It can be seen that after the position of the zoom motor is fixed, there is a mapping relationship between the focal point of the focusing motor and the object distance. In other words, once the focal point is obtained when a clear image is obtained, the object distance corresponding to the focal point can be determined.
[0017] Understandably, during the process of a camera focusing on any scene, the sharpness evaluation value of each image block is determined on a per-block basis, and the peak value is recorded. By recording the focus point that matches each peak value, the required focus point for the target object at different object distances can be obtained.
[0018] In one embodiment, multiple focal points of the focusing motor of the camera are acquired during the focusing process, as well as the image captured at each focal point. The image is divided into multiple image blocks according to a preset image segmentation method. Based on the gradient of pixels in each image block, the sharpness evaluation value of each image block is determined. According to the changing trend of the sharpness evaluation value of each image block as the focal point is adjusted, the evaluation peak value corresponding to the sharpness evaluation value of each image block is determined, and the focal point matching the evaluation peak value is extracted.
[0019] In one embodiment, multiple focal points of the focusing motor of the camera are acquired during the focusing process, as well as the image captured at each focal point. The proportion of each target in the image is determined. Based on the proportion of each target, the image is segmented to obtain multiple image blocks. Based on the frequency domain energy of each image block, the sharpness evaluation value of each image block is determined. According to the change of each image block when the focal point is adjusted in any direction, the evaluation peak value corresponding to the sharpness evaluation value of each image block is determined. The focal point matching the evaluation peak value is extracted.
[0020] Optionally, during the change of the focus point of the focusing motor, the evaluation peaks of different image blocks are sorted according to the bubble sort algorithm to facilitate the statistical analysis of the adjustment points matching the evaluation peaks of different image blocks.
[0021] S102: Based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered to obtain multiple point step size intervals and reference focal points for matching each point step size interval.
[0022] Specifically, based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered so that focal points with similar distribution can be clustered to obtain multiple point step size intervals and reference focal points matching each point step size interval, so that the point step size intervals and reference focal points are adapted to the target objects in the current scene that are in the corresponding object distance intervals.
[0023] In one embodiment, a preset target number is obtained, and based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered into the target number of clusters. According to the position changes of the focal points within each cluster, the position step size interval of each cluster is determined, and the focal point corresponding to the cluster center of each cluster is used as the reference focal point for matching the corresponding position step size interval.
[0024] In one embodiment, based on the distribution of the focal points for evaluating peak matching, multiple clustering radii are generated that are compatible with the distribution density and distribution interval of the focal points. The focal points for evaluating peak matching are clustered according to the clustering radii to obtain the focal points within each point step interval. The average position of the focal points within the point step interval is used as the reference focal point for point step interval matching.
[0025] In some implementation scenarios, the preset number of targets is three. Based on the distribution of the focal points for evaluating peak matching, these focal points are clustered into three clusters. According to the positional changes of the focal points within each cluster, the positional step size interval for each cluster is determined, so that the positional step size intervals of the three clusters are adapted to the object distance intervals corresponding to near-field, mid-field, and far-field, respectively. The focal point corresponding to the cluster center of each cluster is used as the reference focal point for matching the corresponding positional step size interval.
[0026] It is understandable that other target quantities can be set in different implementation scenarios. For example, when the target quantity is two, the resulting clusters are adapted to the object distance intervals corresponding to the near and far views, respectively. When more than three target quantities are set, the object distance interval is divided more finely. This application will not elaborate on this further.
[0027] In some implementation scenarios, based on the distribution of the focal points for evaluating peak matching, at least two sets of clustering radii are generated that are compatible with the distribution density and interval of the focal points. The focal points for evaluating peak matching are clustered according to the clustering radii to obtain a corresponding number of clusters and their corresponding point step size intervals. The average position of the focal points within the point step size interval is used as the reference focal point for point step size interval matching, so as to adaptively generate a corresponding number of point step size intervals according to the actual scenario.
[0028] S103: Obtain the target step size interval selected for the camera from all point step size intervals, and adjust the focus motor based on the reference focus point matched by the target step size interval.
[0029] Specifically, the target step size range selected for the camera is obtained from all point step size ranges, and the focusing motor is adjusted according to the reference focus point matched by the target step size range. This allows the focusing motor to be quickly adjusted to achieve focusing according to specified requirements, and to efficiently and clearly image the corresponding target objects in the scene.
[0030] In one embodiment, each point step interval is converted into a corresponding object distance interval according to the mapping relationship between the focus point and the object distance. Based on the selected object distance interval, a target step interval is determined from all point step intervals, and the focusing motor is adjusted according to the reference focus point matched by the target step interval.
[0031] In one embodiment, the target object distance is obtained, and based on the mapping relationship between the focal point and the object distance, the point step size interval where the target object distance is located is determined. The point step size interval where the target object distance is located is taken as the target step size interval, and the focusing motor is adjusted according to the reference focal point matched by the target step size interval.
[0032] Understandably, after adjusting the focusing motor according to the reference focusing point matched with the target step size interval, a reference image acquired at the reference focusing point can be obtained, and the position of the focusing motor can be fine-tuned based on the sharpness evaluation value of the reference image.
[0033] In some implementation scenarios, the camera is equipped with a control terminal and an interactive interface that can interact with the control terminal. The selection of the target step size range is triggered by the interactive interface, which is set on a remote terminal, thus facilitating remote control of the camera.
[0034] The above scheme acquires multiple focal points of the focusing motor during the camera's focusing process, as well as the sharpness evaluation value of each image block in the images acquired at each of these focal points. It determines the peak value corresponding to the sharpness evaluation value of each image block as the focal point changes, and the focal point matching the peak value. Thus, during the camera's focusing process for any scene, the scheme determines the change in sharpness evaluation value and the peak value of each image block on a per-block basis. Recording the focal point matching each peak value yields the required focal points for targets at different object distances. Based on the distribution of the focal points matching the peak values, the scheme clusters these points to ensure similar distributions. This results in multiple point step size intervals and a reference focal point matching each interval, ensuring that the point step size intervals and reference focal points are compatible with targets within the corresponding object distance intervals in the current scene. The system acquires the target step size range selected for the camera from all point step size ranges, and adjusts the focusing motor according to the reference focus point matched by the target step size range. This allows for rapid adjustment of the focusing motor to achieve focusing according to specified requirements, and efficient clear imaging of the corresponding target objects in the scene.
[0035] Please see Figure 3 , Figure 3 This is a flowchart illustrating another embodiment of the focusing method of this application, the method comprising: S201: Acquire multiple focal points of the focusing motor during the focusing process of the camera, as well as the sharpness evaluation value of each image block in the image acquired at each focal point, and determine the evaluation peak value corresponding to the sharpness evaluation value of each image block and the focal point that matches the evaluation peak value.
[0036] Specifically, the camera acquires multiple focal points of the focusing motor during the focusing process, as well as the sharpness evaluation value of each image block in the images acquired at each of the multiple focal points. The camera then determines the peak value of the sharpness evaluation value of each image block as the focal point changes, and the focal point that matches the peak value.
[0037] In one embodiment, multiple focal points of the focusing motor of the camera during the focusing process and the images captured at each focal point are acquired. The sharpness evaluation value of each image block in the image captured at each focal point is determined, as well as the trend of the sharpness evaluation value with the focal point. Based on the trend, the evaluation peak value corresponding to the sharpness evaluation value of each image block is obtained, and the focal point matching the evaluation peak value is determined.
[0038] Specifically, the system acquires multiple focal points of the focusing motor during the focusing process of the camera and the images captured at each focal point. It then sequentially determines the sharpness evaluation value of each image block in the image captured at each focal point and obtains the trend of the sharpness evaluation value as the focal point changes. This allows for detailed recording of the trend of each image block as the focal point changes in a specific scenario, facilitating the analysis of all image blocks one by one.
[0039] Furthermore, based on the changes in the sharpness evaluation value in the trend, the evaluation peak that meets the peak feature is extracted from each image block, and the focal point matching the evaluation peak is determined. Thus, the evaluation peak and the focal point matching the evaluation peak are efficiently determined through the trend.
[0040] For clarity, please refer to Figure 4 , Figure 4 This is a schematic diagram illustrating an application scenario of one embodiment of the sharpness evaluation value change trend of this application, wherein, Figure 4 The image is simply divided into 9 image blocks. In real-world scenarios, it can be divided into other numbers of image blocks, and this application does not impose any specific limitations on this. Each image block corresponds to a trend curve of sharpness evaluation value. The red dots on the curve correspond to the starting positions of the focusing motor, represented by a step size of 1 in the spatial system corresponding to the focusing motor. The yellow dots on the curve represent the peak values of the sharpness evaluation values. Specifically, the focusing positions corresponding to the evaluation peak values of the 6 image blocks on the left have step sizes of 20, 21, and 22 in the spatial system corresponding to the focusing motor, while the focusing positions corresponding to the evaluation peak values of the 3 image blocks on the right have step sizes of 0 and 1 in the spatial system corresponding to the focusing motor.
[0041] It should be noted that, after obtaining the evaluation peak value corresponding to the sharpness evaluation value of each image block based on the trend of change, and determining the focal point position matching the evaluation peak, the process further includes: obtaining the step size difference between the focal points matching the evaluation peak in every two image blocks; adjusting the focusing motor based on the focal points matching the evaluation peak in at least some image blocks when all step size differences are less than the difference threshold; and clustering the focal points matching the evaluation peak based on the distribution of the focal points matching the evaluation peak to obtain multiple point step size intervals and a reference focal point position matching each point step size interval.
[0042] Specifically, each pair of image blocks is compared separately to determine the step size difference between the focal points for evaluating peak matching in each pair of image blocks. The step size difference is then compared with a difference threshold to determine whether the current scene includes target objects at multiple object distances.
[0043] Understandably, when the difference between any two image patches is less than a difference threshold, it indicates that the target objects in the current scene are at the same object distance, thus determining that the current scene has a single object distance. Based on the focal points of peak matching evaluation in at least some image patches, the required focal point for the focusing motor in the current scene is determined, thereby adjusting the focusing motor to adapt to the single object distance scene and improve scene adaptability. The final focal point adjusted by the focusing motor can be the focal point with the highest number of images, the average of the focal points corresponding to all image patches, or the focal point of any image patch.
[0044] Furthermore, if at least some step size differences are greater than or equal to the difference threshold, it indicates that the current scene includes target objects at multiple object distances. It is necessary to cluster the focal points corresponding to different object distances, enter the distribution of focal points based on the evaluation peak matching, cluster the focal points of the evaluation peak matching, and obtain multiple point step size intervals and reference focal points matching each point step size interval.
[0045] It should be noted that since operator fluctuations may form pseudo-peaks in the trend of sharpness evaluation values, that is, the complete trend includes multiple evaluation peaks that meet the peak characteristics, but pseudo-peaks are not peaks that can truly achieve sharp imaging, before proceeding to the step of clustering the focal points matched by the evaluation peaks based on the distribution of the focal points and obtaining multiple point step intervals and reference focal points matched for each point step interval, the evaluation peaks can be screened according to the method of steps S202-S203 to improve the confidence of the evaluation peaks and ensure the accuracy of clustering.
[0046] S202: Obtain the number of evaluation peaks in the image patch, and the rate of change of the sharpness evaluation value at the evaluation peak.
[0047] Specifically, the number of peaks is obtained by counting the total number of evaluation peaks in the image block, the slope of the sharpness evaluation value at the evaluation peak is determined, and the numerical change rate of the sharpness evaluation value at the evaluation peak is obtained.
[0048] It is understandable that the greater the number of peaks in an image patch, the higher the probability of false peaks. The rate of change of values can reflect the instantaneous rate of change of the sharpness evaluation value. False peaks usually have a flatter characteristic compared to true peaks. Therefore, false peaks can be screened by the number of peaks and the rate of change of values.
[0049] S203: Based on the number of peaks and the rate of change of values, select the evaluation peaks for clustering from the evaluation peaks of the image patch.
[0050] Specifically, for each image, the evaluation peaks in the image block are filtered based on the number of peaks and the rate of change of values corresponding to the image block. Evaluation peaks with higher confidence are selected from the evaluation peaks of the image block for clustering, thereby ensuring the accuracy of clustering.
[0051] It is understandable that the more peaks there are in a single image patch, the lower the confidence level of the evaluation peaks in the corresponding image patch. The smaller the rate of change of the values at the evaluation peaks, the lower the confidence level of the corresponding evaluation peaks. Therefore, based on the two dimensions of peak quantity and evaluation peaks, it is possible to effectively filter out evaluation peaks with higher confidence.
[0052] In one embodiment, a quantity evaluation value corresponding to the evaluation peak in the image block is obtained based on the number of peaks corresponding to the image block, and a change rate evaluation value corresponding to the evaluation peak is obtained based on the change rate of the evaluation peak. A comprehensive evaluation value corresponding to the evaluation peak is obtained based on the quantity evaluation value and the change rate evaluation value corresponding to the evaluation peak. Evaluation peaks with a comprehensive evaluation value greater than the evaluation value threshold are used as evaluation peaks for clustering.
[0053] Specifically, based on the number of peaks corresponding to the image patch, a corresponding quantity evaluation value is set for the evaluation peak in the image patch, and based on the numerical change rate corresponding to the evaluation peak, a corresponding change rate evaluation value is set for the evaluation peak.
[0054] Furthermore, the quantity evaluation value and the rate of change evaluation value are integrated to determine the comprehensive evaluation value corresponding to the evaluation peak from two dimensions, thereby improving the accuracy of the comprehensive evaluation value. Evaluation peaks with comprehensive evaluation values less than or equal to the evaluation value threshold are removed, while evaluation peaks with comprehensive evaluation values greater than the evaluation value threshold are retained as evaluation peaks for clustering.
[0055] In some implementation scenarios, there is a first conversion function between the number of peaks and the quantity evaluation value, in which the quantity evaluation value is negatively correlated with the number of peaks. There is a second conversion function between the rate of change of values and the rate of change evaluation value, in which the rate of change evaluation value is positively correlated with the rate of change of values. The evaluation value threshold changes with the mean of the comprehensive evaluation value of the evaluation peaks in the image patch.
[0056] In some implementation scenarios, the peak quantity corresponds to a first assignment method, the peak quantity in different quantity ranges corresponds to a specific evaluation value assignment, the numerical change rate corresponds to a second assignment method, the numerical change rate in different numerical ranges corresponds to a specific evaluation value assignment, and the evaluation value threshold is a preset fixed value.
[0057] Optionally, the comprehensive evaluation value is obtained by weighted summation of the quantity evaluation value and the rate of change evaluation value, and the weight allocation can be customized in different scenarios.
[0058] In a specific implementation scenario, for an image patch, if there is only one evaluation peak, the evaluation value for the peak quantity dimension is 100 (full marks); if there are two, it is 60 (passing grade); and if there are more than two, it is 0. If the rate of change at the evaluation peak reaches 10% or more, the evaluation value for the rate of change dimension is 100 (full marks); if it is 5%-10%, it is 60 (passing grade); and if it is less than 5%, it is 0. The average of the quantity evaluation value and the rate of change evaluation value is taken as the comprehensive evaluation value for the region, and the evaluation value threshold is set to 60.
[0059] S204: Based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered to obtain multiple point step size intervals and reference focal points for matching each point step size interval.
[0060] Specifically, based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered so that focal points with similar distribution can be clustered, resulting in multiple point step size intervals and reference focal points matching each point step size interval.
[0061] In one embodiment, based on the distribution of the focal points of the evaluation peak matching, the clustering radius corresponding to multiple point step size intervals is determined, and the focal points of the evaluation peak matching are clustered according to the clustering radius corresponding to each point step size interval to obtain the focal points within each point step size interval; based on the focal points within each point step size interval, the reference focal point for matching each point step size interval is determined.
[0062] Specifically, based on the distribution of the focal points of the evaluation peak matching, the focal points corresponding to the evaluation peak are adaptively clustered to obtain the clustering radius corresponding to multiple point step size intervals. The focal points of the evaluation peak matching are clustered according to the clustering radius corresponding to each point step size interval, reducing the probability of over-segmentation or over-merging during the clustering process, and obtaining the focal points within each point step size interval after clustering.
[0063] Furthermore, based on the focal points within each point step interval, a focal point is set for each point step interval to obtain a matching reference focal point for each point step interval, so that the focal points covered within the point step interval can meet the image clarity requirements when adjusted according to the reference focal point.
[0064] In some implementation scenarios, the cluster radius corresponding to the cluster center changes adaptively during the clustering process. The above process can be expressed by the following formula: (1) in, The cluster radius is 1. and Let k be the evaluation peak value in the i-th and j-th image patches, and k be the number of evaluation peak values. This is the normalization coefficient.
[0065] S205: Obtain the target step size interval selected for the camera from all point step size intervals, and adjust the focus motor based on the reference focus point matched by the target step size interval.
[0066] Specifically, the target step size interval selected for the camera is obtained from all point step size intervals, and the focusing motor in the camera is quickly adjusted according to the reference focus point matched by the target step size interval to achieve rapid response.
[0067] It is understandable that during the focusing process, the camera has a zoom step size corresponding to the zoom motor, and the zoom step size is matched with the mapping relationship between the focus point and the object distance.
[0068] In one embodiment, obtaining a target step size interval for the camera from all point step size intervals, and adjusting the focusing motor based on the reference focus point matched by the target step size interval, includes: determining a reference object distance matched by each reference focus point based on the reference focus point matched by each point step size interval and the mapping relationship; setting a matching object distance category for each reference object distance; displaying the object distance category on the interactive interface; obtaining the object distance category selected for the camera on the interactive interface; using the point step size interval corresponding to the selected object distance category as the target step size interval; and adjusting the focusing motor based on the reference focus point matched by the target step size interval.
[0069] Specifically, based on the reference focal point and mapping relationship matched within each point's step size interval, the reference object distance matched for each reference focal point in the current scene is determined. Object distance categories are set according to the distance of the reference object distance, and these categories are displayed on the interactive interface for intuitive and convenient selection of imaging requirements for different object distances in the current scene. The target object distance is the reference object distance matched by the selected object distance category. The object distance category must be compatible with the reference object distance and must include at least near-field and far-field objects.
[0070] Furthermore, the object distance category selected for the camera on the interactive interface is obtained. Based on the correlation between the object distance category and the point step size interval, the point step size interval corresponding to the object distance category is determined. The corresponding point step size interval is used as the target step size interval, thereby quickly determining the matching focus point under the specified object distance. The focusing motor is adjusted based on the reference focus point matched by the target step size interval.
[0071] It is understandable that for cameras with pan-tilt-zoom (PTZ) functionality, such as PTZ cameras that can rotate, the distance between objects in the scene changes after the camera captures the scene when the PTZ is activated. The aforementioned method of displaying the distance category on the interactive interface ensures that the distance category is always displayed on the interactive interface and that the distance category is adapted to the distance of the target object in the latest scene, but the user does not perceive the actual change in distance, thereby improving the consistency of use after scene switching.
[0072] Optionally, the interactive interface is set on a remote terminal, thereby facilitating remote control of the camera.
[0073] In a specific implementation scenario, the interactive interface is set on a web terminal. The web terminal interacts with the camera's control terminal. The interactive interface includes selectable object distance categories that match each point step size interval. After any object distance category is selected, it is sent from the web terminal to the control terminal. The control terminal receives the object distance category, takes the point step size interval associated with the object distance category as the target step size interval, obtains the reference focus point matching the target step size interval, and drives the focus motor to the reference focus point matching the target step size interval.
[0074] In one embodiment, obtaining the target step size interval selected for the camera from all point step size intervals, and adjusting the focusing motor based on the reference focus point matched by the target step size interval, includes: obtaining the target object distance confirmed for the camera on the interactive interface; determining the focus point corresponding to the target object distance based on the target object distance and the mapping relationship; taking the point step size interval matched by the focus point corresponding to the target object distance as the target step size interval, and adjusting the focusing motor based on the reference focus point matched by the target step size interval.
[0075] Specifically, the target distance confirmed by the camera on the interactive interface is obtained to obtain the specified requirements in the specific scene. Based on the target distance and the mapping relationship, the target distance is converted into the position in the spatial system corresponding to the focusing motor to obtain the focus point position matching the target distance.
[0076] Optionally, the target object distance can be confirmed by directly entering it in the interactive interface or by selecting a candidate option on the interactive interface.
[0077] Furthermore, the target object distance matching focal point is matched with each point step size interval. First, the point step size interval where the target object distance matching focal point is located is found. If the point step size interval where the target object distance matching focal point is located is not found, the point step size interval closest to the target object distance matching focal point is found. The point step size interval matching the target object distance corresponding to the focal point is obtained. The point step size interval matching the target object distance corresponding to the focal point is used as the target step size interval, thereby quickly determining the matching focal point at the specified object distance. The focusing motor is adjusted based on the reference focal point matched by the target step size interval.
[0078] Optionally, when the difference between the focal point corresponding to the target object distance and the step size of each point step size interval exceeds a preset threshold, the point step size interval is converted into an object distance interval using a mapping relationship and displayed on the interactive interface so that the user can select a target object distance that is more suitable for the current scene.
[0079] It is understandable that for cameras with relatively fixed positions, such as bullet cameras, the probability of changes in the distance to objects within the scene is small. The method of confirming the distance to objects in the interactive interface can obtain more specific needs from users in specific scenarios, so as to quickly adjust the focusing motor in the camera according to specific needs.
[0080] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of an embodiment of the electronic device of this application. The electronic device 30 includes a memory 301 and a processor 302 coupled to each other. The memory 301 stores program data (not shown in the figure). The processor 302 calls the program data to implement the method in any of the above embodiments. For the description of the relevant content, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0081] Please see Figure 6 , Figure 6 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present application. The computer-readable storage medium 40 stores program data 400. When the program data 400 is executed by a processor, it implements the method in any of the above embodiments. For a detailed description of the relevant content, please refer to the detailed description of the above method embodiments, which will not be repeated here.
[0082] It should be noted that the units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0083] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0084] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0085] The above description is merely an embodiment of this application and does not limit the scope of protection of this application. Any equivalent structural or procedural transformations made based on the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the scope of protection of this application.
Claims
1. A focusing method, characterized in that, The method includes: The camera acquires multiple focal points of the focusing motor during the focusing process, as well as the sharpness evaluation value of each image block in the image acquired at each focal point, and determines the evaluation peak value corresponding to the sharpness evaluation value of each image block and the focal point that matches the evaluation peak value. Based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered to obtain multiple point step size intervals and reference focal points matching each point step size interval; Obtain the target step size interval selected for the camera from all the said point step size intervals, and adjust the focusing motor based on the reference focus point matched by the target step size interval.
2. The focusing method according to claim 1, characterized in that, Before clustering the focal points of the evaluation peak matching based on their distribution to obtain multiple point step size intervals and reference focal points matching each point step size interval, the method further includes: Obtain the number of peak values of the evaluation peaks in the image block, and the rate of change of the sharpness evaluation value at the evaluation peaks; Based on the number of peaks and the rate of change of values, evaluation peaks for clustering are selected from the evaluation peaks of the image patch.
3. The focusing method according to claim 2, characterized in that, The step of selecting evaluation peaks for clustering from the evaluation peaks of the image patch based on the number of peaks and the rate of change of values includes: Based on the number of peaks corresponding to the image patch, a quantity evaluation value corresponding to the evaluation peak in the image patch is obtained; based on the rate of change of the value corresponding to the evaluation peak, a rate of change evaluation value corresponding to the evaluation peak is obtained. Based on the quantity evaluation value and the rate of change evaluation value corresponding to the evaluation peak, a comprehensive evaluation value corresponding to the evaluation peak is obtained. Evaluation peaks whose comprehensive evaluation values are greater than the evaluation value threshold are used as evaluation peaks for clustering.
4. The focusing method according to claim 1, characterized in that, The step of acquiring multiple focal points of the focusing motor during the focusing process of the camera, and the sharpness evaluation value of each image block in the image acquired at each focal point, and determining the evaluation peak value corresponding to the sharpness evaluation value of each image block and the focal point position matching the evaluation peak value, includes: The camera acquires multiple focal points of the focusing motor during the focusing process and the images captured at each focal point. It then determines the sharpness evaluation value of each image block in the image captured at each focal point, as well as the trend of the sharpness evaluation value as a function of the focal point. Based on the changing trend, the peak value corresponding to the sharpness evaluation value of each image block is obtained, and the focal point matching the peak value is determined.
5. The focusing method according to claim 4, characterized in that, After obtaining the peak value corresponding to the sharpness evaluation value of each image block based on the changing trend, and determining the focal point matching the peak value, the method further includes: Obtain the step size difference between the focal points of the evaluation peak matching in every two image blocks; In response to all of the step size differences being less than the difference threshold, the focusing motor is adjusted based on the focus point position of the evaluation peak matching in at least a portion of the image blocks; In response to at least some of the step size differences being greater than or equal to a difference threshold, the distribution of the focal points based on the evaluation peak matching is entered into the step of clustering the focal points of the evaluation peak matching to obtain multiple point step size intervals and a reference focal point matching each point step size interval.
6. The focusing method according to claim 1, characterized in that, Based on the distribution of the focal points of the evaluation peak matching, the focal points of the evaluation peak matching are clustered to obtain multiple point step size intervals and reference focal points matching each point step size interval, including: Based on the distribution of the focal points of the evaluation peak matching, the clustering radius corresponding to multiple point step intervals is determined, and the focal points of the evaluation peak matching are clustered according to the clustering radius corresponding to each point step interval to obtain the focal points within each point step interval. Based on the focal point within each of the said point step size intervals, a reference focal point matching each of the said point step size intervals is determined.
7. The focusing method according to claim 1, characterized in that, The camera has a zoom step size corresponding to the zoom motor during the focusing process, and the zoom step size is matched with a mapping relationship between the focus point and the object distance. The step of obtaining the target step range selected for the camera from all the said point step ranges, and adjusting the focusing motor based on the reference focus point matched by the target step range, includes: Based on the reference focal point matched by each of the point step size intervals and the mapping relationship, the reference object distance matched by each reference focal point is determined, a matching object distance category is set for each of the reference object distances, and the object distance category is displayed on the interactive interface. The object distance category selected for the camera on the interactive interface is obtained, the point step size interval corresponding to the selected object distance category is taken as the target step size interval, and the focusing motor is adjusted based on the reference focus point matched by the target step size interval.
8. The focusing method according to claim 1, characterized in that, The camera has a zoom step size corresponding to the zoom motor during the focusing process, and the zoom step size is matched with a mapping relationship between the focus point and the object distance. The step of obtaining the target step range selected for the camera from all the said point step ranges, and adjusting the focusing motor based on the reference focus point matched by the target step range, includes: Obtain the target distance confirmed by the camera on the interactive interface, and determine the focal point corresponding to the target distance based on the target distance and the mapping relationship; The point step size interval matched by the focal point position corresponding to the target object distance is taken as the target step size interval, and the focusing motor is adjusted based on the reference focal point position matched by the target step size interval.
9. An electronic device, characterized in that, include: A memory and a processor are coupled to each other, wherein the memory stores program data, and the processor invokes the program data to perform the method as described in any one of claims 1-8.
10. A computer-readable storage medium storing program data thereon, characterized in that, When the program data is executed by the processor, it implements the method as described in any one of claims 1-8.