Autofocus methods, apparatus, devices, chips, and media
By performing cascaded downsampling and resolution synthesis on the original images from the image acquisition device, the problem of noise interference in phase detection focusing technology is solved, thereby improving the focusing success rate and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- XIAN UNISOC TECH CO LTD
- Filing Date
- 2026-04-20
- Publication Date
- 2026-06-16
AI Technical Summary
Existing phase detection autofocus technology is susceptible to noise interference and has poor reliability of phase difference, which increases the possibility of focusing failure.
By cascading downsampling the original images acquired by the image acquisition device, sampled images at different resolutions are generated, the reference phase difference at each resolution is determined, and the target phase difference is determined by combining the reference phase differences at different resolutions, thereby performing focus control.
It improves the focus success rate by reducing interference information in the sampled image, enhancing the accuracy and reliability of the reference phase difference and target phase difference, and ensuring the accuracy of focus control.
Smart Images

Figure CN122227073A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image processing technology, and in particular to an autofocus method, apparatus, device, chip, and medium. Background Technology
[0002] Currently, camera performance has become the most important part of smartphones. To achieve excellent photographic results, not only do you need megapixels, but accurate autofocus is also crucial.
[0003] The commonly used focusing method is phase detection autofocus, which determines the focal plane offset by comparing the phase difference between the left and right pixel signals. Based on this offset, the focusing motor is controlled to move the lens toward or away from the image sensor, thus achieving focus control. However, current phase detection autofocus technology is susceptible to noise interference, and the reliability of the phase difference is relatively poor, potentially leading to focusing failure. Summary of the Invention
[0004] Therefore, it is necessary to provide an autofocus method, apparatus, device, chip, and medium that can improve the autofocus success rate in response to the above-mentioned technical problems.
[0005] In a first aspect, this application provides an automatic focusing method, comprising: determining an image to be processed corresponding to an original image acquired by an image acquisition device; wherein the image to be processed includes a left image and a right image; performing cascaded downsampling on the image to be processed to obtain sampled images of the image to be processed at different resolutions; determining a reference phase difference at a corresponding resolution based on the sampled images at the same resolution; determining a target phase difference based on the reference phase differences at different resolutions; and performing focusing control on the image acquisition device based on the target phase difference.
[0006] In one embodiment, different resolutions include a first resolution and a second resolution other than the first resolution; the first resolution is the lowest resolution; correspondingly, determining the reference phase difference at the corresponding resolution based on each sampled image at the same resolution includes: determining the reference phase difference at the first resolution based on each sampled image at the first resolution; for each second resolution, determining the phase difference search range at the second resolution based on the reference phase difference at the adjacent lower resolution; and searching within the phase difference search range at the second resolution based on each sampled image at the second resolution to obtain the reference phase difference at the second resolution.
[0007] In one embodiment, determining the reference phase difference at a first resolution based on each sampled image at a first resolution includes: generating at least one image block corresponding to each sampled image at the first resolution according to a preset window size; the image block includes a left image block corresponding to a left image and a right image block corresponding to a right image; for each left image block, performing registration in at least one right image block to obtain registration similarity corresponding to different registration image block groups; determining a target registration image block group based on each registration similarity; the target registration image block group includes a target left image block and a target right image block; and generating the reference phase difference at the first resolution based on the registration displacement between the target left image block and the target right image block.
[0008] In one embodiment, each sampled image at the first resolution includes a first left sampled image corresponding to the left image at the first resolution and a first right sampled image corresponding to the right image at the first resolution. Correspondingly, generating at least one image block corresponding to each sampled image at the first resolution according to a preset window size includes: for each round of selection, sliding once in the first left sampled image according to the first window to obtain a left image block to be registered; and cascading sliding in the first right sampled image according to the second window to generate at least one right image block to be registered. Both the first and second windows are preset window sizes and have corresponding initial positions. Correspondingly, for each left image block, registration is performed in at least one right image block to obtain a registration image block corresponding to different registration image block groups. Similarity includes: in each round of registration, for the left image patch to be registered obtained in the selection process of that round, registration is performed on each right image patch to be registered obtained in the selection process of that round, to obtain the registration similarity corresponding to different registration image patch groups; accordingly, based on each registration similarity, the target registration image patch group is determined, including: after each round of registration, the registration image patch group corresponding to the highest registration similarity among the registration similarities obtained in that round of registration is selected as the candidate registration image patch group; based on the gradient of each registration image patch in the candidate registration image patch group in different directions, a gradient consistency check is performed on the candidate registration image patch group; the candidate registration image patch group that passes the gradient consistency check is used as the target registration image patch group.
[0009] In one embodiment, a search is performed within the phase difference search range at the second resolution based on each sampled image at the second resolution to obtain a reference phase difference at the second resolution. This includes: selecting a preset number of phase differences within the phase difference search range at the second resolution; performing phase difference polynomial fitting with the selected phase differences as independent variables and the registration similarity corresponding to the selected phase differences as dependent variables; and selecting the phase difference corresponding to the maximum registration similarity in the fitting results within the phase difference search range as the reference phase difference at the second resolution.
[0010] In one embodiment, cascading downsampling is performed on the image to be processed to obtain sampled images of the image to be processed at different resolutions, including: determining the texture contrast of the original image based on the pixel data of the original image; determining the number of resolutions based on the texture contrast; wherein the number of resolutions is negatively correlated with the texture contrast; and cascading downsampling is performed on the image to be processed based on the number of resolutions to obtain sampled images of the image to be processed at the number of resolutions.
[0011] Secondly, this application also provides an autofocus device, comprising: an image determination module for determining an image to be processed corresponding to an original image acquired by an image acquisition device; wherein the image to be processed includes a left image and a right image; a downsampling module for performing cascaded downsampling on the image to be processed to obtain sampled images of the image to be processed at different resolutions; a first determination module for determining a reference phase difference at a corresponding resolution based on each sampled image at the same resolution; a second determination module for determining a target phase difference based on the reference phase differences at different resolutions; and a focus control module for controlling the focus of the image acquisition device based on the target phase difference.
[0012] Thirdly, this application also provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the method provided in the first aspect.
[0013] Fourthly, this application also provides a chip, including a processor and a communication interface, wherein the processor is configured to cause the chip to perform the steps of the method provided in the first aspect.
[0014] Fifthly, this application also provides a chip module, including a communication module, a power module, a storage module, and a chip, wherein: the power module is used to provide electrical energy to the chip module; the storage module is used to store data and instructions; the communication module is used for internal communication within the chip module, or for communication between the chip module and external devices; and the chip is used to perform the steps of the method provided in the first aspect above.
[0015] In a sixth aspect, this application also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method provided in the first aspect.
[0016] In a seventh aspect, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the method provided in the first aspect.
[0017] The aforementioned autofocus method, apparatus, device, chip, and medium perform cascaded downsampling on both the left and right images of the image to be processed corresponding to the original image acquired by the image acquisition device, obtaining sampled images at different resolutions. Downsampling reduces interference information in the sampled images, thereby improving the accuracy of the subsequent reference phase difference, and consequently, the accuracy of the subsequent target phase difference. Then, for each sampled image at each resolution, the reference phase difference at that resolution is determined; and based on the reference phase differences at each resolution, the target phase difference is determined. It is evident that the target phase difference in this embodiment integrates reference phase differences at different resolutions, improving its reliability compared to a phase difference at a single resolution. Because the accuracy and reliability of the target phase difference are improved, focusing control based on the target phase difference can increase the focusing success rate. Attached Figure Description
[0018] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the description of the embodiments of this application or related technologies will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1A This is a flowchart illustrating an autofocus method in one embodiment;
[0020] Figure 1B This is a schematic diagram of the original image in one embodiment;
[0021] Figure 1C This is a schematic diagram of the original image in one embodiment;
[0022] Figure 1D This is a schematic diagram of the left image in one embodiment;
[0023] Figure 1E This is a schematic diagram of the right image in one embodiment;
[0024] Figure 2 This is a flowchart illustrating the reference phase difference determination step in one embodiment;
[0025] Figure 3 This is a flowchart illustrating the steps for determining the reference phase difference at a first resolution in one embodiment.
[0026] Figure 4 This is a flowchart illustrating the steps for obtaining the reference phase difference at the second resolution in one embodiment.
[0027] Figure 5 This is a flowchart illustrating the steps for obtaining a sampled image in one embodiment;
[0028] Figure 6 This is a flowchart illustrating the target phase difference determination step in one embodiment;
[0029] Figure 7 This is a flowchart illustrating an autofocus method in one embodiment;
[0030] Figure 8 This is a structural block diagram of an autofocus device in one embodiment;
[0031] Figure 9 This is an internal structural diagram of a computer device in one embodiment;
[0032] Figure 10 This is an internal structure diagram of a chip module in one embodiment. Detailed Implementation
[0033] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0034] It should be noted that the terms "first," "second," etc., used in this application can be used to describe various elements, but these elements are not limited by these terms. These terms are only used to distinguish the first element from the second element. The terms "comprising" and "having," and any variations thereof, used in this application, are intended to cover non-exclusive inclusion. The term "multiple" used in this application refers to two or more. The term "and / or" used in this application refers to one of the embodiments, or any combination of multiple embodiments.
[0035] In one exemplary embodiment, an autofocus method is provided, which can be applied to a chip or chip module with data processing capabilities. See also Figure 1A The method includes:
[0036] S110, determine the image to be processed corresponding to the original image acquired by the image acquisition device.
[0037] The images to be processed include the left image and the right image.
[0038] The raw images acquired by the image acquisition device are actually the raw images captured by the image sensor within the device. These raw images are the image data used for phase difference detection.
[0039] The image to be processed includes a left image and a right image, which can be obtained by extracting pixels from the original image.
[0040] For example, Figure 1B The pixels in the odd-numbered columns (first, third, and fifth columns) of the original image shown are extracted to form Figure 1D The left image shown will Figure 1B The pixels in the even-numbered columns (second, fourth, and sixth columns) of the original image shown are extracted to form... Figure 1E The right image is shown. It is understandable that pixels in each column of the left image and the corresponding pixels in the right image are adjacent pixels; the pixel values of adjacent pixels are relatively close and generally do not change abruptly. This forms the basis for subsequently determining the reference phase difference based on registration similarity.
[0041] For example, Figure 1C The pixels in the odd-numbered rows (first, third, fifth, and seventh rows) of the original image shown are extracted to form Figure 1D The left image shown will Figure 1C The pixels in the even-numbered rows (second, fourth, sixth, and eighth rows) of the original image shown are extracted to form... Figure 1E The right image is shown. It's understandable that pixels in each row of the left image and their corresponding rows in the right image are adjacent pixels; the pixel values of adjacent rows are relatively close and generally do not change abruptly. Similarly, this forms the basis for subsequently determining the reference phase difference based on registration similarity.
[0042] Of course, other methods can be used to generate the left and right images based on the original image, which are not limited here.
[0043] S120, perform cascaded downsampling on the image to be processed to obtain sampled images of the image to be processed at different resolutions.
[0044] It is understandable that cascaded downsampling of the image to be processed means performing cascaded downsampling on the left and right images respectively, to obtain sampled images of the left image at different resolutions, and sampled images of the right image at different resolutions.
[0045] For example, different resolutions include full resolution, 0.5 resolution, and 0.25 resolution. Of course, other resolutions may also be included, and this is not limited to them.
[0046] The full-resolution sampled images are the left and right images. The 0.5 resolution sampled images are the left image and the right image after being downsampled by 0.5. The 0.25 resolution sampled images are the 0.5 resolution sampled images after being downsampled by 0.5 for each of the 0.5 resolution sampled images.
[0047] In the downsampling process, the horizontal pixels can be kept unchanged while the vertical pixels are downsampled. This is because phase difference is more sensitive in the horizontal direction, thus retaining more horizontal pixels. For example, for... Figure 1D The left image shown is downsampled vertically by 0.5, which can be understood as... Figure 1D The first and third rows in the left image shown are preserved, for Figure 1E The right image shown is downsampled vertically by 0.5, which can be understood as... Figure 1E The first and third rows in the right image shown are retained, thus obtaining two sampled images at a resolution of 0.5.
[0048] Understandably, the sampled images of the left image at various resolutions form the left image pyramid, and the sampled images of the right image at various resolutions form the right image pyramid.
[0049] S130: Determine the reference phase difference at the corresponding resolution based on the sampled images at the same resolution.
[0050] The reference phase difference at a given resolution can be understood as the phase difference between the left and right sampled images at that resolution.
[0051] For example, based on two sampled images at 0.25 resolution, the phase difference between the two sampled images at 0.25 resolution can be determined as a reference phase difference at 0.25 resolution. Based on two sampled images at 0.5 resolution, the phase difference between the two sampled images at 0.5 resolution can be determined as a reference phase difference at 0.5 resolution. Based on two sampled images at full resolution, the phase difference between the two sampled images at full resolution can be determined as a reference phase difference at full resolution. Thus, the reference phase differences at the three resolutions are obtained.
[0052] S140, determine the target phase difference based on the reference phase difference at different resolutions.
[0053] The target phase difference can be understood as the combined phase difference between the left and right images in the image to be processed.
[0054] For example, different resolutions are preset with different weights, and then the target phase difference is calculated by weighted summation of the reference phase differences at each resolution.
[0055] S150 controls the focus of the image acquisition device based on the target phase difference.
[0056] That is, controlling the motor in the image acquisition device to drive the lens to move in the direction and distance indicated by the target phase difference, thereby achieving focus control.
[0057] The aforementioned autofocus method, apparatus, device, chip, and medium perform cascaded downsampling on both the left and right images of the image to be processed corresponding to the original image acquired by the image acquisition device, obtaining sampled images at different resolutions. Downsampling reduces interference information in the sampled images, thereby improving the accuracy of the subsequent reference phase difference, and consequently, the accuracy of the subsequent target phase difference. Then, for each sampled image at each resolution, the reference phase difference at that resolution is determined; and based on the reference phase differences at each resolution, the target phase difference is determined. It is evident that the target phase difference in this embodiment integrates reference phase differences at different resolutions, improving its reliability compared to a phase difference at a single resolution. Because the accuracy and reliability of the target phase difference are improved, focusing control based on the target phase difference can increase the focusing success rate.
[0058] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided. In this optional embodiment, different resolutions include a first resolution and a second resolution other than the first resolution; the first resolution is the lowest resolution, and the reference phase difference determination step in S130 is refined.
[0059] See Figure 2 The detailed steps for determining the reference phase difference include:
[0060] S210, determine the reference phase difference at the first resolution based on each sampled image at the first resolution.
[0061] S220, for each second resolution, determine the phase difference search range at the second resolution based on the reference phase difference at the adjacent lower resolution.
[0062] S230: Based on each sampled image at the second resolution, a search is performed within the phase difference search range at the second resolution to obtain the reference phase difference at the second resolution.
[0063] For example, if the resolution includes full resolution, 0.5 resolution, and 0.25 resolution, then 0.25 resolution is the first resolution, and 0.5 resolution and full resolution are the second resolution.
[0064] First, based on the two sampled images at 0.25 resolution, the reference phase difference Δx3 at 0.25 resolution is determined, thus achieving a rough global search.
[0065] Then, based on the reference phase difference Δx3 at 0.25 resolution, the phase difference search range [Δx3-μ, Δx3+μ]×a at 0.5 resolution is determined, where μ is the search step size and a is the mapping factor from 0.5 resolution to 0.25 resolution. Based on the two sampled images at 0.5 resolution, a search is performed within [Δx3-μ, Δx3+μ]×a to obtain the reference phase difference Δx2 at 0.5 resolution, thus achieving an accurate search.
[0066] Finally, based on the reference phase difference Δx2 at 0.5 resolution, the phase difference search range [Δx2-μ, Δx2+μ]×a at full resolution is determined, where μ is the search step size and a is the mapping factor from full resolution to 0.5 resolution. Using the two sampled images at full resolution, the search is performed within [Δx2-μ, Δx2+μ]×a to obtain the reference phase difference Δx1 at full resolution, achieving a more precise search.
[0067] Thus, the reference phase difference Δx3 at 0.25 resolution, the reference phase difference Δx2 at 0.5 resolution, and the reference phase difference Δx1 at full resolution are obtained.
[0068] In the example above, the reference phase difference at the lowest resolution is first determined, achieving a coarse global search. Then, based on the reference phase difference at the lowest resolution, a phase difference search range is provided for the adjacent second-lowest resolution to determine the reference phase difference at the second-lowest resolution, achieving a precise search. This process is repeated layer by layer, gradually narrowing the search range until precise phase difference localization at full resolution is achieved.
[0069] In this embodiment, the reference phase difference at the first resolution is first determined, achieving a coarse global search and providing a search basis for each second resolution. For each second resolution, the phase difference search range at that second resolution is determined based on the reference phase difference at adjacent lower resolutions, thereby narrowing the search range. A local search can then be performed to obtain the reference phase difference at the second resolution, thus achieving a precise local search. It is evident that this embodiment can progressively reduce the search range; the higher the resolution, the more accurate the positioning of the reference phase difference.
[0070] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the step of determining the reference phase difference at the first resolution in S210 is refined.
[0071] See Figure 3 The steps for determining the reference phase difference at the first resolution include:
[0072] S310, generate at least one image block corresponding to each sampled image at the first resolution according to the preset window size.
[0073] Here, the sampled image of the left image at the first resolution can be called the first left sampled image, and the sampled image of the right image at the first resolution can be called the first right sampled image. That is, each sampled image at the first resolution includes the first left sampled image corresponding to the left image at the first resolution and the first right sampled image corresponding to the right image at the first resolution.
[0074] The aforementioned at least one image block includes a left image block corresponding to the left image and a right image block corresponding to the right image. The left image block is an image block in the first left-sampled image with a size of a preset window size, and the right image block is an image block in the first right-sampled image with a size of a preset window size.
[0075] In an optional implementation, the method for generating image blocks in S310 includes: for each round of selection process, sliding the first left sampled image once according to the first window to obtain a left image block to be registered; and cascading sliding the first right sampled image according to the second window to generate at least one right image block to be registered; the first window and the second window are both preset window sizes and their initial positions correspond to each other.
[0076] As can be seen, in each round of selection, the initial position of the first window in the first left-sampled image corresponds to the initial position of the second window in the first right-sampled image. For example, the coordinates of the initial position of the upper left corner of the first window in the first left-sampled image are (x1, y1), and the coordinates of the initial position of the upper left corner of the second window in the first right-sampled image are also (x1, y1). Each slide of the first window in the first left-sampled image forms a left image block to be registered by the pixels within the first window. The second window in the first right-sampled image undergoes cascading slides, i.e., multiple consecutive slides. After each slide, the pixels within the second window form a right image block to be registered, resulting in multiple right image blocks to be registered after multiple cascading slides. Therefore, after one round of selection, one left image block to be registered and multiple right image blocks to be registered are obtained; that is, one left image block and multiple right image blocks that need to be registered with the left image block.
[0077] Understandably, since both the first and second windows are preset window sizes, the sizes of the left image block to be registered and each right image block to be registered are the same. Because the initial positions of the first and second windows correspond, the displacement of each right image block to be registered relative to the first right image block to be registered is actually equal to the displacement of that right image block to be registered relative to the left image block to be registered.
[0078] As can be seen, in this implementation, by sliding the first window once in the first left sampled image and then sliding the second window multiple times in the first right sampled image during one round of selection, a left image block to be registered and multiple right image blocks to be registered can be obtained quickly, thereby improving the focus control efficiency.
[0079] S320, for each left image block, registration is performed in at least one right image block to obtain the registration similarity corresponding to different registered image block groups.
[0080] A registration image block group includes a left image block and a right image block, namely a left image block to be registered and a right image block to be registered.
[0081] As can be seen, by registering a left image block and a right image block, we can obtain the registration similarity of the registered image block group to which the left and right image blocks belong.
[0082] The registration similarity method can include: calculating the pixel similarity between the left image block and the right image block. For example, if both the left and right image blocks contain 9 pixels, then the pixel value similarity between the 9 pixels in the left image block and the 9 pixels in the right image block is calculated.
[0083] After going through one round of selection, the corresponding registration process for that round begins.
[0084] In an optional implementation, S320 includes: in each round of registration, for the left image block to be registered obtained in the selection process of that round, registration is performed on each right image block to be registered obtained in the selection process of that round, so as to obtain the registration similarity corresponding to different groups of registered image blocks.
[0085] For example, in one round of selection, one left image block to be registered and ten right image blocks to be registered are generated, thus obtaining ten sets of registered image blocks in this round of selection. Then, the registration process of this round begins, in which the registration similarity between the left and right image blocks to be registered in each of the ten sets of registered image blocks is calculated, ultimately obtaining ten registration similarity scores.
[0086] S330, determine the target registration image block group based on the registration similarity.
[0087] The target registration image block group includes a left target image block and a right target image block.
[0088] In practical scenarios, the maximum value can be selected from the registration similarity scores obtained in the first round, and the group of registered image patches corresponding to this maximum value can be used as the target group of registered image patches, eliminating the need for a second round of selection and registration. Alternatively, multiple rounds of selection and registration can be performed, and then the maximum value can be selected from the registration similarity scores obtained in each round, with the group of registered image patches corresponding to this maximum value used as the target group of registered image patches.
[0089] Of course, other methods can also be used to determine the target registration image patch group. For example, in an optional implementation, S330 may include S1~S3:
[0090] S1. After each round of registration process, select the group of registered image patches with the highest registration similarity among the registration similarities obtained in that round of registration process as the candidate group of registered image patches.
[0091] S2, perform gradient consistency check on the candidate registration image block group based on the gradients of each registration image block in different directions.
[0092] Different directions can include horizontal and vertical directions.
[0093] Specifically, the combined gradient of the left registered image patch can be determined based on its gradient in the horizontal and vertical directions. Similarly, the combined gradient of the right registered image patch can be determined based on its gradient in the horizontal and vertical directions. The gradient consistency of the candidate registered image patch group is then calculated based on the combined gradients of the left and right registered image patches within the candidate registered image patch group.
[0094] For example, the gradient consistency of candidate registration image patch groups is calculated using the following formula:
[0095]
[0096] In the formula, For gradient consistency, ▽L1 is the combined gradient of the left registered image patch, ▽R1 is the combined gradient of the right registered image patch, |▽L1| is the magnitude of the combined gradient of the left registered image patch, and |▽R1| is the magnitude of the combined gradient of the right registered image patch.
[0097] In the above calculation formula, the dot product of the combined gradients is used to measure the consistency of the gradient direction, and the product of the magnitudes is the normalization factor. If the gradient consistency is within the range of [-1, 1], the gradient consistency check passes; the closer the gradient consistency is to 1, the higher the degree of consistency of the gradient direction, and the more accurate the focus. If the gradient consistency is outside the range of [-1, 1], the gradient consistency check fails.
[0098] Understandably, gradient consistency can reveal whether there are pixel abrupt changes in either the left or right registered image patch, leading to significant inconsistencies in texture between the two patches. If the gradient consistency check of the left and right registered image patches passes, it indicates a high degree of texture similarity. Based on maximizing the registration similarity between the left and right registered image patches in the candidate registration patch group, further gradient consistency checks can determine whether the left and right registered image patches in the candidate group match. Based on the matched left and right registered image patches, the reference phase difference at the first resolution can be accurately calculated.
[0099] S3, the candidate registration image patch group that passes the gradient consistency check is used as the target registration image patch group.
[0100] That is, after each round of selection and registration, the maximum value is selected from the registration similarities obtained in that round, and the group of registered image patches corresponding to the maximum value is taken as the candidate group of registered image patches. Then, the gradient consistency between the left and right registered image patches in the candidate group of registered image patches is calculated. If the gradient consistency passes the gradient consistency check, the candidate group of registered image patches in that round is taken as the target group of registered image patches.
[0101] Of course, if the gradient consistency fails the gradient consistency check, the process proceeds to the next round of selection and registration, and S1~S3 are executed after the next round of registration. This continues until the gradient consistency passes the gradient consistency check, at which point the candidate registration image patch group that passes the gradient consistency check is used as the target registration image patch group.
[0102] In the implementation method including steps S1 to S3, based on selecting candidate registration image block groups according to registration similarity, a gradient consistency check is performed on the candidate registration image block groups to determine whether the textures of the left and right registration image blocks in the candidate registration image block groups are consistent, that is, to further determine whether the left and right registration image blocks in the candidate registration image block groups match, thereby determining the target registration image block group. Based on the target left image block and target right image block in the target registration image block group, the reference phase difference at the first resolution can be accurately calculated.
[0103] S340, based on the registration displacement between the left and right image blocks of the target, generate a reference phase difference at the first resolution.
[0104] Specifically, the displacement of the right image block of the target relative to the left image block of the target in the target registration image block group is used as the registration displacement.
[0105] In practical scenarios, the registration displacement (dx, dy) can be directly used as the reference phase difference at the first resolution. Since focusing is sensitive to horizontal displacement, the horizontal displacement dx in the registration displacement (dx, dy) can also be used as the registration displacement.
[0106] In this embodiment, the left and right image blocks in the registered image block group are registered to obtain the registration similarity of the registered image block group. The higher the registration similarity, the higher the matching degree between the left and right image blocks. Based on the registration similarity of each registered image block group, the target registered image block group with the highest matching degree between the left and right image blocks is selected. Based on the registration displacement between the target left and target right image blocks in the target registered image block group, the reference phase difference at the first resolution can be accurately determined.
[0107] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the step of obtaining the reference phase difference at the second resolution in S230 is refined.
[0108] See Figure 4 The steps for obtaining the reference phase difference at the refined second resolution include:
[0109] S410, within the phase difference search range at the second resolution, select a preset number of phase differences.
[0110] The preset quantity can be set as needed, for example, 3.
[0111] S420 uses the selected phase difference as the independent variable and the registration similarity corresponding to the selected phase difference as the dependent variable to perform phase difference polynomial fitting.
[0112] The specific form of the phase difference polynomial can be y=ax. 2 +bx+c, at this point the phase difference polynomial is a quadratic parabola.
[0113] S430, within the phase difference search range, select the phase difference corresponding to the maximum registration similarity in the fitting results as the reference phase difference under the second resolution.
[0114] For example, three phase differences p1, p2, and p3 are selected from [Δx3-μ, Δx3+μ]×a. First, for each selected phase difference, the left image block of the left image at the second resolution and the right image block of the right image at the second resolution are determined, and the displacement of the right image block at the second resolution relative to the left image block at the second resolution is the phase difference. Then, the registration similarity between the left image block at the second resolution and the right image block at the second resolution is calculated, and this registration similarity is taken as the registration similarity corresponding to the phase difference. Each selected phase difference is taken as the independent variable x, and the registration similarity corresponding to each phase difference is taken as the dependent variable y. The phase difference polynomial y=ax is fitted according to the three sets (independent variable x, dependent variable y). 2 +bx+c. After fitting, the peak value in the quadratic parabolic curve (i.e., -b / 2a) is the maximum registration similarity, and the independent variable x corresponding to the peak value is used as the reference phase difference under the second resolution.
[0115] In one optional implementation, after selecting the phase difference corresponding to the maximum registration similarity in the fitting results, S430 determines the left image patch of the left image at the second resolution and the right image patch of the right image at the second resolution. At this time, the displacement of the right image patch of the right image at the second resolution relative to the left image patch at the second resolution is the phase difference corresponding to the maximum registration similarity in the fitting results. Then, the gradient consistency between the left image patch at the second resolution and the right image patch at the second resolution is calculated, and a gradient consistency check is performed. If the gradient consistency check passes, the phase difference corresponding to the maximum registration similarity in the fitting results is used as the reference phase difference at the second resolution. If the gradient consistency check fails, the process returns to S410 and repeats S410~S430 until the gradient consistency calculated after fitting passes the gradient consistency check, and the phase difference corresponding to the maximum registration similarity in the last fitting result is used as the reference phase difference at the second resolution.
[0116] The above implementation method, for each second resolution, selects the phase difference corresponding to the maximum registration similarity in the fitting results, and then performs a gradient consistency check. The gradient consistency check determines whether the textures of the left and right image blocks under the phase difference corresponding to the maximum registration similarity in the fitting results are consistent, thereby improving the reliability of the reference phase difference under the second resolution.
[0117] In this embodiment, within the phase difference search range at the second resolution, multiple phase differences are selected, and the registration similarity corresponding to the selected phase differences is determined. Using the selected phase differences as independent variables and the registration similarity corresponding to the selected phase differences as dependent variables, a position difference polynomial is fitted. Based on the position difference polynomial, the phase difference corresponding to the maximum registration similarity in the fitted results is selected as the reference phase difference at the second resolution. Since the registration similarity corresponding to the reference phase difference at the second resolution is the largest, the reference phase difference at the second resolution is the phase difference with the highest confidence within the phase difference search range at the second resolution, thereby improving the accuracy of the reference phase difference at the second resolution. Therefore, this embodiment provides a local search implementation method that can achieve accurate local search.
[0118] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the step of obtaining the sampled image in S120 is refined.
[0119] See Figure 5 The steps to obtain a refined sampled image include:
[0120] S510 determines the texture contrast of the original image based on the pixel data of the original image.
[0121] Among them, texture contrast is the degree to which the texture complexity of the original image is relative to a preset complexity threshold.
[0122] For example, texture contrast is calculated using the following formula:
[0123]
[0124] In the formula, ScaleLevel represents the texture contrast, and σ scence Let σ be the texture complexity of the original image. threshold This is a preset complexity threshold. Wherein, texture complexity σ scence It can be the standard deviation of the pixel values of each pixel in the original image, and the specific calculation formula is as follows:
[0125]
[0126] In the formula, N is the number of pixels in the original image, and xi is the pixel value of the i-th pixel. This is the average pixel value of each pixel in the original image.
[0127] The S520 determines the number of resolutions based on texture contrast.
[0128] Among them, the number of resolutions is negatively correlated with texture contrast.
[0129] Typically, if the original image contains mirrored and / or transparent objects (e.g., a glass), the original image is likely to be a low-texture image.
[0130] Understandably, high-texture images contain more information, and the reference phase difference calculated at each resolution based on this more information is more accurate. Therefore, it's not necessary to calculate the accurate target phase difference using reference phase differences at multiple resolutions. Thus, for high-texture images, the number of resolutions is smaller, reducing computational redundancy while maintaining target phase difference accuracy. However, low-texture images contain less information, and the accuracy of reference phase differences at lower resolutions may not be high enough. Therefore, using reference phase differences at a larger number of resolutions can improve the accuracy and reliability of the target phase difference. Thus, the higher the texture contrast, the fewer the number of resolutions required.
[0131] For example, if the texture contrast is higher than a preset value, the original image is considered a high-texture image, and the number of resolutions is 2. If the texture contrast is not higher than the preset value, the original image is considered a low-texture image, and the number of resolutions is 3.
[0132] S530 performs cascaded downsampling on the image to be processed according to the number of resolutions, to obtain a sampled image of the image to be processed at the number of resolutions.
[0133] For example, if the number of resolutions is 3, then the image to be processed undergoes 3 layers of cascaded downsampling. If the number of resolutions is 2, then the image to be processed undergoes 2 layers of cascaded downsampling.
[0134] In this embodiment, the texture contrast of the original image is determined based on the pixel data of the original image, and then the number of resolutions is determined based on the texture contrast, so that the number of resolutions matches the texture contrast of the original image, thereby ensuring the accuracy of the subsequent target phase difference while minimizing the amount of computation.
[0135] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which the target phase difference determination step in S140 is refined.
[0136] See Figure 6 The detailed target phase difference determination steps include:
[0137] S610 determines the target phase difference based on the reference phase difference at different resolutions and the gradient consistency corresponding to each reference phase difference.
[0138] For example, the target phase difference is calculated using the following formula:
[0139]
[0140] In the formula, Let M be the target phase difference, and w be the number of resolutions. i The weights are for the i-th resolution. If the original image is a high-texture image, the higher the resolution, the greater the corresponding weight. If the original image is a low-texture image, the lower the resolution, the greater the corresponding weight. For the gradient consistency corresponding to the reference phase difference at the i-th resolution, Let be the reference phase difference at the i-th resolution.
[0141] In this embodiment, in the process of determining the target phase difference, not only the reference phase difference at each resolution is taken into account, but also the gradient consistency corresponding to each reference phase difference is taken into account, so the accuracy and reliability of the target phase difference can be further improved.
[0142] Based on the technical solutions provided in the above embodiments, an optional embodiment is provided, in which an autofocus method is provided, see [link to optional embodiment]. Figure 7 The method includes:
[0143] S701, acquire the raw image captured by the image acquisition device.
[0144] S702, Based on the original image, determine the image to be processed, including the left and right images.
[0145] S703 determines the texture contrast of the original image based on the pixel data of the original image.
[0146] S704 determines the number of resolutions based on texture contrast.
[0147] Among them, the number of resolutions is negatively correlated with texture contrast.
[0148] S705, based on the number of resolutions, performs cascaded downsampling on the image to be processed to obtain a sampled image of the image to be processed at the number of resolutions.
[0149] Among them, different resolutions include a first resolution and a second resolution other than the first resolution; the first resolution is the lowest resolution.
[0150] The sampled images at the first resolution include the first left sampled image corresponding to the left image at the first resolution and the first right sampled image corresponding to the right image at the first resolution.
[0151] S706, for each round of selection process, according to the first window, slide once on the first left sampled image to obtain the left image block to be registered; and according to the second window, perform cascaded sliding on the first right sampled image to generate at least one right image block to be registered; and enter the registration process of that round.
[0152] Both the first and second windows are preset window sizes and their initial positions correspond to each other.
[0153] One round includes a selection process and a registration process.
[0154] S707, In each round of registration, for the left image block to be registered obtained in the selection process of that round, registration is performed on each right image block to be registered obtained in the selection process of that round, so as to obtain the registration similarity corresponding to different groups of registered image blocks.
[0155] S708 After each round of registration process, the group of registered image blocks corresponding to the highest registration similarity among the registration similarities obtained in that round of registration process is selected as the candidate group of registered image blocks.
[0156] S709, perform gradient consistency check on the candidate registration image block group based on the gradients of each image block in different directions.
[0157] S710 selects the candidate registration image patch group that has passed the gradient consistency check as the target registration image patch group.
[0158] If the candidate image block group determined after a registration process fails the gradient consistency check, the process returns to S706 to proceed to the next selection process.
[0159] Of course, gradient consistency checks can be skipped, and the candidate registration image block group obtained in S708 of the first round can be directly used as the target registration image block group.
[0160] The target registration image block group includes a left target image block and a right target image block.
[0161] S711, based on the registration displacement between the left and right image blocks of the target, generates a reference phase difference at the first resolution.
[0162] S712, for each second resolution, determines the phase difference search range at the second resolution based on the reference phase difference at the adjacent lower resolution.
[0163] S713, within the phase difference search range at the second resolution, selects a preset number of phase differences.
[0164] S714 uses the selected phase difference as the independent variable and the registration similarity corresponding to the selected phase difference as the dependent variable to perform phase difference polynomial fitting.
[0165] S715, within the phase difference search range, select the phase difference corresponding to the maximum registration similarity in the fitting results as the reference phase difference under the second resolution.
[0166] The algorithm can also check the gradient consistency of the phase difference corresponding to the maximum registration similarity in the fitting results. If the gradient consistency check passes, the phase difference corresponding to the maximum registration similarity in the fitting results is used as the reference phase difference at the second resolution. If the gradient consistency check fails, the algorithm returns to step S713.
[0167] S716 determines the target phase difference based on the reference phase difference at different resolutions and the gradient consistency corresponding to each reference phase difference.
[0168] The S717 controls the focus of the image acquisition device based on the target phase difference.
[0169] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps. It is understood that the steps in different embodiments can be freely combined as needed, and all non-contradictory solutions formed by such combinations are within the scope of protection of this application.
[0170] Based on the same inventive concept, this application also provides an autofocus device for implementing the autofocus method described above. This device can be applied to or integrated into a chip or chip module, for example. The solution provided by this device is similar to the solution described in the above method; therefore, the specific limitations of one or more autofocus device embodiments provided below can be found in the limitations of the autofocus method described above, and will not be repeated here.
[0171] In one exemplary embodiment, such as Figure 8 As shown, an autofocus device is provided, comprising:
[0172] The image determination module 810 is used to determine the image to be processed corresponding to the original image acquired by the image acquisition device; wherein, the image to be processed includes a left image and a right image;
[0173] The downsampling module 820 is used to perform cascaded downsampling on the image to be processed, so as to obtain sampled images of the image to be processed at different resolutions.
[0174] The first determining module 830 is used to determine the reference phase difference at the corresponding resolution based on the sampled images at the same resolution;
[0175] The second determining module 840 is used to determine the target phase difference based on the reference phase difference at different resolutions;
[0176] The focus control module 850 is used to control the focus of the image acquisition device based on the target phase difference.
[0177] In one embodiment, the different resolutions include a first resolution and a second resolution other than the first resolution; the first resolution is the lowest resolution; correspondingly, the first determining module includes:
[0178] The first determining submodule is used to determine the reference phase difference at the first resolution based on each sampled image at the first resolution;
[0179] The second determining submodule is used to determine the phase difference search range at each second resolution based on the reference phase difference at adjacent lower resolutions.
[0180] The first search submodule is used to search within the phase difference search range at the second resolution based on each sampled image at the second resolution, and obtain the reference phase difference at the second resolution.
[0181] In one embodiment, the first determining submodule includes:
[0182] The image block generation unit is used to generate at least one image block corresponding to each sampled image at a first resolution according to a preset window size; the image block includes a left image block corresponding to the left image and a right image block corresponding to the right image;
[0183] The image patch registration unit is used to register each left image patch in at least one right image patch to obtain the registration similarity corresponding to different registered image patch groups.
[0184] The first determining unit is used to determine the target registration image block group based on the registration similarity; the target registration image block group includes a target left image block and a target right image block;
[0185] The phase difference generation unit is used to generate a reference phase difference at a first resolution based on the registration displacement between the left image block and the right image block of the target.
[0186] In one embodiment, each sampled image at the first resolution includes a first left sampled image corresponding to the left image at the first resolution and a first right sampled image corresponding to the right image at the first resolution. Correspondingly, the image block generation unit is specifically used for: for each round of selection, sliding once on the first left sampled image according to the first window to obtain a left image block to be registered; and cascading sliding on the first right sampled image according to the second window to generate at least one right image block to be registered. The first window and the second window are both preset window sizes and their initial positions correspond. Correspondingly, the image block registration unit is specifically used for: in the registration process of each round, for that round... The left image patch to be registered obtained in the selection process is registered with each right image patch to be registered obtained in the same selection process to obtain the registration similarity corresponding to different registration image patch groups; accordingly, the first determining unit is specifically used to: after each registration process, select the registration image patch group corresponding to the highest registration similarity among the registration similarities obtained in the registration process of that round as the candidate registration image patch group; perform gradient consistency check on the candidate registration image patch group according to the gradient of each registration image patch in different directions; and take the candidate registration image patch group that passes the gradient consistency check as the target registration image patch group.
[0187] In one embodiment, the first search submodule is specifically used to: select a preset number of phase differences within the phase difference search range at the second resolution; perform phase difference polynomial fitting with the selected phase differences as independent variables and the registration similarity corresponding to the selected phase differences as dependent variables; and select the phase difference corresponding to the maximum registration similarity in the fitting results within the phase difference search range as the reference phase difference at the second resolution.
[0188] In one embodiment, the downsampling module is specifically used to: determine the texture contrast of the original image based on the pixel data of the original image; determine the number of resolutions based on the texture contrast; wherein the number of resolutions is negatively correlated with the texture contrast; and perform cascaded downsampling on the image to be processed based on the number of resolutions to obtain a sampled image of the image to be processed at the number of resolutions.
[0189] Regarding the modules / units included in the various devices and products described in the above embodiments, they can be software modules / units, hardware modules / units, or a combination of both. For example, for various devices and products applied to or integrated into a chip, all of their modules / units can be implemented using hardware methods such as circuits, or at least some modules / units can be implemented using software programs that run on a processor integrated within the chip, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits; for various devices and products applied to or integrated into a chip module, all of their modules / units can be implemented using hardware methods such as circuits, and different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or different components of the chip module, or at least some modules / units can be implemented using hardware methods such as circuits. The components can be implemented using software programs that run on the processor integrated within the chip module. The remaining (if any) modules / units can be implemented using hardware methods such as circuits. For various devices and products applied to or integrated into the terminal, each of its components / units can be implemented using hardware methods such as circuits. Different modules / units can be located in the same component (e.g., chip, circuit module, etc.) or in different components within the terminal. Alternatively, at least some modules / units can be implemented using software programs that run on the processor integrated within the terminal, while the remaining (if any) modules / units can be implemented using hardware methods such as circuits.
[0190] In one exemplary embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 9As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, Near Field Communication (NFC), or other technologies. When executed by the processor, the computer program implements an autofocus method. The display unit is used to form a visually visible image and can be a display screen, a projection device, or a virtual reality imaging device. The display screen can be an LCD screen or an e-ink screen. The input device of the computer device can be a touch layer covering the display screen, or buttons, trackballs, or touchpads set on the casing of the computer device, or external keyboards, touchpads, or mice, etc.
[0191] Those skilled in the art will understand that Figure 9 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0192] In one exemplary embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the autofocus method provided in the above embodiment.
[0193] Based on the same inventive concept, this application also provides a chip, including a processor and a communication interface; the communication interface is used to receive or send data; the processor is configured to cause the chip to perform the steps of the autofocus method provided in the above embodiments.
[0194] It is understood that the chip involved in the embodiments of this application may be a field-programmable gate array (FPGA), may be an application-specific integrated circuit (ASIC), may be a system on chip (SoC), may be a central processor unit (CPU), may be a network processor (NP), may be a digital signal processor (DSP), may be a microcontroller unit (MCU), may be a programmable logic device (PLD), or other integrated chips, etc.
[0195] Based on the same inventive concept, this application also provides a chip module, such as... Figure 10 As shown, the chip module includes a communication module, a power module, a storage module, and a chip. Specifically: the power module provides power to the chip module; the storage module stores data and instructions; the communication module enables internal communication within the chip module or communication between the chip module and external devices; and the chip corresponds to the chip in the aforementioned chip embodiment. The implementation of this chip module can be found in the relevant content of the aforementioned chip embodiment, and will not be repeated here.
[0196] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the steps of the autofocus method provided in the above embodiments.
[0197] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the steps of the autofocus method provided in the above embodiments.
[0198] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, artificial intelligence (AI) processors, etc., and are not limited to these.
[0199] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.
[0200] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.
Claims
1. An autofocus method, characterized in that, include: The image to be processed is determined corresponding to the original image acquired by the image acquisition device; wherein, the image to be processed includes the left image and the right image; The image to be processed is subjected to cascaded downsampling to obtain sampled images of the image to be processed at different resolutions; Based on the sampled images at the same resolution, determine the reference phase difference at the corresponding resolution; Determine the target phase difference based on the reference phase difference at different resolutions; The image acquisition device is focused based on the target phase difference.
2. The method according to claim 1, characterized in that, The different resolutions include a first resolution and a second resolution other than the first resolution; The first resolution is the lowest resolution; Accordingly, determining the reference phase difference at the corresponding resolution based on each sampled image at the same resolution includes: Based on each sampled image at the first resolution, determine the reference phase difference at the first resolution; For each second resolution, the phase difference search range at the second resolution is determined based on the reference phase difference at the adjacent lower resolution. Based on each sampled image at the second resolution, a search is performed within the phase difference search range at the second resolution to obtain the reference phase difference at the second resolution.
3. The method according to claim 2, characterized in that, The step of determining the reference phase difference at the first resolution based on each sampled image at the first resolution includes: According to a preset window size, at least one image block is generated corresponding to each sampled image at the first resolution; the image block includes a left image block corresponding to the left image and a right image block corresponding to the right image; For each of the left image blocks, registration is performed in at least one right image block to obtain the registration similarity corresponding to different registered image block groups; Based on the registration similarity scores, a target registration image block group is determined; the target registration image block group includes a target left image block and a target right image block; A reference phase difference at the first resolution is generated based on the registration displacement between the left and right image blocks of the target.
4. The method according to claim 3, characterized in that, Each sampled image at the first resolution includes a first left sampled image corresponding to the left image at the first resolution and a first right sampled image corresponding to the right image at the first resolution; Accordingly, generating at least one image block corresponding to each sampled image at the first resolution according to a preset window size includes: For each round of selection, the first window slides once on the first left sampled image to obtain the left image block to be registered; and the second window slides in a cascaded manner on the first right sampled image to generate at least one right image block to be registered; the first window and the second window are both the preset window size and their initial positions correspond to each other; Accordingly, the registration process for each left image patch in at least one right image patch to obtain registration similarity for different registered image patch groups includes: In each round of registration, for the left image block to be registered obtained in the selection process of that round, registration is performed on each right image block to be registered obtained in the selection process of that round, so as to obtain the registration similarity corresponding to different groups of registered image blocks. Accordingly, based on the registration similarity of each, a target registration image patch group is determined, including: After each round of registration, the group of registered image patches with the highest registration similarity among all the registration similarities obtained in that round of registration is selected as the candidate group of registered image patches. Based on the gradients of each image block in the candidate registration image block group in different directions, a gradient consistency check is performed on the candidate registration image block group. The candidate registration image block group that passes the gradient consistency check is used as the target registration image block group.
5. The method according to claim 3, characterized in that, The step of searching within the phase difference search range at the second resolution based on each sampled image at the second resolution to obtain the reference phase difference at the second resolution includes: Within the phase difference search range at the second resolution, a preset number of phase differences are selected; Using the selected phase difference as the independent variable and the registration similarity corresponding to the selected phase difference as the dependent variable, a phase difference polynomial fitting was performed. Within the phase difference search range, the phase difference corresponding to the maximum registration similarity in the fitting results is selected as the reference phase difference under the second resolution.
6. The method according to any one of claims 1 to 5, characterized in that, The step of cascading downsampling the image to be processed to obtain sampled images of the image to be processed at different resolutions includes: The texture contrast of the original image is determined based on the pixel data of the original image; The number of resolutions is determined based on the texture contrast; wherein the number of resolutions is negatively correlated with the texture contrast. Based on the number of resolutions, the image to be processed is cascaded downsampled to obtain a sampled image of the image to be processed at the number of resolutions.
7. An automatic focusing device, characterized in that, The device includes: An image determination module is used to determine the image to be processed corresponding to the original image acquired by the image acquisition device; wherein, the image to be processed includes a left image and a right image; The downsampling module is used to perform cascaded downsampling on the image to be processed to obtain sampled images of the image to be processed at different resolutions; The first determining module is used to determine the reference phase difference at the corresponding resolution based on the sampled images at the same resolution; The second determining module is used to determine the target phase difference based on the reference phase difference at different resolutions; The focus control module is used to control the focus of the image acquisition device based on the target phase difference.
8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 6.
9. A chip, characterized in that, The device includes a processor and a communication interface, wherein the processor is configured to cause the chip to perform the steps of the method described in any one of claims 1 to 6.
10. A computer-readable storage medium, characterized in that, It stores a computer program thereon, which, when executed by a processor, implements the steps of the method described in any one of claims 1 to 6.