Focusing Method, Device and Storage Medium in Point Light Source Scenario

By tiling the image frames in the point light source scene and brightness value processing, the target light source area and optimal focus position are determined, and the problem of inaccurate focus in the point light source scene is solved, and fast and accurate focus is achieved and calculation needs are reduced.

CN120034738BActive Publication Date: 2025-07-04ZHEJIANG HUASHI INTELLIGENT INSPECTION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510481351.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-17
Publication Date
2025-07-04
Estimated Expiration
2045-04-17

AI Technical Summary

Technical Problem

In point light source scenarios, it is difficult for the prior art to accurately determine the clearest position of the image, resulting in a failed focus.

Method used

By dividing the image frames in the point light source scene, calculate the brightness value of each tile, divide the tile with a brightness value less than the candidate threshold into the background area, and divide the tile with a brightness value not less than the candidate threshold into the light source area, calculate the brightness variance between the background area and the light source area, select the candidate threshold with the largest variance to determine the target light source area, and determine the tile position of the extremely small luminance value as the optimal focus position.

Benefits of technology

It improves the accuracy and speed of focus, reduces the amount of calculation, enhances the versatility of the algorithm, and is suitable for different image processing chips.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120034738B_ABST
    Figure CN120034738B_ABST
Patent Text Reader

Abstract

The present application discloses a focusing method, device, and storage medium in a point light source scenario. The focusing method in the point light source scenario includes: dividing a current image frame into tiles to obtain a plurality of current frame tiles; respectively using the brightness value of each current frame tile as a candidate threshold; dividing the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and dividing the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; calculating the variance of the brightness values between the candidate background regions and the candidate light source regions, and obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds; determining the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position, which can quickly and accurately divide the target light source region, improve the focusing accuracy, reduce the calculation amount, and have high algorithm generality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technologies, and particularly to a focusing method, device, and storage medium in a point light source scenario. Background Art

[0002] During the process of image acquisition and focusing, it is necessary to determine the clearest position of the image. The current mainstream method is still to find the pixel with the maximum sharpness in the continuously changing contrast information of the image through the hill climbing algorithm to determine the clearest position of the image. However, in a point light source scenario, the light source in a defocused state usually has more edge information, resulting in the position with the maximum image contrast in this scenario not necessarily being the true clear position. Therefore, simply relying on the contrast of the entire image in a point light source scenario is extremely likely to result in focusing failure.

[0003] Currently, the industry has been actively exploring the problem of accurate focusing in a point light source scenario, but there is still no completely effective solution. Summary of the Invention

[0004] To solve the above technical problems, this application provides at least a focusing method, device, and storage medium in a point light source scenario.

[0005] In the first aspect of this application, a focusing method in a point light source scenario is provided. The method includes: obtaining a current image frame obtained by image acquisition of a point light source scenario, dividing the current image frame into tiles to obtain a plurality of current frame tiles; calculating the brightness value of each current frame tile, and respectively using the brightness value of each current frame tile as a candidate threshold; dividing the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and dividing the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; calculating the variance of the brightness values between the candidate background regions and the candidate light source regions, and obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds; determining the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position.

[0006] In an embodiment, obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds includes: using the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds as the initial light source region corresponding to the current image frame; and obtaining the previous image frame corresponding to the current image frame, and obtaining the initial light source region corresponding to the previous image frame; wherein, the image acquisition time of the previous image frame is earlier than the image acquisition time of the current image frame; calculating the intersection of the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame to obtain the target light source region corresponding to the current image frame.

[0007] In one embodiment, before determining the tile position corresponding to the minimum brightness value in the target light source area of the current image frame to obtain the best focus position, the method further includes: obtaining a previous image frame corresponding to the current image frame; taking any current frame tile in the target light source area of the current image frame as a tile to be detected, determining the tile in the previous image frame that is in the same position as the tile to be detected to obtain a previous reference tile; calculating the change amplitude between the brightness value of the tile to be detected and the brightness value of the previous reference tile; if the change amplitude is greater than a preset amplitude threshold, correcting the brightness value of the tile to be detected.

[0008] In one embodiment, any of the following strategies is adopted to correct the brightness value of the tile to be detected: Strategy 1: performing weighted summation on the brightness value of the previous reference tile and the brightness value of the tile to be detected to obtain the corrected brightness value of the tile to be detected; Strategy 2: obtaining the current frame tiles adjacent to the tile to be detected in the current image frame to obtain adjacent tiles, performing weighted summation on the brightness values of the adjacent tiles and the tile to be detected to obtain the corrected brightness value of the tile to be detected; Strategy 3: obtaining the current frame tiles adjacent to the tile to be detected in the current image frame to obtain adjacent tiles, performing weighted summation on the brightness values of the adjacent tiles and the tile to be detected to obtain the current total brightness; performing weighted summation on the brightness value of the previous reference tile and the current total brightness to obtain the corrected brightness value of the tile to be detected.

[0009] In one embodiment, performing weighted summation on the brightness values of the adjacent tiles and the tile to be detected includes: determining the distance between the adjacent tile and the tile to be detected; respectively setting weight parameters corresponding to the adjacent tile and the tile to be detected based on the distance and / or the magnitude of the change amplitude; performing weighted summation on the brightness values of the adjacent tile and the tile to be detected based on the weight parameters.

[0010] In one embodiment, the number of strategies for correcting the brightness value of the tile to be detected is multiple; correcting the brightness value of the tile to be detected includes: selecting a matching strategy from the multiple strategies based on the magnitude of the change amplitude to obtain a target strategy; using the target strategy to correct the brightness value of the tile to be detected.

[0011] In one embodiment, determining the tile position corresponding to the minimum brightness value in the target light source area to obtain the best focus position includes: respectively recording the current movement position and the current movement direction of the focusing motor as a first motor position and a first movement direction, and detecting the change trend of the brightness value of the current frame tile in the target light source area in the first movement direction; if the change trend is a downward trend, continuing to move in the first movement direction to a second motor position; detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value; if the brightness value of the current frame tile corresponding to the second motor position is a minimum value, taking the second motor position as the best focus position.

[0012] In one embodiment, detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value includes: detecting the change trend of the brightness values corresponding to each movement direction of the second motor position, and if there is no downward trend, determining that the brightness value of the current frame tile corresponding to the second motor position is a minimum value.

[0013] The second aspect of the present application provides a focusing device in a point light source scenario. The device includes: a tile division module, configured to obtain a current image frame obtained by image acquisition of the point light source scenario, and perform tile division on the current image frame to obtain a plurality of current frame tiles; a candidate threshold selection module, configured to calculate the brightness value of each current frame tile, and respectively use the brightness value of each current frame tile as a candidate threshold; a region division module, configured to divide the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and divide the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; a target region determination module, configured to calculate the variance of the brightness values between the candidate background region and the candidate light source region, and obtain the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among a plurality of candidate thresholds; a focusing module, configured to determine the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position.

[0014] The third aspect of the present application provides an electronic device, including a memory and a processor, and the processor is configured to execute program instructions stored in the memory to implement the above-mentioned focusing method in a point light source scenario.

[0015] The fourth aspect of the present application provides a computer-readable storage medium, on which program instructions are stored, and when the program instructions are executed by a processor, the above-mentioned focusing method in a point light source scenario is implemented.

[0016] In the above solution, by obtaining a current image frame obtained by image acquisition of a point light source scenario, performing tile division on the current image frame to obtain a plurality of current frame tiles; calculating the brightness value of each current frame tile, and respectively using the brightness value of each current frame tile as a candidate threshold; dividing the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and dividing the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; calculating the variance of the brightness values between the candidate background region and the candidate light source region, and obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among a plurality of candidate thresholds; determining the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position, it is possible to quickly and accurately select the target light source region divided under the optimal threshold, improve the focusing accuracy, quickly achieve focusing, while reducing the amount of calculation, and since the algorithm has low requirements for the chip capabilities, the generality of the algorithm is enhanced.

[0017] It should be understood that the above general description and the following detailed description are merely exemplary and explanatory, and do not limit this application. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings herein are incorporated into and constitute a part of this specification. These drawings show embodiments consistent with this application and, together with the specification, are used to explain the technical solutions of this application.

[0019] Figure 1 is a schematic diagram of the solution implementation environment shown in an exemplary embodiment of this application;

[0020] Figure 2 is a flowchart of the focusing method in a point light source scenario shown in an exemplary embodiment of this application;

[0021] Figure 3 is a flowchart of determining the optimal threshold shown in an exemplary embodiment of this application;

[0022] Figure 4 is a schematic diagram of determining the target light source area shown in an exemplary embodiment of this application;

[0023] Figure 5 is a schematic diagram of correcting the brightness value according to the previous image frame and adjacent tiles shown in an exemplary embodiment of this application;

[0024] Figure 6 is a block diagram of the focusing device in a point light source scenario shown in an exemplary embodiment of this application;

[0025] Figure 7 is a schematic diagram of the structure of an electronic device shown in an exemplary embodiment of this application;

[0026] Figure 8 is a schematic diagram of the structure of a computer-readable storage medium shown in an exemplary embodiment of this application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The solutions of the embodiments of this application will be described in detail below with reference to the drawings in the specification.

[0028] In the following description, specific details such as specific system architectures, interfaces, and technologies are set forth for the purpose of illustration and not limitation, so as to thoroughly understand this application.

[0029] As used herein, the term "and / or" is merely an association information describing associated objects, indicating that there can be three relationships. For example, A and / or B can represent three cases: A exists alone, A and B exist simultaneously, and B exists alone. In addition, the character " / " in this text generally indicates that the associated objects before and after are in an "or" relationship. Furthermore, "plurality" in this text means two or more than two. Additionally, the term "at least one" in this text means any one of a plurality or any combination of at least two of a plurality. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set composed of A, B, and C.

[0030] In the related art, if there is a point light source in the captured image, generally, it is determined whether there is a point light source in the image area by counting the number of highlighted pixels in a single image area. This requires the image processing chip itself to provide the number of highlighted pixels and requires a large number of image blocks obtained by the image processing chip to divide the image. However, limited by the capabilities of different image processing chips, not all image processing chips have the ability to provide the number of highlighted pixels and the ability to perform a large number of image blocks. When the number of image blocks on the chip side is small and the information provided is small, the point light source area determined by the above method is not accurate, and the generality of the above method is poor.

[0031] Based on this, the present application provides a focusing method in a point light source scenario with stronger generality. The focusing method in the point light source scenario provided by the embodiments of the present application will be described below.

[0032] Please refer to Figure 1 , Figure 1 is a schematic diagram of the implementation environment of the solution shown in an exemplary embodiment of the present application. The implementation environment of the solution may include an image acquisition device 110 and a server 120, and the image acquisition device 110 and the server 120 are communicatively connected to each other.

[0033] The number of image acquisition devices 110 can be used to perform image acquisition. The image acquisition device 110 can be a camera, a smart phone, a tablet computer, a smart watch, etc., but is not limited thereto.

[0034] The server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, Content Delivery Network (CDN), and big data and artificial intelligence platforms.

[0035] In one example, the server 120 can determine the best focus position based on the current image frame obtained from the image acquisition device 110, and then the server 120 can transmit the best focus position back to the image acquisition device 110.

[0036] In one example, a client of a target application is installed and running in the image acquisition device 110. The target application can be an application that provides the best focus position calculation function, and the best focus position is calculated based on this target application. The server 120 can be the background server of this target application, used to provide background services for the client of this target application.

[0037] For the focusing method in the point light source scenario provided by the embodiments of the present application, the execution entity of each step can be the image acquisition device 110, such as the client of the target application installed and running in the image acquisition device 110, or the server 120, or executed by the interaction and cooperation of the image acquisition device 110 and the server 120, that is, part of the steps of the method are executed by the image acquisition device 110 and the other part of the steps are executed by the server 120.

[0038] Please refer to Figure 2 , Figure 2 which is a flowchart of the focusing method in the point light source scenario shown in an exemplary embodiment of the present application. The focusing method in the point light source scenario can be applied to Figure 1 the implementation environment shown, and is specifically executed by the image acquisition device in this implementation environment. It should be understood that this method can also be applicable to other exemplary implementation environments and be specifically executed by devices in other implementation environments. This embodiment does not limit the implementation environment applicable to this method.

[0039] As Figure 2 shown, the focusing method in the point light source scenario at least includes steps S210 to S250, which are introduced in detail as follows:

[0040] Step S210: Obtain the current image frame obtained by image acquisition of the point light source scenario, and perform tile division on the current image frame to obtain multiple current frame tiles.

[0041] The image acquisition device performs image acquisition in the point light source scenario. At this time, the image frame obtained by acquisition contains a point light source, and the currently acquired image frame is used as the current image frame.

[0042] Perform tile division on the current image frame to obtain multiple current frame tiles.

[0043] It should be noted that the sizes of the current frame tiles divided by different image processing chips can be different. For example, it can be to perform The tile division may also be performed on the current image frame tile division.

[0044] Step S220: Calculate the brightness value of each current frame tile, and use the brightness value of each current frame tile as a candidate threshold respectively.

[0045] For each current frame tile, calculate the corresponding brightness value. For example, calculate the sum of the brightness values of each pixel in the current frame tile to obtain the corresponding brightness value of the current frame tile; or calculate the average value between the brightness values of each pixel in the current frame tile to obtain the corresponding brightness value of the current frame tile.

[0046] Obtain the brightness value of each current frame tile, and use the brightness value of each current frame tile as a candidate threshold in sequence.

[0047] For example, obtain an image histogram from the brightness values of each current frame tile, start from the minimum brightness value in the image histogram, and sequentially use each brightness value as a candidate threshold in order until the maximum brightness value.

[0048] Step S230: Divide the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and divide the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions.

[0049] Perform a region division for each candidate threshold. Specifically, divide the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and divide the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions.

[0050] For example, if the currently selected candidate threshold is 100, then divide the current frame tiles with brightness values less than 100 into candidate background regions, and divide the current frame tiles with brightness values not less than 100 into candidate light source regions.

[0051] Step S240: Calculate the variance of the brightness values between the candidate background region and the candidate light source region, and obtain the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds.

[0052] In the above manner, each candidate threshold divides a candidate background region and a candidate light source region. For any candidate threshold, calculate the variance of the brightness values between the candidate background region and the candidate light source region corresponding to this candidate threshold, and determine the candidate threshold with the largest variance among multiple candidate thresholds. Use the candidate threshold with the largest variance as the optimal threshold.

[0053] Exemplarily, please refer to Figure 3 , Figure 3 is a flowchart for determining the optimal threshold shown in an exemplary embodiment of the present application. AsFigure 3 As shown in the figure, it includes:

[0054] Step S310: Obtain the image histogram from the luminance values of each current frame block, and initialize the value of the maximum variance to 0;

[0055] Step S320: Starting from the minimum luminance value in the image histogram, traverse each luminance value in the image histogram in sequence as a candidate threshold;

[0056] Step S330: Calculate the variance of the luminance values between the candidate background region and the candidate light source region corresponding to the currently traversed candidate threshold;

[0057] Step S340: Whether the variance of the luminance values between the candidate background region and the candidate light source region is greater than the maximum variance. If so, execute Step S350; if not, execute Step S360;

[0058] Step S350: Assign the variance of the luminance values between the candidate background region and the candidate light source region to the maximum variance, and record the candidate threshold corresponding to the maximum variance;

[0059] Step S360: Whether each luminance value in the image histogram has been traversed. If not, execute S320; if so, execute Step S370;

[0060] Step S370: Output the candidate threshold corresponding to the maximum variance as the optimal threshold.

[0061] Among them, the specific calculation method of the variance of the luminance values between the candidate background region and the candidate light source region is shown in the following Formulas 1 to 3:

[0062] Formula 1:

[0063] Formula 2:

[0064] Formula 3:

[0065] Among them, Variance is the variance of the luminance values between the candidate background region and the candidate light source region; W0 is the number of current frame blocks included in the candidate background region; W1 is the number of current frame blocks included in the candidate light source region; T0 is the average value between the luminance values corresponding to each current frame block within the candidate background region; T1 is the average value between the luminance values corresponding to each current frame block within the candidate light source region; Tavg is the average luminance of the current image frame.

[0066] Of course, other variance calculation algorithms can also be used to calculate the variance of the luminance values between the candidate background region and the candidate light source region, and this application does not limit this.

[0067] Optionally, when determining the optimal threshold, in addition to considering the variance of the luminance values between the candidate background region and the candidate light source region, the variance of the luminance values within the candidate background region and the variance of the luminance values within the candidate light source region can also be further considered. The optimal threshold can be selected from multiple candidate thresholds with the condition that the variance of the luminance values within the candidate background region and the candidate light source region is minimized, while the variance of the luminance values between the candidate background region and the candidate light source region is maximized.

[0068] Then, based on the candidate light source region corresponding to the optimal threshold, the target light source region corresponding to the current image frame is obtained. For example, the candidate light source region corresponding to the optimal threshold can be directly used as the target light source region corresponding to the current image frame; or, for another example, after adjusting the candidate light source region corresponding to the optimal threshold with reference to other image frames, the target light source region corresponding to the current image frame is obtained. For specific implementation manners, refer to the embodiments listed later.

[0069] Step S250: Determine the tile position corresponding to the minimum luminance value in the target light source region corresponding to the current image frame to obtain the best focus position.

[0070] After obtaining the target light source region corresponding to the current image frame, determine the tile position corresponding to the minimum luminance value in the target light source region and use it as the best focus position.

[0071] For example, the tile position corresponding to the current frame tile with the minimum luminance value in the target light source region corresponding to the current image frame can be directly used as the best focus position; it is also possible to detect the change trend of the luminance values of the tile positions passed during the gradual movement of the focusing motor, determine the tile position corresponding to the minimum luminance value in the target light source region corresponding to the currently captured current image frame, and obtain the best focus position. The present application does not limit this.

[0072] The focusing method in the point light source scenario disclosed in the present application divides the candidate light source region and the candidate background region by sequentially selecting the luminance value corresponding to the current frame tile as the subsequent threshold, and then sequentially determines the variance of the luminance values between the candidate background region and the candidate light source region, which can accurately select the light source region divided under the optimal threshold, improve the focusing accuracy, and generally there are tiles with the same luminance value in the current image frame. Therefore, the calculation amount can be reduced and the focusing can be quickly realized. In addition, the algorithm has low requirements for the chip capability, which can enhance the generality of the algorithm.

[0073] Next, some embodiments of the present application will be described in detail by way of examples.

[0074] In some embodiments, in step S240, to obtain the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds, the method includes: taking the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds as the initial light source region corresponding to the current image frame; and obtaining the previous image frame corresponding to the current image frame, and obtaining the initial light source region corresponding to the previous image frame, where the image acquisition time of the previous image frame is earlier than that of the current image frame; calculating the intersection of the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame to obtain the target light source region corresponding to the current image frame.

[0075] Considering that point light sources in a point light source scenario are prone to changes (such as flickering lights or fast-moving vehicle lights), to improve focusing accuracy, the candidate light source region corresponding to the optimal threshold is adjusted based on the previous image frame.

[0076] Specifically, taking the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds as the initial light source region corresponding to the current image frame, and obtaining the previous image frame acquired before the current image frame, and obtaining the initial light source region corresponding to the previous image frame in the same way. Both the initial light source region corresponding to the current image frame and the previous image frame contain multiple tiles. Take the intersection of the tiles in the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame to obtain the target light source region corresponding to the current image frame.

[0077] For example, after obtaining the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame, detect whether the tiles at the same position are both included in the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame. If they are both included, retain the current tile at this position in the current image frame. Detect whether each current tile in the initial light source region corresponding to the current image frame is retained in the above manner, and merge all the current tiles that need to be retained to obtain the target light source region corresponding to the current image frame.

[0078] For illustration, please refer to Figure 4 , Figure 4 which is a schematic diagram of determining the target light source region shown in an exemplary embodiment of the present application. As Figure 4 shown, after taking the intersection of the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame, the target light source region corresponding to the current image frame is obtained.

[0079] It should be noted that Figure 4For illustrative purposes, only one previous image frame is taken as an example. In actual application scenarios, more previous image frames can be selected to determine the target light source area, and the present application does not limit this.

[0080] Optionally, the number of previous image frames to be acquired can also be flexibly determined according to the actual situation of the current image frame. For example, the number of previous image frames to be acquired is determined according to the average brightness of the current image frame and / or the number of current frame blocks included in the initial light source area corresponding to the current image frame. Among them, the average brightness of the current image frame, the number of current frame blocks in the initial light source area corresponding to the current image frame, and the number of previous image frames to be acquired are in direct proportion.

[0081] Of course, in addition to flexibly calculating the number of previous image frames according to parameters such as the average brightness of the current image frame and the number of current frame blocks in the initial light source area corresponding to the current image frame in the above embodiments, the number of previous image frames to be acquired can also be preset according to experience, and the present application does not limit this.

[0082] Through the above embodiments, the interference of the flickering light source can be avoided, a more accurate target light source area can be obtained, which is convenient for subsequent focusing.

[0083] In some embodiments, before determining the block position corresponding to the minimum brightness value in the target light source area corresponding to the current image frame to obtain the best focusing position, it further includes: acquiring the previous image frame corresponding to the current image frame; taking any current frame block in the target light source area corresponding to the current image frame as the to-be-detected block, and determining the block in the previous image frame that is in the same position as the to-be-detected block to obtain the previous reference block; calculating the change amplitude between the brightness value of the to-be-detected block and the brightness value of the previous reference block; if the change amplitude is greater than the preset amplitude threshold, correcting the brightness value of the to-be-detected block.

[0084] Among them, the preset amplitude threshold is preset according to experience.

[0085] Considering that the brightness of the light source in the environment may change, in order to improve the stability of focusing, the brightness information of the current frame blocks in the target light source area is judged for fluctuations with reference to the previous image frame, and the brightness values of the current frame blocks with large change amplitudes are corrected.

[0086] Exemplarily, any of the following strategies is adopted to correct the brightness value of the to-be-detected block:

[0087] Strategy 1: Perform weighted summation on the brightness value of the previous reference block and the brightness value of the to-be-detected block to obtain the corrected brightness value of the to-be-detected block.

[0088] Among them, the number of previous reference blocks can be one or more.

[0089] Perform a weighted sum of the luminance values of the previous reference patch and the patch to be detected to obtain the corrected luminance value of the patch to be detected.

[0090] When performing the weighted sum of the luminance values of the previous reference patch and the patch to be detected, the weight parameters used can be preset. For example, the weight parameter for the luminance value of the previous reference patch is 0.4, and the weight parameter for the luminance value of the patch to be detected is 0.6. It is also possible to calculate the time interval between the image acquisition time of the previous reference patch and the image acquisition time of the patch to be detected, and / or obtain the magnitude of the change, and set the weight parameters corresponding to the luminance values of the previous reference patch and the patch to be detected according to the time interval and / or the magnitude of the change. For example, the smaller the time interval and the larger the magnitude of the change, the larger the weight parameter corresponding to the luminance value of the previous reference patch and the smaller the weight parameter corresponding to the luminance value of the patch to be detected; conversely, the larger the time interval and the smaller the magnitude of the change, the smaller the weight parameter corresponding to the luminance value of the previous reference patch and the larger the weight parameter corresponding to the luminance value of the patch to be detected.

[0091] Perform a weighted sum of the luminance values of the previous reference patch and the patch to be detected based on the weight parameters to obtain the corrected luminance value of the patch to be detected.

[0092] Strategy 2: Obtain the current frame patches adjacent to the patch to be detected in the current image frame to get the adjacent patches, and perform a weighted sum of the luminance values of the adjacent patches and the patch to be detected to obtain the corrected luminance value of the patch to be detected.

[0093] Use the current frame patches in the current image frame whose distance from the patch to be detected is less than the distance threshold as the adjacent patches corresponding to the patch to be detected. Here, the distance threshold can be preset according to experience or flexibly set according to the magnitude of the change. The larger the magnitude of the change, the larger the distance threshold; the smaller the magnitude of the change, the smaller the distance threshold.

[0094] Perform a weighted sum of the luminance values of the adjacent patches and the patch to be detected to obtain the corrected luminance value of the patch to be detected.

[0095] When performing weighted summation on the luminance values of adjacent blocks and the luminance value of the block to be detected, the weight parameters used can be preset. For example, the weight parameter for the luminance value of the adjacent block is 0.1, and the weight parameter for the luminance value of the block to be detected is 0.4. It is also possible to calculate the distance between the adjacent block and the block to be detected, and / or obtain the magnitude of the change, and set the weight parameters corresponding to the luminance values of the adjacent block and the block to be detected according to the distance and / or the magnitude of the change. For example, the smaller the distance and the larger the magnitude of the change, the larger the weight parameter corresponding to the luminance value of the adjacent block and the smaller the weight parameter corresponding to the luminance value of the block to be detected; conversely, the larger the distance and the smaller the magnitude of the change, the smaller the weight parameter corresponding to the luminance value of the adjacent block and the larger the weight parameter corresponding to the luminance value of the block to be detected.

[0096] Based on the weight parameters, perform weighted summation on the luminance values of the adjacent block and the block to be detected to obtain the corrected luminance value of the block to be detected.

[0097] Strategy three: Obtain the current frame block adjacent to the block to be detected in the current image frame to get the adjacent block, perform weighted summation on the luminance values of the adjacent block and the block to be detected to obtain the current luminance sum; perform weighted summation on the luminance value of the previous reference block and the current luminance sum to obtain the corrected luminance value of the block to be detected.

[0098] Taking into account the luminance information of the previous image frame and the adjacent block at the same time, perform weighted summation on the luminance values of the adjacent block, the previous reference block, and the block to be detected to obtain the corrected luminance value of the block to be detected.

[0099] The setting method of the weight parameters used in the weighted summation in Strategy three can refer to the setting methods of the weight parameters in Strategy one and Strategy two, which will not be elaborated here.

[0100] For example, please refer to Figure 5 , Figure 5 which is a schematic diagram showing the correction of the luminance value according to the previous image frame and the adjacent block shown in an exemplary embodiment of the present application. As Figure 5 shown, the luminance value of the block to be detected is Ycur, the luminance value of the previous reference block is Ylast, and the luminance values of the adjacent blocks include Y1, Y2, Y3, Y4, Y5, Y6, Y7, and Y8 respectively.

[0101] Assume that the weight parameters corresponding to Y2, Y4, Y5, and Y7 are 0.1, the weight parameters corresponding to Y1, Y3, Y6, and Y8 are 0.05, and the weight parameter corresponding to Ycur is 0.4. Then, the specific calculation formula for performing weighted summation on the luminance values of the adjacent block and the block to be detected to obtain the current luminance sum is shown in the following formula 4:

[0102]

[0103] Among them, Yall is the current total brightness.

[0104] Assume that the weight parameter corresponding to Ylast is 0.4, the weight parameter corresponding to Yall is 0.05, and the weight parameter corresponding to Ycur is 0.6. Then, a weighted sum is performed on the brightness value of the previous reference patch and the current total brightness to obtain the specific calculation formula for the corrected brightness value of the patch to be detected as shown in the following formula 5:

[0105]

[0106] Among them, Y is the corrected brightness value of the patch to be detected.

[0107] Optionally, if the adjacent patch does not belong to the target light source area, the brightness value of the adjacent patch can be set to 0 for calculation.

[0108] The above strategies correct the brightness value of the current frame patch in the target light source area based on the adjacent patch and / or the previous reference patch, avoiding unstable focus search caused by large amplitude of brightness change and reducing the focus accuracy.

[0109] In some embodiments, the number of strategies for correcting the brightness value of the patch to be detected is multiple; correcting the brightness value of the patch to be detected includes: selecting a matching strategy from multiple strategies according to the magnitude of the change amplitude to obtain a target strategy; using the target strategy to correct the brightness value of the patch to be detected.

[0110] The parameters considered by different strategies can be different. For example, the first strategy corrects the brightness value according to the brightness value of the previous reference patch, the second strategy corrects the brightness value according to the brightness value of the adjacent patch, and the third strategy corrects the brightness value by combining the brightness values of the previous reference patch and the adjacent patch; the weight coefficients corresponding to different strategies can be different, and the number of previous reference patches and / or adjacent patches selected by different strategies can be different. The present application does not limit this.

[0111] Select a matching strategy from multiple strategies according to the magnitude of the change amplitude to obtain a target strategy. For example, the strategies for correcting the brightness value of the patch to be detected include the above first strategy, second strategy, and third strategy. When the detected change amplitude is greater than the preset amplitude threshold, strategy selection is performed: if the change amplitude is less than the first abnormal threshold, select the first strategy as the target strategy; if the change amplitude is less than the second abnormal threshold and greater than the first abnormal threshold, select the second strategy as the target strategy; if the change amplitude is less than the third abnormal threshold and greater than the second abnormal threshold, select the third strategy as the target strategy.

[0112] Determining the target strategy according to the change range can improve the accuracy of brightness correction and further reduce the calculation amount.

[0113] In some embodiments, determining the tile position corresponding to the minimum brightness value in the target light source area in step S250 to obtain the best focusing position includes: recording the current movement position and the current movement direction of the focusing motor as the first motor position and the first movement direction respectively, and detecting the change trend of the brightness value of the current frame tile in the target light source area in the first movement direction; if the change trend is a downward trend, continue to move in the first movement direction to the second motor position; detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value; if the brightness value of the current frame tile corresponding to the second motor position is a minimum value, then take the second motor position as the best focusing position.

[0114] The focusing motor initially moves along the first movement direction by default from the first motor position, and detects the change trend of the brightness value of the current frame tile in the target light source area in the first movement direction. For example, if the brightness value of the nearest current frame tile in the target light source area in the first movement direction is less than the brightness value of the first motor position, then the change trend is a downward trend; if the brightness value of the nearest current frame tile in the target light source area in the first movement direction is not less than the brightness value of the first motor position, then the change trend is not a downward trend.

[0115] If the change trend is a downward trend, continue to move in the first movement direction to the second motor position.

[0116] If the change trend is not a downward trend, take a movement direction different from the first movement direction as the second movement direction, and continue to detect whether the change trend of the brightness value of the current frame tile in the target light source area in the second movement is a downward trend until a movement direction with a downward trend is detected, and move in the movement direction with the downward trend to the second motor position.

[0117] Detect whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value. If the brightness value of the current frame tile corresponding to the second motor position is a minimum value, then take the second motor position as the best focusing position; if the brightness value of the current frame tile corresponding to the second motor position is not a minimum value, continue to move in the above manner until a minimum value is detected.

[0118] Exemplarily, detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value includes: detecting the change trend of the brightness values corresponding to each movement direction of the second motor position. If there is no downward trend, it is determined that the brightness value of the current frame tile corresponding to the second motor position is a minimum value.

[0119] The focusing method in the point light source scenario provided by this application obtains the current image frame obtained by image acquisition of the point light source scenario, divides the current image frame into tiles to obtain multiple current frame tiles; calculates the brightness value of each current frame tile, and respectively uses the brightness value of each current frame tile as a candidate threshold; divides the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and divides the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; calculates the variance of the brightness values between the candidate background region and the candidate light source region, and based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds, obtains the target light source region corresponding to the current image frame; determines the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position, can quickly and accurately select the target light source region divided under the optimal threshold, improve the focusing accuracy, quickly achieve focusing, reduce the calculation amount at the same time, and because the algorithm has low requirements for the chip ability, the versatility of the algorithm is enhanced.

[0120] Figure 6 is a block diagram of a focusing device in a point light source scenario shown in an exemplary embodiment of this application. As Figure 6 shown, the exemplary focusing device 600 in the point light source scenario includes:

[0121] A tile division module 610, configured to obtain the current image frame obtained by image acquisition of the point light source scenario, and divide the current image frame into tiles to obtain multiple current frame tiles;

[0122] A candidate threshold selection module 620, configured to calculate the brightness value of each current frame tile, and respectively use the brightness value of each current frame tile as a candidate threshold;

[0123] A region division module 630, configured to divide the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and divide the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions;

[0124] A target region determination module 640, configured to calculate the variance of the brightness values between the candidate background region and the candidate light source region, and based on the candidate light source region corresponding to the candidate threshold with the largest variance among multiple candidate thresholds, obtain the target light source region corresponding to the current image frame;

[0125] A focusing module 650, configured to determine the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position.

[0126] It should be noted that the focusing device in the point light source scenario provided by the above embodiments and the focusing method in the point light source scenario provided by the above embodiments belong to the same concept. The specific ways in which each module and unit perform operations have been described in detail in the method embodiments and will not be repeated here. In practical applications, the focusing device in the point light source scenario provided by the above embodiments can, as needed, allocate the above functions to different functional modules, that is, divide the internal structure of the device into different functional modules to complete all or part of the functions described above, and this is not limited herein.

[0127] Please refer to Figure 7 , Figure 7 which is a schematic structural diagram of an embodiment of an electronic device of the present application. The electronic device 700 includes a memory 701 and a processor 702. The processor 702 is configured to execute program instructions stored in the memory 701 to implement the steps in any of the above embodiments of the focusing method in the point light source scenario. In a specific implementation scenario, the electronic device 700 may include, but is not limited to, a microcomputer, a server. In addition, the electronic device 700 may also include mobile devices such as a laptop computer, a tablet computer, etc., which are not limited herein.

[0128] Specifically, the processor 702 is configured to control itself and the memory 701 to implement the steps in any of the above embodiments of the focusing method in the point light source scenario. The processor 702 may also be referred to as a Central Processing Unit (CPU). The processor 702 may be an integrated circuit chip with signal processing capabilities. The processor 702 may also be a general-purpose processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Additionally, the processor 702 may be implemented jointly by integrated circuit chips.

[0129] Please refer to Figure 8 , Figure 8 which is a schematic structural diagram of an embodiment of a computer-readable storage medium of the present application. The computer-readable storage medium 800 stores program instructions 810 that can be run by a processor. The program instructions 810 are used to implement the steps in any of the above embodiments of the focusing method in the point light source scenario.

[0130] In some embodiments, the functions or modules included in the apparatus provided by the embodiments of the present disclosure can be used to execute the methods described in the above method embodiments. The specific implementation can refer to the description of the above method embodiments. For the sake of brevity, it will not be repeated here.

[0131] The above descriptions of the various embodiments tend to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to each other. For the sake of brevity, they will not be repeated in this article.

[0132] In several embodiments provided in the present application, it should be understood that the disclosed methods and apparatuses can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of modules or units is only a logical function division. In actual implementation, there may be other division methods. For example, units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed coupling or direct coupling or communication connection between each other can be through some interfaces. The indirect coupling or communication connection of the apparatus or unit can be in electrical, mechanical or other forms.

[0133] In addition, in each embodiment of the present application, the functional units can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software functional units. If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present 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. The computer software product is stored in a storage medium and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) or a processor to execute all or part of the steps of the methods of the various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical discs that can store program codes.

Claims

1. A focusing method in a point light source scenario, characterized in that The method includes: Obtaining a current image frame obtained by performing image acquisition on a point light source scene, performing tile division on the current image frame to obtain a plurality of current frame tiles; Calculating the brightness value of each current frame tile, and respectively using the brightness value of each current frame tile as a candidate threshold; Dividing the current frame tiles with brightness values less than the candidate threshold into candidate background regions, and dividing the current frame tiles with brightness values not less than the candidate threshold into candidate light source regions; Calculating the variance of the brightness values between the candidate background region and the candidate light source region, and obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds; Determining the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position.

2. The method according to claim 1, wherein The obtaining the target light source region corresponding to the current image frame based on the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds includes: Taking the candidate light source region corresponding to the candidate threshold with the largest variance among the multiple candidate thresholds as the initial light source region corresponding to the current image frame; and, obtaining the previous image frame corresponding to the current image frame, and obtaining the initial light source region corresponding to the previous image frame; wherein, the image acquisition time of the previous image frame is earlier than the image acquisition time of the current image frame; Calculating the intersection of the initial light source region corresponding to the current image frame and the initial light source region corresponding to the previous image frame to obtain the target light source region corresponding to the current image frame.

3. The method according to claim 1, characterized in that Before the determining the tile position corresponding to the minimum brightness value in the target light source region corresponding to the current image frame to obtain the best focusing position, it further includes: Obtaining the previous image frame corresponding to the current image frame; Taking any current frame tile in the target light source region corresponding to the current image frame as a to-be-detected tile, and determining the tile in the previous image frame that is in the same position as the to-be-detected tile to obtain a previous reference tile; Calculating the change amplitude between the brightness value of the to-be-detected tile and the brightness value of the previous reference tile; If the change amplitude is greater than a preset amplitude threshold, then correcting the brightness value of the to-be-detected tile.

4. The method according to claim 3, characterized in that The brightness value of the to-be-detected tile is corrected by using any one of the following strategies: Strategy 1: Performing weighted summation on the brightness value of the previous reference tile and the brightness value of the to-be-detected tile to obtain the corrected brightness value of the to-be-detected tile; Strategy 2: Obtaining the current frame tiles adjacent to the to-be-detected tile in the current image frame to obtain adjacent tiles, performing weighted summation on the brightness values of the adjacent tiles and the to-be-detected tile to obtain the corrected brightness value of the to-be-detected tile; Strategy 3: Obtaining the current frame tiles adjacent to the to-be-detected tile in the current image frame to obtain adjacent tiles, performing weighted summation on the brightness values of the adjacent tiles and the to-be-detected tile to obtain the current total brightness; performing weighted summation on the brightness value of the previous reference tile and the current total brightness to obtain the corrected brightness value of the to-be-detected tile.

5. The method according to claim 4, characterized in that, Performing weighted summation on the brightness values of the adjacent tile and the tile to be detected includes: Determining the distance between the adjacent tile and the tile to be detected; Based on the distance and / or the magnitude of the change range, respectively setting weight parameters corresponding to the adjacent tile and the tile to be detected; Performing weighted summation on the brightness values of the adjacent tile and the tile to be detected based on the weight parameters.

6. The method according to claim 3, wherein The number of strategies for correcting the brightness value of the tile to be detected is multiple; correcting the brightness value of the tile to be detected includes: Selecting a matching strategy from multiple strategies based on the magnitude of the change range to obtain a target strategy; Using the target strategy to correct the brightness value of the tile to be detected.

7. The method according to claim 1, characterized in that Determining the tile position corresponding to the minimum brightness value in the target light source area corresponding to the current image frame to obtain the best focus position includes: Recording the current movement position and the current movement direction of the focusing motor as the first motor position and the first movement direction respectively, and detecting the change trend of the brightness value of the current frame tile in the target light source area in the first movement direction; If the change trend is a downward trend, continue to move in the first movement direction to the second motor position; Detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value; If the brightness value of the current frame tile corresponding to the second motor position is a minimum value, taking the second motor position as the best focus position.

8. The method according to claim 7, wherein Detecting whether the brightness value of the current frame tile corresponding to the second motor position is a minimum value includes: Detecting the change trend of the brightness values corresponding to each movement direction of the second motor position, and if there is no downward trend, determining that the brightness value of the current frame tile corresponding to the second motor position is a minimum value.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor, and the processor is configured to execute program instructions stored in the memory to implement the steps in the method according to any one of claims 1-8.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores program instructions, and the program instructions can be executed by a processor to implement the steps in the method according to any one of claims 1-8.

Citation Information

Patent Citations

  • Focusing for point light source scene

    US20170019582A1

  • Control apparatus, imaging apparatus, control method, and storage medium

    US20200228721A1