Focusing method and device, electronic equipment and storage medium
By conducting focus search based on target focus strategy and clustering technology in multi-object distance scenarios, the problem of inaccurate focus in traditional methods is solved, and higher focus accuracy is achieved.
Patent Information
- Application Number
- CN202311239870.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-22
- Publication Date
- 2025-03-25
AI Technical Summary
In multi-object distance scenarios, the traditional focusing method reduces the accuracy of focus because multiple peaks of the FV value curve after weighted superposition are not the best clear points.
By focusing search based on the target focus strategy, the target image of the focus motor at each first focus position is obtained, the FV value of the image block is determined, the focus position corresponding to the maximum clustering FV value is determined, and finally the focus is focused based on the clustering result.
The accuracy of focus is improved, and the distance distribution law is obtained through the clustering results of the maximum FV value corresponding to the image block, achieving more accurate focus.
Smart Images

Figure CN119697490A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of camera technology, and in particular to a focusing method, device, electronic equipment and storage medium. Background Art
[0002] In the field of video surveillance, the traditional focusing method is to calculate the FV value of the picture based on a pre-set fixed area and fixed weight, and control the focusing motor to execute a hill climbing algorithm based on the FV value to search for the optimal clear point position.
[0003] However, in multi-object distance scenes, since the positions of clear points at different object distances are different, the FV value curves of different object distances are usually weighted superimposed, such as Figure 1 As shown, the solid line 10 represents the FV value curves corresponding to the object distances A and B after weighted superposition, the dotted line 11 represents the FV value curve corresponding to a single object distance A, and the dotted line 12 represents the FV value curve corresponding to a single object distance B. It can be seen that the peak of the object distance A corresponding to the solid line 10 and the peak of the object distance A corresponding to the dotted line 11 are not the same point, and the peak of the object distance B corresponding to the solid line 10 and the peak of the object distance B corresponding to the dotted line 12 are not the same point either. As a result, multiple peaks of the FV value curve after weighted superposition are not the best clear points, thereby reducing the focusing accuracy. Summary of the invention
[0004] In view of the problems existing in the prior art, embodiments of the present invention provide a focusing method, device, electronic device and storage medium.
[0005] The present invention provides a focusing method, comprising:
[0006] Performing a focus search based on a target focus strategy, and acquiring a first target image captured by the electronic device when the focus motor is at each first focus position;
[0007] For each of the first target images, determining FV values of at least two image blocks in the first target image;
[0008] For each target image block at the same position of each of the first target images, based on the FV values of the target image blocks of all the first target images, determine a first maximum FV value corresponding to the target image block;
[0009] Clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0010] Focusing is performed based on the first clustering result.
[0011] According to a focusing method provided by the present invention, the focusing search is performed based on the target focusing strategy, and a first target image captured by the electronic device is obtained when the focusing motor is at each first focusing position, including:
[0012] When the focus motor is located at a focus starting position, a first image captured by the electronic device is acquired; when the target focus strategy includes focusing to the nearest object distance or focusing to the farthest object distance, the focus starting position includes the current position of the focus motor; when the target focus strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the focus starting position includes the minimum focus position of the focus search interval; K is an integer greater than 1 or equal to;
[0013] Controlling the focus motor to move from the focus starting position based on a preset focus step length and a first focus search direction to obtain each target position;
[0014] When the focusing motor is located at each of the target positions, acquiring each second image taken by the electronic device;
[0015] The first image and each of the second images are determined as the first target images.
[0016] According to a focusing method provided by the present invention, focusing based on the first clustering result includes:
[0017] When the number of clusters in the first clustering result is zero, an average value of the first focus positions corresponding to all the first maximum FV values is determined as a first target clear point position, and the focus motor is controlled to move to the first target clear point position;
[0018] When the number of classes in the first clustering result is not equal to zero, a second target clear point position is determined based on the target focusing strategy and the center value of the class, and the focusing motor is controlled to move to the second target clear point position.
[0019] According to a focusing method provided by the present invention, when the values of the focus position increase successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is not equal to zero, determining the second target clear point position based on the target focusing strategy and the center value of the class, includes:
[0020] When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing to the nearest object distance or focusing to the farthest object distance, determining the distance between the center value of the class and the focus starting point position;
[0021] When the distance is greater than or equal to a preset distance, determining the center value of the class as the second target clear point position;
[0022] When the distance is less than the preset distance, starting from the focus starting point, a focus search is performed based on the preset focus step and the second focus search direction to obtain a second target image captured by the electronic device when the focus motor is at each second focus position; the second focus search direction is opposite to the first focus search direction;
[0023] For each of the second target images, determining FV values of at least two image blocks in the second target image;
[0024] For each target image block at the same position, based on the FV values of the target image blocks of all the first target images and all the second target images, determine a second maximum FV value corresponding to the target image block;
[0025] Clustering the focus positions corresponding to all the second maximum FV values to obtain a second clustering result;
[0026] The second target clear point position is determined based on the second clustering result.
[0027] According to a focusing method provided by the present invention, when the number of classes in the first clustering result is not equal to zero, determining the position of the second target clear point based on the target focusing strategy and the center value of the class includes:
[0028] When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance or focusing on multiple object distances, the center value of the class is determined as the second target clear point position.
[0029] According to a focusing method provided by the present invention, when the number of classes in the first clustering result is not equal to zero, determining the position of the second target clear point based on the target focusing strategy and the center value of the class includes:
[0030] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the nearest object distance, determining the center value of the smallest class as the second target clear point position;
[0031] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the farthest object distance, determining the center value of the largest class as the second target clear point position;
[0032] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, based on the sorting of the center values of each class from small to large, the center value of the Kth class is determined as the second target clear point position;
[0033] When the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, based on the sorting of the center values of each class from small to large, the center values of each class after sorting are sequentially determined as the second target clear point positions corresponding to the object distances from near to far.
[0034] According to a focusing method provided by the present invention, clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result includes:
[0035] determining a cluster radius based on a depth of focus of the electronic device;
[0036] Determining a density threshold based on the number of the image blocks and a preset picture ratio; the preset picture ratio is the ratio of the target area to the first target image;
[0037] The focus positions corresponding to all the first maximum FV values are clustered based on the cluster radius and the density threshold to obtain the first clustering result.
[0038] The present invention also provides a focusing device, comprising:
[0039] An acquisition unit, configured to perform a focus search based on a target focus strategy, and acquire a first target image captured by the electronic device when the focus motor is at each first focus position;
[0040] A first determining unit, configured to determine, for each of the first target images, FV values of at least two image blocks in the first target image;
[0041] A second determining unit, configured to determine, for each target image block at the same position of each of the first target images, a first maximum FV value corresponding to the target image block based on the FV values of the target image blocks of all the first target images;
[0042] a clustering unit, configured to cluster the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0043] A focusing unit is used to focus based on the first clustering result.
[0044] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, any of the focusing methods described above is implemented.
[0045] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the focusing method as described above is implemented.
[0046] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the computer program implements any of the above-mentioned focusing methods.
[0047] The focusing method, device, electronic device and storage medium provided by the present invention perform focusing search based on the target focusing strategy, obtain the first target image captured by the electronic device when the focusing motor is at each first focusing position, determine the FV value of at least two image blocks in each first target image, and for each target image block at the same position, determine the first maximum FV value corresponding to the target image block based on the FV values of all target image blocks of all first target images, and then cluster the focusing positions corresponding to all the first maximum FV values, and finally focus based on the first clustering result obtained by clustering. It can be seen that the present invention obtains the object distance distribution law based on the clustering result of the maximum FV value corresponding to the image block, focuses according to the object distance distribution law, and improves the focusing accuracy. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1 is a schematic diagram of a FV value curve in the related art;
[0050] Figure 2 It is one of the flowcharts of the focusing method provided by the embodiment of the present invention;
[0051] Figure 3 is a focus curve of a zoom camera at different object distances provided by an embodiment of the present invention;
[0052] Figure 4 This is a second flow chart of the focusing method provided by an embodiment of the present invention;
[0053] Figure 5 This is a third flow chart of the focusing method provided by an embodiment of the present invention;
[0054] Figure 6 is a schematic diagram of a monitoring scenario provided by an embodiment of the present invention;
[0055] Figure 7 is a curve graph corresponding to the FV value of each image block in a multi-object distance scene provided by an embodiment of the present invention;
[0056] Figure 8is a schematic diagram of clustering results of focus positions corresponding to FV values of each image block in a multi-object distance scene provided by an embodiment of the present invention;
[0057] Fig. 9 is a schematic structural diagram of a focusing device provided by an embodiment of the present invention;
[0058] Fig.10 It is a schematic diagram of the physical structure of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0059] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0060] Depth of field refers to the fact that within a certain focusing range, images at different object distances appear acceptably clear. This focusing range is called focal depth.
[0061] The focus value (Focus Value, FV) is used to characterize the clarity of the image.
[0062] The position Zpos of the zoom motor is achieved by controlling the rotation of the zoom motor to drive the lens group to move, change the focal length of the focal lens, and realize the zoom action.
[0063] The focus motor position Fpos is achieved by adjusting the focus motor position to drive the focus lens group to move, so as to achieve the change of image clarity and blur.
[0064] The focus curve refers to the curve composed of the clear points FPos corresponding to each zoom position ZPos at a specified object distance, also known as the zoom-focus curve. The focus curves are different at different object distances.
[0065] The hill climbing algorithm is a local optimization algorithm. It starts from the current focus position, selects a direction at random, changes the focus position, obtains the FV value and compares it with the FV value of the previous position. If the FV trend increases, the focus continues to move in that direction. If the FV trend decreases, the focus moves in the opposite direction, and so on, until the focus position corresponding to the maximum FV value is found. Since it is not a comprehensive search, the final result may be a local maximum.
[0066] Combine the following Figure 2-Figure 8The focusing method of the present invention is described. The execution subject of the method may be an electronic device, and the electronic device may be a camera device or a terminal with a camera function.
[0067] Figure 2 is one of the flow charts of the focusing method provided by the embodiment of the present invention, such as Figure 2 As shown, the focusing method comprises the following steps:
[0068] Step 201: Perform a focus search based on a target focus strategy, and obtain a first target image captured by the electronic device when the focus motor is at each first focus position.
[0069] Among them, the target focus strategy is a focus strategy set by the user, and the focus strategy includes focusing to the nearest object distance, focusing to the nearest object distance, focusing to the Nth object distance starting from the nearest object distance, or focusing to multiple object distances, etc.
[0070] For example, according to the minimum focusing distance of the electronic device and the clear point position corresponding to the infinite object distance curve, the minimum focusing position and the maximum focusing position of the initial focusing search interval are determined, and the position between the minimum focusing position and the maximum focusing position is determined as the initial focusing search interval, such as Figure 3 As shown, the rectangular frame 301 is a partial enlargement of the curve, and the focus position corresponding to the object distance of 3m (meter) is determined as the minimum focus position, and the focus position corresponding to the infinite object distance is determined as the maximum focus position. In order to prevent the clear point position of some electronic devices from exceeding the initial focus search interval, the initial focus search interval can be expanded based on the half focal depth at the current focal length of the electronic device to obtain the final focus search interval, and then the hill climbing algorithm is used based on the target focus strategy set by the user to perform a focus search within the focus search interval to obtain each first focus position of the focus motor during the focus search process, and at each first focus position, the first target image captured by the electronic device is obtained, that is, the first target image corresponding to each first focus position is obtained.
[0071] Step 202: For each of the first target images, determine the FV values of at least two image blocks in the first target image.
[0072] For example, for each first target image, the first target image is divided into M rows and N columns to obtain M*N image blocks, and the FV value of each image block is counted. The matrix composed of the FV values of all image blocks in the first target image is recorded as V. V is an M*N matrix containing the FV value of each image block, which can be expressed by the following formula (1):
[0073] V=[V ij ], where i∈[0-M], j∈[0-N](1)
[0074] Among them, Vij Indicates the FV value of the image block corresponding to the i-th row and j-th column.
[0075] Step 203 : for each target image block at the same position of each first target image, determine a first maximum FV value corresponding to the target image block based on the FV values of the target image blocks of all the first target images.
[0076] For example, when obtaining the FV values of each image block in the first target image, for the target image blocks at the same position in all the first target images, the maximum FV value is found among the FV values of the target image blocks of all the first target images, and the maximum FV value is determined as the first maximum FV value corresponding to the target image block. According to the same method, the first maximum FV value corresponding to each target image block at the same position can be obtained.
[0077] Step 204: cluster the focus positions corresponding to all the first maximum FV values to obtain a first clustering result.
[0078] For example, when the first maximum FV value corresponding to each target image block is obtained, the focus positions corresponding to all the first maximum FV values are clustered using a clustering algorithm to obtain a first clustering result, and the distribution pattern of object distance in the current scene is found out through the first clustering result; wherein the clustering algorithm can be a DBSCAN clustering algorithm, which is a density-based spatial clustering algorithm that can divide areas with sufficiently high density into clusters.
[0079] Step 205: Focusing based on the first clustering result.
[0080] For example, when the first clustering result is obtained, focusing is performed based on the object distance distribution law represented by the first clustering result.
[0081] The focusing method provided by the present invention performs focusing search based on the target focusing strategy, obtains the first target image captured by the electronic device when the focusing motor is at each first focusing position, determines the FV value of at least two image blocks in each first target image, and for each target image block at the same position, determines the first maximum FV value corresponding to the target image block based on the FV values of all target image blocks of all first target images, and then clusters the focusing positions corresponding to all the first maximum FV values, and finally focuses based on the first clustering result obtained by clustering. It can be seen that the present invention obtains the object distance distribution law based on the clustering result of the maximum FV value corresponding to the image block, focuses according to the object distance distribution law, and improves the focusing accuracy.
[0082] In one embodiment, Figure 4 FIG. 2 is a second flow chart of the focusing method provided by an embodiment of the present invention. Figure 4As shown, the above step 201 performs focus search based on the target focus strategy, and obtains the first target image captured by the electronic device when the focus motor is at each first focus position. Specifically, it can be implemented by the following steps:
[0083] Step 2011, when the focus motor is located at the focus starting position, acquiring a first image captured by the electronic device; when the target focus strategy includes focusing to the nearest object distance or focusing to the farthest object distance, the focus starting position includes the current position of the focus motor; when the target focus strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the focus starting position includes the minimum focus position of the focus search interval; K is an integer greater than or equal to 1.
[0084] For example, the focus starting position is first determined based on the target focus strategy, and then the focus motor is moved to the focus starting position. After the focus motor is stabilized, a first image captured by the electronic device is acquired.
[0085] Step 2012: Control the focus motor to move from the focus starting position based on a preset focus step size and a first focus search direction to obtain each target position.
[0086] Among them, when the target focusing strategy includes focusing to the nearest object distance, the first focusing search direction is the direction of searching towards the minimum focusing position of the focusing search interval; when the target focusing strategy includes focusing to the farthest object distance, the first focusing search direction is the direction of searching towards the maximum focusing position of the focusing search interval; when the target focusing strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the first focusing search direction is the direction of searching towards the maximum focusing position of the focusing search interval.
[0087] The focusing step length is a trade-off between focusing speed and focusing accuracy. If the focusing step length is too large, the focusing speed is fast, but the focusing result accuracy is poor; if the focusing step length is too small, the focusing speed is slow, but the focusing result accuracy is high. A suitable focusing step length can be selected according to the actual focusing requirements, and the present invention does not limit this. For example, 1 / 4 of the focal depth can be selected as the preset focusing step length; the first focusing search direction is determined based on the target focusing strategy.
[0088] For example, when determining the preset focus step and the first focus search direction, the focus motor is controlled to move from the focus starting position to the next focus position based on the preset focus step and the first focus search direction. If the first focus search direction is a direction for searching toward the maximum focus position of the focus search interval, the next focus position is the current focus position plus the preset focus step; if the first focus search direction is a direction for searching toward the minimum focus position of the focus search interval, the next focus position is the current focus position minus the preset focus step; until the focus motor reaches the maximum focus position of the focus search interval, the target positions of the focus motor in the focus search process are finally obtained.
[0089] Step 2013: When the focus motor is located at each of the target positions, acquiring each second image taken by the electronic device.
[0090] For example, at each target position, the second image captured by the electronic device is acquired, that is, the corresponding second image at each target position is obtained.
[0091] Step 2014: determine the first image and each of the second images as the first target images.
[0092] For example, the first image and each second image captured by the electronic device are determined as first target images corresponding to the focus search process.
[0093] In this embodiment, the focus starting position and the first focus search direction can be determined based on the target focus strategy, and a focus search can be performed based on the determined focus starting position and the first focus search direction, and finally each first target image is obtained, thereby realizing the process of acquiring the target image based on user needs.
[0094] In one embodiment, the above step 205 performs focusing based on the first clustering result, which can be specifically implemented in the following manner:
[0095] When the number of classes in the first clustering result is zero, an average value of the first focus positions corresponding to all the first maximum FV values is determined as a first target clear point position, and the focus motor is controlled to move to the first target clear point position.
[0096] For example, when the number of classes in the first clustering result is zero, it means that the clear point position has not been found, the object distance in the current scene changes evenly, and there is no clear object distance boundary. The average value of the first focus position corresponding to all first maximum FV values can be determined as the first target clear point position, and the focus motor is controlled to move to the first target clear point position, thereby completing the focusing.
[0097] When the number of classes in the first clustering result is not equal to zero, a second target clear point position is determined based on the target focusing strategy and the center value of the class, and the focusing motor is controlled to move to the second target clear point position.
[0098] For example, when the number of classes in the first clustering result is not zero, there is at least one object distance in the current scene. At this time, it is necessary to determine the final second target clear point position based on the target focusing strategy and the center value of each class in the first clustering result, and control the focusing motor to move to the second target clear point position to complete the focusing.
[0099] Specifically, when the number of classes in the first clustering result is not equal to zero, the second target clear point position is determined based on the target focus strategy and the center value of the class, which can be specifically divided into the following cases:
[0100] In the first case, when the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing to the nearest object distance or focusing to the farthest object distance, the distance between the center value of the class and the focusing starting position is determined.
[0101] When the distance is greater than or equal to the preset distance, the center value of the class is determined as the second target clear point position.
[0102] In the case where the distance is less than the preset distance, starting from the focus starting position, a focus search is performed based on the preset focus step and the second focus search direction to obtain a second target image captured by the electronic device when the focus motor is at each second focus position; for each second target image, the FV value of at least two image blocks in the second target image is determined; for each target image block at the same position, based on the FV values of the target image blocks of all the first target images and all the second target images, the second maximum FV value corresponding to the target image block is determined; the focus positions corresponding to all the second maximum FV values are clustered to obtain a second clustering result; and the second target clear point position is determined based on the second clustering result.
[0103] The second focus search direction is opposite to the first focus search direction, and the center value of a class is the average value of all focus positions included in the class.
[0104] For example, when the number of classes in the first clustering result is equal to 1, and the target focus strategy includes focusing to the nearest object distance or focusing to the farthest object distance, since the target focus strategy is focusing to the nearest object distance or focusing to the farthest object distance, the focus starting position is the current position of the electronic device, that is, the focus starting position may not be at the boundary of the focus search interval, indicating that the focus search has not traversed the entire focus search interval. Therefore, it is necessary to determine the distance between the center value of the class in the first clustering result and the focus starting position, and compare the distance with the preset distance. When the distance is greater than or equal to the preset distance, it means that the center value of the class is far away from the focus starting position. At this time, the center value of the class can be directly determined as the second target clear point position; when the distance is less than the preset distance, it means that the center value of the class is close to the focus starting position, which also means that the second target clear point position may be in the unknown. The search area needs to be searched in reverse, that is, starting from the focus starting position, a focus search is performed based on a preset focus step and a second focus search direction opposite to the first focus search direction, to obtain the second target image taken by the electronic device when the focus motor is at each second focus position, and calculate the FV value of each second image block in each second target image. It should be emphasized here that the number of second image blocks in the second target image is the same as the number of first image blocks in the first target image. For the target image blocks at the same position, it is necessary to determine the second maximum FV value of the target image block based on the FV values of the target image blocks of all the first target images and all the second target images obtained by the forward and reverse searches, and then perform a clustering operation on all the second maximum FV values obtained to obtain a second clustering result, and determine the final second target clear point position based on the second clustering result.
[0105] It should be noted that the specific process of determining the final second target clear point position based on the second clustering result may refer to the specific process of determining the first target clear point position based on the first clustering result, and the present invention will not be repeated here.
[0106] In the second case, when the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance or focusing on multiple object distances, the center value of the class is determined as the second target clear point position.
[0107] For example, since the target focus strategy is to focus on the Kth object distance from the nearest object distance or to focus on multiple object distances, the focus starting position is the minimum focus position of the focus search interval, that is, the focus starting position is at the boundary of the focus search interval, which means that the focus search traverses the entire focus search interval. In the first clustering result, when the number of classes is equal to 1 and the target focus strategy includes focusing on the Kth object distance from the nearest object distance or to focus on multiple object distances, it is impossible to focus separately on each object distance. In this case, the center value of the class is directly determined as the second target clear point position.
[0108] In the third case, when the focus position values increase successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the nearest object distance, the center value of the smallest class is determined as the second target clear point position.
[0109] For example, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the nearest object distance, the center value of each class is determined. Since the center value of the smallest class is closer to the nearest object distance, the center value of the smallest class is determined as the second target clear point position.
[0110] In the fourth case, when the focus position values increase successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the farthest object distance, the center value of the largest class is determined as the second target clear point position.
[0111] For example, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the farthest object distance, the center value of each class is determined. Since the center value of the largest class is closer to the farthest object distance, the center value of the largest class is determined as the second target clear point position.
[0112] In the fifth case, when the focus position value increases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, the center value of the Kth class is determined as the second target clear point position based on the order of the center values of each class from small to large.
[0113] For example, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, the center value of each class is determined, and the center values of each class are sorted from small to large, and the center value of the Kth class can be determined as the second target clear point position; for example, if the value of K is 2, the center values of 2 classes are determined as the second target clear point position.
[0114] In the sixth case, when the focus position value increases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, based on the sorting of the center values of each class from small to large, the center values of each class after sorting are sequentially determined as the second target clear point position corresponding to the object distances from near to far.
[0115] For example, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, the center value of each class is determined, and the center values of each class are sorted from small to large, and the center values of each class after sorting are sequentially determined as the second target clear point position corresponding to the object distances from near to far; for example, the target focusing strategy includes focusing on 3 object distances from near to far, and the determined number of classes is 3, then the center values of the three classes are sorted from small to large to obtain center value 1, center value 2 and center value 3, wherein center value 1 is less than center value 2, and center value 2 is less than center value 3, then center value 1 is determined as the second target clear point position corresponding to the nearest object distance, center value 2 is determined as the second target clear point position corresponding to the intermediate object distance, and center value 3 is determined as the second target clear point position corresponding to the farthest object distance. In addition, since each class contains multiple focus position samples, the focus area included in the corresponding object distance can be composed based on the size of each focus position sample included in the class, and when determining the second target clear point position corresponding to each object distance, the focus motor can be moved to the corresponding object distance based on the user-set strategy for focusing on multiple object distances, thereby realizing customized object distance focusing.
[0116] It should be noted that, when the target focusing strategy is to focus on the nearest object distance or to focus on the farthest object distance, if after the reverse search is performed, the number of classes in the second clustering result is still zero, indicating that the object distance in the current scene changes evenly and there is no clear object distance boundary. At this time, the focus position corresponding to the average value of all maximum FV values is determined as the clear point position; similarly, when the target focusing strategy is to focus on the Kth object distance starting from the nearest object distance or to focus on multiple object distances, the full-stroke focusing search is completed, and the number of classes in the first clustering result is still zero, indicating that the object distance in the current scene changes evenly and there is no clear object distance boundary. At this time, the focus position corresponding to the average value of all maximum FV values is determined as the clear point position.
[0117] It should be noted that the present invention can also be set to end the search early to avoid unnecessary searches and speed up the focusing speed. During the focus search process, the FV value of the image block in the image captured by the electronic device is calculated at each position of the focus motor to obtain the matrix V corresponding to each position, and then the ratio R of the FV values of each image block in two adjacent Vs is calculated. If the ratio of the target area of interest to the image screen is set to α in advance, the target smaller than the target area is ignored. During the focus search process in a certain direction, if the R corresponding to the image block occupying the image screen ratio (1-α) for L consecutive frames is less than 1, it means that there is no clear point position corresponding to the target area in the current search direction, so the search in this direction can be ended early.
[0118] Specifically, the ratio R can be expressed by the following formula (2):
[0119] R 21 =[V 2ij / V 1ij ], where i∈[0-M], j∈[0-N] (2)
[0120] Among them, R 21 V represents the image block in the first V 1ij and V of the image block in the second V 2ij ratio.
[0121] It should be noted that when the focus position value decreases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the nearest object distance, the center value of the largest class is determined as the second target clear point position.
[0122] It should be noted that when the focus position value decreases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the farthest object distance, the center value of the smallest class is determined as the second target clear point position.
[0123] It should be noted that when the focus position value decreases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, the center value of the Kth class is determined as the second target clear point position based on the order of the center values of each class from large to small.
[0124] It should be noted that when the focus position value decreases successively in the direction from the nearest object distance to the farthest object distance, when the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, based on the sorting of the center values of each class from large to small, the center values of each class after sorting are determined successively as the second target clear point position corresponding to the object distances from near to far.
[0125] In this embodiment, based on the different numbers of classes in the focusing results and the different target focusing strategies, the methods for determining the clear point position are also different, and the focus can be accurately focused on any object distance that needs to be focused; in addition, when the target focusing strategy includes focusing on multiple object distances, the focus clarity evaluation values of the areas corresponding to different object distances can be taken into account, and the regular distribution of object distances can be determined through clustering results, so that in multiple object distance scenarios, the areas corresponding to different object distances have the same clarity.
[0126] In one embodiment, Figure 5 FIG. 3 is a flow chart of the focusing method provided by an embodiment of the present invention. Figure 5 As shown, the above step 204 clusters the focus positions corresponding to all the first maximum FV values to obtain a first clustering result, which can be specifically achieved by the following steps:
[0127] Step 2041: Determine a clustering radius based on the focal depth of the electronic device.
[0128] For example, the clustering parameters included in the DBSCAN clustering algorithm are the clustering radius Eps and the density threshold MinPts. The clustering radius Eps is set according to the depth of focus, Eps = k*Df, where Df is the depth of focus at the current focal length of the electronic device, and k is the adjustment coefficient. The clustering radius Eps determines the range of object distances contained in each cluster during clustering. Determining Eps based on the depth of focus can ensure that after clustering is completed, the object distance distribution in each class is within the depth of focus, and the image is clear.
[0129] Step 2042: Determine a density threshold based on the number of the image blocks and a preset picture ratio; the preset picture ratio is the ratio of the target area to the first target image.
[0130] For example, the density threshold determines the minimum cluster size in the clustering, which can be determined according to the size of the target area that the user focuses on, MintPts=α*M*N, where α is the ratio of the target area to the first target image, and the target area is the screen area occupied by the smallest target that the user focuses on.
[0131] Step 2043: cluster the focus positions corresponding to all the first maximum FV values based on the cluster radius and the density threshold to obtain the first clustering result.
[0132] For example, when determining the clustering radius and the density threshold, a clustering algorithm is used to cluster the focus positions corresponding to all first maximum FV values based on the clustering radius and the density threshold to obtain a first clustering result.
[0133] In this embodiment, the clustering radius is determined based on the depth of focus, and the density threshold is determined based on the target area of user interest, so that the object distance range contained in each cluster matches the depth of focus during clustering. This can ensure that after clustering is completed, the object distance distribution in each class is within the depth of focus and the image is clear; and the size of each cluster is small, so that the final clustering result is more accurate.
[0134] In one embodiment, the focusing method further comprises the following steps:
[0135] When the number of classes in the first clustering result is not equal to zero, for each object distance, the focus motor is controlled to move to the center value of the target class corresponding to the object distance, and the center value of the target class is determined as a new focus starting position; starting from the new focus starting position, a focus search is performed based on a new focus step and a new focus search interval to obtain a third target image captured by the electronic device when the focus motor is at each third focus position; based on the target focus strategy and each third target image, the target clear point position of the object distance is updated to obtain an updated clear point position; and the focus motor is controlled to move to the updated clear point position.
[0136] For example, based on the above steps 201 to 205, the clear point positions under different focusing strategies have been found, and the focusing motor is controlled to move to the corresponding clear point position to complete the focusing. However, if the preset focus step in the focus search module is too large, the clear point position determined by clustering may not be accurate enough, and the focus fine-tuning module can be used as an optional module to improve the focusing accuracy. According to the center value of the class in the clustering result as the starting point of the focus fine-tuning, the weight of the image block to which the FV value corresponding to the focus position sample contained in the class belongs is set to 1, and the weight of other image blocks is set to 0. A new focus step and a new focus search interval are set, and a hill climbing algorithm is executed once to find the precise clear point position under different object distances, and the focus motor is controlled to move to the clear point position after fine-tuning to complete the focusing process.
[0137] In this embodiment, the clear point position can be updated based on the focus fine-tuning module, so that the updated clear point position is more accurate, further improving the focusing accuracy.
[0138] Figure 6 is a schematic diagram of a monitoring scenario provided by an embodiment of the present invention, such as Figure 6As shown in the figure, the monitoring scene includes three sets of object distances with large differences, among which object distance 1 is the smallest, object distance 2 is the largest, and object distance 3 is between object distance 1 and object distance 2. If the user requires to focus on object distance 1, object distance 2, and object distance 3 in sequence, the focus motor is controlled to complete a round of search within the focus search interval, and the FV value of the image block corresponding to each position is recorded at the same time. If M = N = 15, there are 225 image blocks in total. The FV value curve of each image block is shown in Figure 7 The clustering process is performed on the maximum FV value corresponding to each image block, and the clustering result is as follows: Figure 8 As shown, from Figure 8 It can be seen that all image blocks are divided into three categories, namely class 1, class 2 and class 3. The center value of class 1 is determined as the clear point position corresponding to object distance 1, the center value of class 2 is determined as the clear point position corresponding to object distance 3, and the center value of class 3 is determined as the clear point position corresponding to object distance 2. Among them, the circle sample indicates that the FV peak is not near these three effective object distances and is considered to be a noise point. Compared with the algorithm based on regional weighted calculation of FV peak, the clustering algorithm can effectively avoid the influence of the FV value of the noise sample point on the clear point position of the effective object distance, while taking into account the clarity of different object distances within the focal depth range. In addition, the center value of the class in the present invention is determined based on the average of the maximum FV value, rather than the traditional algorithm based on the average of all FV values. Therefore, it can avoid the problem that the focused clear points are too biased towards the area with rich details, resulting in insufficient clarity in the area with fewer details.
[0139] The focusing device provided by the present invention is described below. The focusing device described below and the focusing method described above can be referenced to each other.
[0140] Fig. 9 is a schematic diagram of the structure of a focusing device provided by an embodiment of the present invention, such as Fig. 9 As shown, the focusing device 900 includes an acquisition unit 901, a first determination unit 902, a second determination unit 903, a clustering unit 904 and a focusing unit 905; wherein:
[0141] An acquisition unit 901 is used to perform a focus search based on a target focus strategy, and acquire a first target image captured by the electronic device when the focus motor is at each first focus position;
[0142] A first determining unit 902 is used to determine, for each of the first target images, FV values of at least two image blocks in the first target image;
[0143] A second determining unit 903 is configured to determine, for each target image block at the same position of each of the first target images, a first maximum FV value corresponding to the target image block based on the FV values of the target image blocks of all the first target images;
[0144] A clustering unit 904 is used to cluster the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0145] The focusing unit 905 is used to perform focusing based on the first clustering result.
[0146] The focusing device provided by the present invention performs focusing search based on the target focusing strategy, obtains the first target image captured by the electronic device when the focusing motor is at each first focusing position, determines the FV value of at least two image blocks in each first target image, and for each target image block at the same position, determines the first maximum FV value corresponding to the target image block based on the FV values of all target image blocks of all first target images, and then clusters the focusing positions corresponding to all the first maximum FV values, and finally focuses based on the first clustering result obtained by clustering. It can be seen that the present invention obtains the object distance distribution law based on the clustering result of the maximum FV value corresponding to the image block, focuses according to the object distance distribution law, and improves the focusing accuracy.
[0147] Based on any of the above embodiments, the acquiring unit 901 is specifically used for:
[0148] When the focus motor is located at a focus starting position, a first image captured by the electronic device is acquired; when the target focus strategy includes focusing to the nearest object distance or focusing to the farthest object distance, the focus starting position includes the current position of the focus motor; when the target focus strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the focus starting position includes the minimum focus position of the focus search interval; K is an integer greater than 1 or equal to;
[0149] The focusing motor is controlled to move from the focus starting position based on a preset focus step and a first focus search direction to obtain each target position; when the target focus strategy includes focusing to the nearest object distance, the first focus search direction is a direction to search toward the minimum focus position of the focus search interval; when the target focus strategy includes focusing to the farthest object distance, the first focus search direction is a direction to search toward the maximum focus position of the focus search interval; when the target focus strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the first focus search direction is a direction to search toward the maximum focus position of the focus search interval;
[0150] When the focusing motor is located at each of the target positions, acquiring each second image taken by the electronic device;
[0151] The first image and each of the second images are determined as the first target images.
[0152] Based on any of the above embodiments, the focusing unit 905 is specifically used for:
[0153] When the number of clusters in the first clustering result is zero, an average value of the first focus positions corresponding to all the first maximum FV values is determined as a first target clear point position, and the focus motor is controlled to move to the first target clear point position;
[0154] When the number of classes in the first clustering result is not equal to zero, a second target clear point position is determined based on the target focusing strategy and the center value of the class, and the focusing motor is controlled to move to the second target clear point position.
[0155] Based on any of the above embodiments, the focusing unit 905 is further specifically used for:
[0156] When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing to the nearest object distance or focusing to the farthest object distance, determining the distance between the center value of the class and the focus starting point position;
[0157] When the distance is greater than or equal to a preset distance, determining the center value of the class as the second target clear point position;
[0158] When the distance is less than the preset distance, starting from the focus starting point, a focus search is performed based on the preset focus step and the second focus search direction to obtain a second target image captured by the electronic device when the focus motor is at each second focus position; the second focus search direction is opposite to the first focus search direction;
[0159] For each of the second target images, determining FV values of at least two image blocks in the second target image;
[0160] For each target image block at the same position, based on the FV values of the target image blocks of all the first target images and all the second target images, determine a second maximum FV value corresponding to the target image block;
[0161] Clustering the focus positions corresponding to all the second maximum FV values to obtain a second clustering result;
[0162] The second target clear point position is determined based on the second clustering result.
[0163] Based on any of the above embodiments, the focusing unit 905 is further specifically used for:
[0164] When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance or focusing on multiple object distances, the center value of the class is determined as the second target clear point position.
[0165] Based on any of the above embodiments, when the values of the focus positions increase in sequence from the closest object distance to the farthest object distance, the focusing unit 905 is further specifically configured to:
[0166] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the nearest object distance, determining the center value of the smallest class as the second target clear point position;
[0167] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the farthest object distance, determining the center value of the largest class as the second target clear point position;
[0168] In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, based on the sorting of the center values of each class from small to large, the center value of the Kth class is determined as the second target clear point position;
[0169] When the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, based on the sorting of the center values of each class from small to large, the center values of each class after sorting are sequentially determined as the second target clear point positions corresponding to the object distances from near to far.
[0170] Based on any of the above embodiments, the clustering unit 904 is specifically used for:
[0171] determining a cluster radius based on a depth of focus of the electronic device;
[0172] Determining a density threshold based on the number of the image blocks and a preset picture ratio; the preset picture ratio is the ratio of the target area to the first target image;
[0173] The focus positions corresponding to all the first maximum FV values are clustered based on the cluster radius and the density threshold to obtain the first clustering result.
[0174] Fig.10 is a schematic diagram of the physical structure of an electronic device provided by an example of the present invention, such as Fig.10As shown, the electronic device may include: a processor 1010, a communication interface 1020, a memory 1030 and a communication bus 1040, wherein the processor 1010, the communication interface 1020 and the memory 1030 communicate with each other through the communication bus 1040. The processor 1010 may call the logic instructions in the memory 1030 to execute a focusing method, which includes: performing a focusing search based on a target focusing strategy, and obtaining a first target image captured by the electronic device when the focusing motor is at each first focusing position;
[0175] For each of the first target images, determining FV values of at least two image blocks in the first target image;
[0176] For each target image block at the same position of each of the first target images, based on the FV values of the target image blocks of all the first target images, determine a first maximum FV value corresponding to the target image block;
[0177] Clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0178] Focusing is performed based on the first clustering result.
[0179] In addition, the logic instructions in the above-mentioned memory 1030 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk.
[0180] On the other hand, the present invention further provides a computer program product, the computer program product includes a computer program, the computer program can be stored in a non-transitory computer-readable storage medium, when the computer program is executed by a processor, the computer can execute the focusing method provided by the above methods, the method includes: performing a focus search based on a target focus strategy, and obtaining a first target image captured by the electronic device when the focus motor is at each first focus position;
[0181] For each of the first target images, determining FV values of at least two image blocks in the first target image;
[0182] For each target image block at the same position of each of the first target images, based on the FV values of the target image blocks of all the first target images, determine a first maximum FV value corresponding to the target image block;
[0183] Clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0184] Focusing is performed based on the first clustering result.
[0185] In another aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which is implemented when the computer program is executed by a processor to execute the focusing method provided by the above methods, the method comprising: performing a focus search based on a target focus strategy, and obtaining a first target image captured by the electronic device when the focus motor is at each first focus position;
[0186] For each of the first target images, determining FV values of at least two image blocks in the first target image;
[0187] For each target image block at the same position of each of the first target images, based on the FV values of the target image blocks of all the first target images, determine a first maximum FV value corresponding to the target image block;
[0188] Clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result;
[0189] Focusing is performed based on the first clustering result.
[0190] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0191] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0192] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A focusing method, characterized in that: include: Performing a focus search based on a target focus strategy, and acquiring a first target image captured by the electronic device when the focus motor is at each first focus position; For each of the first target images, determining FV values of at least two image blocks in the first target image; For each target image block at the same position of each of the first target images, based on the FV values of the target image blocks of all the first target images, determine a first maximum FV value corresponding to the target image block; Clustering the focus positions corresponding to all the first maximum FV values to obtain a first clustering result; Focusing is performed based on the first clustering result.
2. The focusing method according to claim 1, characterized in that: The focusing search is performed based on the target focusing strategy, and the first target image captured by the electronic device is obtained when the focusing motor is at each first focusing position, including: When the focus motor is located at a focus starting position, a first image captured by the electronic device is acquired; when the target focus strategy includes focusing to the nearest object distance or focusing to the farthest object distance, the focus starting position includes the current position of the focus motor; when the target focus strategy includes focusing to the Kth object distance starting from the nearest object distance or focusing to multiple object distances, the focus starting position includes the minimum focus position of the focus search interval; K is an integer greater than or equal to 1; Controlling the focus motor to move from the focus starting position based on a preset focus step length and a first focus search direction to obtain each target position; When the focusing motor is located at each of the target positions, acquiring each second image captured by the electronic device; The first image and each of the second images are determined as the first target images.
3. The focusing method according to claim 2, characterized in that: The focusing based on the first clustering result includes: When the number of clusters in the first clustering result is zero, an average value of the first focus positions corresponding to all the first maximum FV values is determined as a first target clear point position, and the focus motor is controlled to move to the first target clear point position; When the number of classes in the first clustering result is not equal to zero, a second target clear point position is determined based on the target focusing strategy and the center value of the class, and the focusing motor is controlled to move to the second target clear point position.
4. The focusing method according to claim 3, characterized in that: The determining, when the number of classes in the first clustering result is not equal to zero, the second target clear point position based on the target focusing strategy and the center value of the class includes: When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing to the nearest object distance or focusing to the farthest object distance, determining the distance between the center value of the class and the focus starting point position; When the distance is greater than or equal to a preset distance, determining the center value of the class as the second target clear point position; When the distance is less than the preset distance, starting from the focus starting point, a focus search is performed based on the preset focus step and the second focus search direction to obtain a second target image captured by the electronic device when the focus motor is at each second focus position; the second focus search direction is opposite to the first focus search direction; For each of the second target images, determining FV values of at least two image blocks in the second target image; For each target image block at the same position, based on the FV values of the target image blocks of all the first target images and all the second target images, determine a second maximum FV value corresponding to the target image block; Clustering the focus positions corresponding to all the second maximum FV values to obtain a second clustering result; The second target clear point position is determined based on the second clustering result.
5. The focusing method according to claim 3, characterized in that: The determining, when the number of classes in the first clustering result is not equal to zero, the second target clear point position based on the target focusing strategy and the center value of the class includes: When the number of classes in the first clustering result is equal to 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance or focusing on multiple object distances, the center value of the class is determined as the second target clear point position.
6. The focusing method according to claim 3, characterized in that: When the values of the focus position increase in sequence from the nearest object distance to the farthest object distance, determining the second target clear point position based on the target focus strategy and the center value of the class when the number of classes in the first clustering result is not equal to zero includes: In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the nearest object distance, determining the center value of the smallest class as the second target clear point position; In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing to the farthest object distance, determining the center value of the largest class as the second target clear point position; In the case where the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on the Kth object distance starting from the nearest object distance, based on the sorting of the center values of each class from small to large, the center value of the Kth class is determined as the second target clear point position; When the number of classes in the first clustering result is greater than 1 and the target focusing strategy includes focusing on multiple object distances, based on the sorting of the center values of each class from small to large, the center values of each class after sorting are sequentially determined as the second target clear point positions corresponding to the object distances from near to far.
7. The focusing method according to any one of claims 1 to 6, characterized in that: The clustering of the focus positions corresponding to all the first maximum FV values to obtain a first clustering result includes: determining a cluster radius based on a depth of focus of the electronic device; Determining a density threshold based on the number of the image blocks and a preset picture ratio; the preset picture ratio is the ratio of the target area to the first target image; The focus positions corresponding to all the first maximum FV values are clustered based on the cluster radius and the density threshold to obtain the first clustering result.
8. A focusing device, characterized in that: include: An acquisition unit, configured to perform a focus search based on a target focus strategy, and acquire a first target image captured by the electronic device when the focus motor is at each first focus position; A first determining unit, configured to determine, for each of the first target images, FV values of at least two image blocks in the first target image; A second determining unit, configured to determine, for each target image block at the same position of each of the first target images, a first maximum FV value corresponding to the target image block based on the FV values of the target image blocks of all the first target images; a clustering unit, configured to cluster the focus positions corresponding to all the first maximum FV values to obtain a first clustering result; A focusing unit is used to focus based on the first clustering result.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the focusing method according to any one of claims 1 to 7 is implemented.
10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the focusing method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Zoom lens automatic focusing region-of-interest selection method
CN120264138A
Zoom lens auto focus region of interest selection method
CN120264138B
Focusing method and apparatus, electronic device, and storage medium
EP4783600A1