Automatic focusing method and device, electronic equipment and storage medium

By acquiring multi-frame phase images under different exposure times and performing pixel fusion, it solves the problem of inaccurate focusing of PDAF technology in dark light or overexposed environments, achieving more accurate phase difference calculation and improving image quality.

CN118741305APending Publication Date: 2024-10-01BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310344436.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-31
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing PDAF technology is difficult to accurately calculate the phase difference value in dark light or overexposed environments, resulting in inaccurate focusing and a greater impact of environmental noise, affecting image quality.

Method used

By acquiring multiple frames of original phase images under different exposure times, the reliability weight is determined based on the gradient information and brightness difference between pixels and neighboring pixels, and pixel fusion is performed to generate the target original phase image, thereby determining the accurate defocus position. Avoid the influence of ambient light.

Benefits of technology

Improved PDAF focusing performance, especially in low light or overexposed environments, ensuring image quality and user photography experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118741305A_ABST
    Figure CN118741305A_ABST
Patent Text Reader

Abstract

The invention relates to an automatic focusing method and device, electronic equipment and a storage medium, and the method comprises the steps: obtaining a plurality of frames of original phase images under different exposure durations, and according to the gradient information and / or brightness difference information between each pixel point and a neighborhood pixel point in the plurality of frames of original phase images, carrying out the automatic focusing of the plurality of frames of original phase images; the method comprises the steps of obtaining multiple frames of original phase images, determining multiple reliability weights corresponding to the multiple frames of original phase images, performing pixel fusion on pixel points at the same positions in the multiple frames of original phase images based on the multiple reliability weights to generate a target original phase image, determining a defocus position according to the target original phase image, and performing focusing based on the defocus position. Therefore, the overexposure part or the underexposure part in the image is compensated through image fusion, the influence of ambient light on the focusing effect of the PDAF is avoided, and an accurate defocus position is obtained. Image shooting is carried out based on the focusing distance, the image quality is improved, and the shooting experience of the user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of image capture technology, and in particular to an auto-focusing method, device, electronic device and storage medium. Background Art

[0002] Taking photos has become a core demand for users to purchase mobile phones, and major manufacturers' new phone launch conferences also focus on photo effects as a selling point. In recent years, PDAF (Phase Detection Auto Focus) has become the mainstream focusing method in the field of mobile phone photography due to its fast focusing speed. The focusing principle of PDAF is mainly to reserve some masked pixels on the photosensitive sensor. These pixels act as autofocus sensors to obtain information related to the phase difference between the left and right sides. For example, the left phase difference data and the right phase difference data can be obtained. By comparing the difference between the left and right phase pixels, the phase value is calculated, and then converted into the corresponding defocus distance through the distance mapping model, and the lens is moved to the best focus position through the defocus distance. Summary of the invention

[0003] In order to overcome the problems existing in the related art, the present disclosure provides an automatic focusing method, device, electronic device and storage medium.

[0004] According to a first aspect of an embodiment of the present disclosure, there is provided an automatic focusing method, comprising:

[0005] Acquire multiple frames of original phase images under different exposure times, wherein each frame of the original phase image includes a phase pixel point corresponding to a preset masked pixel point;

[0006] Determine a plurality of reliability weights corresponding to each of the plurality of frames of original phase images according to gradient information and / or brightness difference information between each pixel point and a neighboring pixel point in the plurality of frames of original phase images, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight;

[0007] Based on the multiple reliability weights, pixel fusion is performed on the pixel points at the same position in the multiple frames of original phase images to generate a target original phase image;

[0008] By presetting masked pixel points, a defocus position is determined according to the target original phase image, and focusing is performed based on the defocus position.

[0009] Optionally, determining a plurality of reliability weights corresponding to each of the multiple frames of original phase images according to gradient information and / or brightness difference information between each pixel point and a neighboring pixel point in the multiple frames of original phase images comprises:

[0010] Determine a first irradiance image of each pixel in the first original phase image according to a first exposure time and first grayscale information of the first original phase image, wherein the first original phase image is any image in the multiple frames of original phase images;

[0011] Determine a first reliability weight of each pixel point according to gradient information and / or brightness difference information between each pixel point and neighboring pixel points in the first irradiance image;

[0012] The multiple frames of original phase images are traversed to generate the multiple reliability weights.

[0013] Optionally, determining a first irradiance image of each pixel in the first original phase image according to the first exposure time and the first grayscale information of the first original phase image includes:

[0014] The first irradiance image is determined by an irradiance calibration function according to the first exposure time and the first grayscale information, wherein the irradiance calibration function is determined by:

[0015] Performing data fitting on the multiple calibrated exposure times and multiple irradiances under the multiple calibrated grayscale information by using the least square method to generate an irradiance curve;

[0016] The irradiance calibration function is determined according to the irradiance curve.

[0017] Optionally, the collecting of multiple frames of original phase images at different exposure times based on preset masked pixels includes:

[0018] When an exposure abnormality is detected in the preview image, obtaining the area ratio of the exposure abnormality region in the preview image;

[0019] If the area ratio is greater than a set ratio threshold, the multiple frames of original phase images under different exposure times are collected based on the preset masked pixel points.

[0020] Optionally, the collecting of multiple frames of original phase images at different exposure times based on preset masked pixels includes:

[0021] Determining odd pixel rows and even pixel rows in the preview image based on the positions of the preset masked pixel points in the preview image;

[0022] Under the different exposure time lengths, scanning odd-numbered pixel rows and even-numbered pixel rows in the preview image to generate a plurality of odd-numbered pixel rows and a plurality of even-numbered pixel rows;

[0023] The plurality of odd-numbered rows of pixels and the plurality of even-numbered rows of pixels are merged to generate the plurality of frames of original phase images.

[0024] Optionally, determining the defocus position according to the target original phase image includes:

[0025] Determine a left phase pixel point and a right phase pixel point of the target original phase image at the preset masked pixel point;

[0026] Determine the phase difference value of the target original phase image by comparing the distance between the left phase pixel point and the right phase pixel point;

[0027] The defocus position is determined according to the phase difference value through a preset distance mapping model.

[0028] Optionally, a duration difference between any two exposure durations among the different exposure durations is greater than a set duration threshold.

[0029] According to a second aspect of an embodiment of the present disclosure, there is provided an automatic focusing device, comprising:

[0030] An acquisition module is configured to acquire multiple frames of original phase images under different exposure times, wherein each frame of the original phase image includes a phase pixel point corresponding to a preset masked pixel point;

[0031] A determination module is configured to determine a plurality of reliability weights corresponding to each of the plurality of frames of original phase images according to gradient information and / or brightness difference information between each pixel point and a neighboring pixel point in the plurality of frames of original phase images, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight;

[0032] A generating module is configured to perform pixel fusion on the pixel points at the same position in the multiple frames of original phase images based on the multiple reliability weights to generate a target original phase image;

[0033] The execution module is configured to determine a defocus position according to the target original phase image, and perform focusing based on the defocus position.

[0034] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:

[0035] a memory having a computer program stored thereon;

[0036] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods described in the first aspect of the present disclosure.

[0037] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of the autofocus method provided in the first aspect of the present disclosure are implemented.

[0038] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:

[0039] Through the above method, multiple frames of original phase images with different exposure times are obtained, wherein each frame of the original phase image includes a phase pixel corresponding to a preset masked pixel, and multiple reliability weights corresponding to each of the multiple frames of original phase images are determined according to the gradient information and / or brightness difference information between each pixel and the neighboring pixel in the multiple frames of original phase images, wherein the smaller the gradient of the pixel and / or the lower the brightness difference, the smaller the corresponding reliability weight, and based on the multiple reliability weights, the pixels at the same position in the multiple frames of original phase images are pixel fused to generate a target original phase image, and the defocus position is determined according to the target original phase image, and focusing is performed based on the defocus position. Thus, the overexposed or underexposed part in the image is compensated by image fusion, and the influence of ambient light on the PDAF focusing effect is avoided to obtain an accurate defocus position. Image shooting is performed based on the focus distance to improve image quality and enhance the user's photography experience.

[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0042] Figure 1 The figure is a flow chart of an automatic focusing method according to an exemplary embodiment.

[0043] Figure 2 It is a schematic diagram showing a pixel extraction method according to an exemplary embodiment.

[0044] Figure 3 The present invention is a flowchart of a method for determining a reliability weight according to an exemplary embodiment.

[0045] Figure 4 is a flow chart of another auto-focusing method according to an exemplary embodiment.

[0046] Figure 5 is a block diagram of an automatic focusing device according to an exemplary embodiment.

[0047] Figure 6 It is a block diagram of an electronic device according to an exemplary embodiment. DETAILED DESCRIPTION

[0048] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.

[0049] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.

[0050] During the PDAF focusing process, it is necessary to obtain the phase difference between phase detection pixels (also called shielded pixels) (phase detection pixel, PD pixel). The calculation of phase difference is crucial, and its result directly affects whether the focus can be clear. At present, the phase difference calculation mainly depends on the preset shielded pixels in the camera. Under sufficiently high-quality brightness shooting conditions, the image is photographed by shielding the pixels to generate an original phase image with a phase difference, and then the SAD (sum of difference) between the left shielded pixel and the right shielded pixel in the original phase image is calculated to obtain the phase difference value. Through the phase difference value, the focus distance can be calculated to achieve accurate focusing.

[0051] In the related art, the trust value of the phase difference value determined based on the PDAF calculation can be evaluated by a preset evaluation function. Generally, the higher the trust value, the more accurate the calculation of the phase difference value, and the lower the trust value, the less reliable the phase difference value. However, since the phase difference value is easily affected by the brightness of the ambient light, especially in a dark or overexposed environment, the measurement and calculation of the phase difference may not be accurate enough. Therefore, in this case, the trust value corresponding to the phase difference value will be greatly reduced, or, in this case, there is a possibility of an error in the calculation of the phase difference value, that is, an abnormal value with a high corresponding trust but an inaccurate actual phase difference value. In addition, the phase difference value may be affected by the noise of the shooting environment. For example, in a shooting scene with large environmental noise interference, the original phase image obtained by shooting is affected by noise, resulting in the position of the left occluded pixel point and / or the right occluded pixel point being offset, which in turn causes the phase difference value calculated by PDAF to be inaccurate. In summary, how to obtain an accurate phase difference value is of vital importance to improving the PDAF focusing performance.

[0052] Therefore, the present disclosure proposes an autofocus method, an apparatus, an electronic device and a storage medium to improve the calculation scheme of the optimized phase difference value for the PDAF focusing effect of the camera. Figure 1 is a flow chart of an automatic focusing method according to an exemplary embodiment. Figure 1 As shown, the method is used in a terminal device and includes the following steps.

[0053] In step S101, multiple frames of original phase images with different exposure times are acquired, wherein each frame of the original phase image includes phase pixel points corresponding to preset masked pixel points.

[0054] It is worth mentioning that the present embodiment is applied to a terminal device, which is a shooting device, and can capture images of the current environment and generate corresponding image data. For example, the terminal device can be a camera device, a mobile terminal device with a shooting function, a camera device, etc. The terminal device is equipped with PDAF technology for focusing processing. Regular and symmetrical shielding pixels are reserved on the photosensitive chip of the terminal device, and phase detection is performed by shielding the pixels, and focusing is performed based on the results of the phase detection. For example, a four-phase Bayer array sensor (QuadBayer sensor) is installed on the terminal device, and shielding pixels are reserved on the sensor. The shielding pixels are provided with left and right shielding plates. When the focus distance of the terminal device needs to be detected, the sensor is used to shoot the environment image. Based on the characteristics of the shielding pixel, the original phase image of the left and right phases will be generated at the same pixel. The focus distance of the current terminal device is determined by the phase difference of the original phase image at the same pixel.

[0055] For example, when shooting an image, the currently captured environmental image is displayed in the preview interface of the terminal device. Since the terminal device imitates the characteristics of human eye imaging, when shooting the environmental image, it is necessary to determine the focus of the imaging in order to display a clear environmental image in the preview interface. When the focus of the terminal device is inaccurate, a misplaced blurred image will appear in the preview interface, resulting in an unclear generated environmental image. Therefore, in the process of image shooting, it is necessary to determine the focus of the terminal device, and then make the terminal device shoot the image based on the focus to generate a higher-definition environmental image.

[0056] Specifically, the phase focusing PDAF technology can be used to determine the focus point. The focusing principle of PDAF is to image the photographed object through the masked pixels preset inside the chip, thereby imitating the imaging principle of the human eye. When shooting an image, a left phase image and a right phase image can be generated based on the masked pixels. By comparing the phase difference between the left and right phase images, the focus point with the smallest phase difference between the two can be determined, and this focus point can be regarded as a point with clear focus. Through the PDAF technology, a plurality of masked pixels are set on the photosensitive chip of the terminal device, and the masked pixels are respectively configured with left-right symmetrical masking plates. When shooting an image, for the position where the left-side masking plate is set, the light is blocked, and only the light on the right side can be irradiated on the photosensitive element, thereby generating a right phase image; for the position where the right-side masking plate is set, after the light is blocked, only the light on the left side can be irradiated on the photosensitive element, thereby generating a left phase image. By comparing the two phase images (left phase image and right phase image) formed based on the left and right shielding plates at the shielded pixel point, the current phase difference value of the terminal device is determined, and the focus point of the terminal device can be determined according to the phase difference value. For example, the point that minimizes the phase difference value can be determined as the focus point of the terminal device. Alternatively, the point that makes the phase difference value less than a preset threshold can be determined as the focus point of the terminal device.

[0057] For example, in this embodiment, when the terminal device performs image capture, due to the diversity of the shooting environment, the different shooting objects in the corresponding shooting environment have different degrees of reflection. For example, the mirror object facing the sun has a strong reflection effect. When it is in a brighter environment, the probability of overexposure corresponding to the mirror object increases; for a pure black object in the shooting environment, its reflection effect is weak, and when it is in a darker environment, the probability of underexposure corresponding to the pure black object increases. Therefore, based on the same shooting environment and the same exposure time, the reflection effects reflected by different shooting objects are different, resulting in the situation that some areas in the generated original phase image are overexposed, some areas are normal, and some areas are underexposed. Therefore, in this embodiment, by collecting multiple frames of original phase images with different exposure times, collecting multiple pixels with normal exposure at different exposure levels, an original phase image without exposure abnormalities is generated based on the multiple pixels.

[0058] On the basis of PDAF technology, based on the preset masked pixels in the corresponding chip of the terminal device, multiple frames of original phase images under different exposure times are collected, wherein each frame of the original phase image includes a phase pixel corresponding to the masked pixel, and the phase pixel is used to determine the phase difference value, and the original phase image also includes other ordinary pixels. By collecting multiple frames of images under different exposure times, image fusion is performed, so that the multiple frames of images are complemented. For example, when the terminal device is in a strong light environment for image shooting, setting the exposure time of the terminal device to normal, it is easy to generate overexposed image data due to the high ambient brightness, resulting in unclear images; therefore, multiple exposure times can be set to generate multiple frames of original images in the current environment, which may include overexposed images corresponding to normal exposure time in the current environment, exposure images with general exposure corresponding to shorter exposure time, and underexposed images with poor exposure corresponding to shorter exposure time. By adjusting the exposure time, the exposure degree of the original phase image in the image acquisition process is adjusted to generate multiple frames of original phase images with different exposure degrees. It should be noted that the focus position of the terminal device has not been adjusted at this time. Therefore, there are two phase images based on the left and right shielding plates in the original phase image generated based on the preset masked pixel points, that is, each frame of the original phase image includes a left phase image and a right phase image based on the preset masked pixel points.

[0059] Optionally, in one implementation, a duration difference between any two exposure durations among the different exposure durations is greater than a set duration threshold.

[0060] It should be noted that in this embodiment, it is necessary to ensure that the exposure levels of the multiple frames of original phase images are different, and the corresponding exposure level differences are large enough. Therefore, the different exposure durations include long-exposure original phase images and short-exposure original phase images. By setting the duration difference between the different exposure durations to be greater than the set duration threshold, it is ensured that the exposure levels of the generated multiple frames of original phase images are different, and images with different exposure levels are generated.

[0061] It is worth mentioning that in this embodiment, when the user presses the shutter button to capture the image, the terminal device will capture the original phase image based on the preset different exposure times and the preset time intervals. Among them, when the terminal device performs image capture based on different exposure times, in order to avoid the exposure parameters of the generated original phase image from affecting each other, it is necessary to set a time interval between different exposure times to separate the original phase image. For example, in this embodiment, a preset time interval can be set to separate the shooting time of multiple frames of original phase images to avoid interference from different exposure times and generate phase images with inaccurate exposure levels.

[0062] It should be understood that in the present disclosure, multiple frames of original phase images under different exposure times can be obtained based on masked pixels, that is, in the process of obtaining multiple frames of original phase images, the relevant information of the original phase images at the required corresponding positions can be obtained by masking the pixels, and of course, other pixels can also obtain the relevant information of the required original phase images. That is, in the present disclosure, multiple frames of original phase images under different exposure times can be obtained by masking pixels and non-masked pixels (pixels other than the masked pixels among multiple pixels), and the phase difference can be calculated to calculate the focus position to ensure the focus accuracy.

[0063] Optionally, in another implementation, before the above step S101, the method further includes:

[0064] When an exposure abnormality is detected in the preview image, the area ratio of the exposure abnormality region in the preview image is obtained;

[0065] If the area ratio is greater than the set ratio threshold, multiple frames of original phase images with different exposure times are collected.

[0066] Normally, when the terminal device collects environmental images, the ambient light based on the current environment may be divided into overexposure, normal and underexposure. In the case of overexposure and underexposure, it is easy to cause a large deviation in the focus position determined based on the PDAF technology, while under normal circumstances, the ambient light brightness will not affect the focus effect of PDFA. Therefore, when generating a preview image for the collected environmental image, it is possible to detect whether there is an area with abnormal exposure in the preview image, such as an overexposed or underexposed area. In this embodiment, when it is determined through monitoring that there is an exposure abnormality in the preview image, the area ratio of the exposure abnormality area in the preview image is determined. When the area ratio is greater than the set ratio threshold, multiple frames of original phase images with different exposure times are collected based on the preset masked pixel points; when the area ratio is less than or equal to the set ratio threshold, the phase difference in the image is directly calculated based on the PDAF technology. For example, the set ratio threshold can be set to 10%. When the exposure abnormality area in the preview image exceeds 10%, it is necessary to fuse multiple frames of original phase images through image fusion to generate a target original phase image, and determine the phase difference value based on the target original phase image, thereby avoiding the problem of inaccurate focusing due to inaccurate phase difference calculation caused by overexposure or underexposure caused by using the traditional PDAF method to determine the phase difference value.

[0067] Optionally, in another implementation, the above step S101 may include:

[0068] Based on the position of the preset masked pixel point in the preview image, determining the odd pixel rows and the even pixel rows in the preview image;

[0069] Under different exposure times, the odd-numbered pixel rows and the even-numbered pixel rows in the preview image can be scanned with the preset shielded pixel points as reference points to generate multiple odd-numbered pixel rows and multiple even-numbered pixel rows;

[0070] Multiple odd-numbered rows of pixels and multiple even-numbered rows of pixels are fused to generate multiple frames of original phase images.

[0071] It is worth mentioning that in the present embodiment, in order to improve the scanning order of image pixels, the preview image can be scanned in double rows based on the position of the preset masked pixels in the preview image, thereby improving the scanning efficiency of the preview image. By way of example, in the present embodiment, a row number system is established based on the position of the preset masked pixels in the preview image, and the odd pixel rows and even pixel rows in the preview image are determined according to the row number system. Through the odd pixel rows and even pixel rows in the preview image, the pixels of the odd pixel rows and even pixel rows in the preview image are scanned simultaneously at different exposure times to generate multiple counting pixels and multiple even row pixels, and then the multiple odd row pixels and multiple even row pixels are fused to generate multiple frames of original phase images. By way of example, Figure 2 is a schematic diagram of a pixel extraction method according to an exemplary embodiment. Figure 2 As shown, during the exposure process, staggered exposure parameters are set for the rows where the pixels are located, for example, long exposure for odd rows and short exposure for even rows. The scanning process is to read the odd rows from top to bottom, and then read the even rows from top to bottom, so that each row is read once, and the original phase image obtained from the odd rows and the original phase image obtained from the even rows are fused together.

[0072] In step S102, multiple reliability weights corresponding to each of the multiple frames of original phase images are determined based on the gradient information and / or brightness difference information between each pixel point in the multiple frames of original phase images and the neighboring pixel points, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight.

[0073] It is worth mentioning that when the shooting environment is too bright or dim, there will be overexposure or underexposure in the image collected by the terminal device. Correspondingly, when the original phase image generated by the sensor based on the shooting environment is collected, there will also be abnormal display areas. For example, when there is overexposure in the image, the corresponding position in the original phase image will show a white area, thereby affecting the image quality; when there is underexposure in the image, the corresponding position in the original phase image will show a black area, resulting in unclear shooting objects, affecting the image quality. Overexposure or underexposure of pixels is a representation of pixel brightness and / or gradient, that is, when the corresponding pixel brightness exceeds the first preset value based on the current exposure time, the pixel is likely to be overexposed; when the corresponding pixel brightness is lower than the second preset value based on the current exposure time, the pixel is likely to be underexposed.

[0074] Therefore, in this embodiment, for the original phase image corresponding to any frame in the multiple frames of original phase images, the gradient information and / or brightness difference information between each pixel of the image and the neighboring pixel is determined, and multiple reliability weights corresponding to each of the multiple frames of original phase images are determined according to the gradient information and / or brightness difference information. The gradient information is used to indicate the grayscale change between each pixel in the image. The greater the grayscale value change between adjacent pixels, the greater the corresponding gradient value. Generally, based on the diversity of the shooting environment, the gradient and / or brightness difference corresponding to the pixels at different positions in the image is large. Therefore, in this embodiment, the reliability weight of the corresponding pixel is determined by determining the gradient and / or brightness difference between each pixel in the original phase image and the neighboring pixel. Among them, the smaller the gradient and / or the lower the brightness difference of the pixel, the smaller the gap between the pixel and the neighboring pixel, and the greater the possibility that the corresponding pixel is in the overexposed area or the underexposed area. The neighboring pixel is based on the resolution of the current terminal device, with the current pixel as the reference, and other pixels in the original phase image within a preset range. For example, the first circle of pixel points surrounding the pixel point in the original phase image is determined as the neighborhood pixel points of the pixel point, or to improve the screening accuracy, the first circle of pixel points and the second circle of pixel points surrounding the pixel point are determined as the neighborhood pixel points of the pixel point.

[0075] In step S103, pixel fusion is performed on pixels at the same position in multiple frames of original phase images based on multiple reliability weights to generate a target original phase image.

[0076] It is worth mentioning that in this embodiment, the larger the reliability weight of the corresponding pixel point, the higher the reliability of the pixel point. Therefore, pixel fusion can be performed based on the reliability weight of the pixel point at the same position in the multiple frames of original phase images. For example, the reliability weight of the pixel point can be set to an evaluation interval of [0-10] according to the gradient information and / or the brightness difference information. When the gradient information between the pixel point and the neighboring pixel point is 0 and / or the brightness difference information is 0, the reliability weight corresponding to the pixel point is determined to be 0; when the gradient information of the pixel point is greater than the gradient threshold, and / or the brightness difference information is greater than the threshold, the reliability weight corresponding to the pixel point is determined to be 10. The reliability weight of each pixel point is determined by setting the evaluation parameters, and the multiple frames of original phase images are pixel-fused according to the reliability weight to generate the target original phase image. Among them, each pixel point in the target original phase image is weighted and generated based on the reliability weight. The target original phase image is generated by fusing multiple frames of original phase images with different exposure times based on the exposure probability of each pixel. For example, the first normal exposure area in the overexposed original phase image with a long exposure time can be extracted in this way, and then the second normal exposure area in the underexposed original phase image with a short exposure time can be extracted. Then, based on the position of each pixel in the original phase image, the first normal exposure area and the second normal area are fused to generate the target original phase image.

[0077] For example, in one implementation, based on the above method, the embodiment of the present disclosure also proposes an image fusion method, by fusing multiple frames of images under different exposure times, generating a target image without exposure abnormality, thereby improving image quality. For example, when the user presses the shutter, multiple frames of images under different exposure times are obtained through the terminal device, wherein, in order to improve the user's shooting experience, the interval between the exposure times is very short, and the user is difficult to perceive based on the naked eye. From the user's perspective, after pressing the shutter, the terminal device only performs one exposure shot. Compare each pixel point in the multi-frame image with the surrounding pixel points to determine whether the pixel point is a pixel point with abnormal exposure. It is worth mentioning that under normal circumstances, the brightness difference or gradient difference between the pixel point in the abnormal exposure area and the surrounding pixel points is small. Therefore, it can be determined whether the corresponding pixel point is a pixel point with abnormal exposure based on this characteristic. When it is determined that the pixel point is a pixel point corresponding to the abnormal exposure area, the fusion weight of the pixel point is reduced when performing image fusion. For example, the reliability weight corresponding to each pixel in the multiple frames of original images can be determined based on the gradient information and / or brightness difference information between each pixel in the multiple frames of images and the neighboring pixels, wherein the smaller the gradient of the pixel and / or the lower the brightness difference, the smaller the corresponding reliability weight, and based on the reliability weight, the pixels at the same position in the multiple frames of images are fused to generate the target image.

[0078] Through the above method, multiple frame images with different exposure times are applied, and the reliability of each pixel is determined according to the brightness difference and / or gradient information between each pixel and the neighboring pixels in the multiple frame images. The pixels are fused according to the reliability, so as to obtain a target image without exposure anomalies, thereby improving the user's image shooting experience.

[0079] In step S104, by presetting masked pixel points and according to the target original phase image, a defocus position is determined, and focusing is performed based on the defocus position.

[0080] For example, the target original phase image generated by the above steps in this embodiment is generated based on the complementary fusion of multiple frames of original phase images under multiple exposure times. Therefore, there is no overexposed area or underexposed area in the target original phase image, and the defocus position is determined based on the target original phase image, thereby avoiding the problem that the generated target original phase image is inaccurate due to the ambient light being too bright or too dark, resulting in low confidence in the defocus position. For example, the defocus position of the target original phase image can be determined by a preset distance mapping model. Then, the focus position of the terminal device is adjusted according to the defocus position, thereby completing the automatic focus of the terminal device.

[0081] Optionally, in another implementation, the above step of “determining the defocus position according to the target original phase image” may include:

[0082] Determine a left phase pixel point and a right phase pixel point of the target original phase image at a preset masked pixel point;

[0083] By comparing the distance between the left phase pixel point and the right phase pixel point, the phase difference value of the target original phase image is determined;

[0084] According to the phase difference value, the defocus position is determined through a preset distance mapping model.

[0085] For example, in this embodiment, after the target original phase image is generated through the above steps, the left phase pixel and the right phase pixel of the preset masked pixel are determined based on the position of the preset masked pixel in the target original phase image, and the distance between each phase pixel at the same preset masked pixel is compared to determine the phase difference value of the target original phase image. The phase difference value is input into the preset distance mapping model to determine the defocus position of the terminal device.

[0086] Through the above method, multiple frames of original phase images with different exposure times are obtained by presetting masked pixels, and multiple reliability weights corresponding to each of the multiple frames of original phase images are determined according to the gradient information and / or brightness difference information between each pixel in the multiple frames of original phase images and the neighboring pixels, wherein the smaller the gradient of the pixel and / or the lower the brightness difference, the smaller the corresponding reliability weight. Based on the multiple reliability weights, the pixels at the same position in the multiple frames of original phase images are pixel-fused to generate the target original phase image, and the defocus position is determined according to the target original phase image, and focusing is performed based on the defocus position. Thus, the overexposed or underexposed part in the image is compensated by image fusion, and the influence of ambient light on the PDAF focusing effect is avoided to obtain an accurate defocus position. Image shooting is performed based on the focus distance to improve image quality and enhance the user's photo-taking experience.

[0087] Figure 3 is a flow chart showing a method for determining a reliability weight according to an exemplary embodiment. Figure 3 As shown, the above step S102 includes the following steps.

[0088] In step S201, a first irradiance image of each pixel in the first original phase image is determined according to a first exposure duration and first grayscale information of the first original phase image, wherein the first original phase image is any image in a plurality of frames of original phase images.

[0089] It is worth mentioning that the overexposure and underexposure of the image are related to the light intensity in the environment. Therefore, the reliability weight of the corresponding pixel point can be determined according to the irradiance reflected by each pixel point in the original phase image. For example, in this embodiment, for the first original phase image, the irradiance of each pixel point in the first original phase image is determined according to the first exposure time corresponding to the first original phase image and the first grayscale information of each pixel point in the first original phase image, and the first irradiance image is generated according to the irradiance of each pixel point. The first original phase image is any image in the multiple frames of original phase images.

[0090] Optionally, in one implementation, the above step S201 includes:

[0091] According to the first exposure time and the first grayscale information, a first irradiance image is determined by an irradiance calibration function, wherein the irradiance calibration function is determined by:

[0092] The data of multiple irradiances under multiple calibrated exposure times and multiple calibrated grayscale information are fitted by the least square method to generate an irradiance curve;

[0093] According to the irradiance curve, determine the irradiance calibration function.

[0094] It is worth mentioning that in this embodiment, the relationship between exposure time, grayscale information and irradiance can be determined through experiments. For example, the relationship between the three can be determined according to the specific exposure time of the test part. After determining the specific exposure time, the grayscale value of the pixel in the image is adjusted, and then the irradiance at different grayscale values ​​in the image is calibrated. Then, the test data is fitted using the least squares method to generate curve parameters, and the following irradiance calibration function is determined according to the curve parameters;

[0095] E(i, j) = Func(T(i)*I(j))

[0096] Wherein, E(i, j) is the irradiance of the i-th, j-th pixel, T(i) is the exposure time of the i-th exposure, I(j) is the actual gray value information of the j-th pixel, and Func() is the irradiance calibration function.

[0097] In step S202, a first reliability weight of each pixel is determined based on gradient information and / or brightness difference information between each pixel and neighboring pixels in the first irradiance image.

[0098] For example, after determining the irradiance image of each pixel in the first original phase image in the above manner, the gradient information and / or brightness difference information between each pixel and other pixels in the neighborhood is compared based on the irradiance image, and the reliability weight of each pixel is determined according to the gradient information and / or brightness difference information. In this embodiment, the method of determining the reliability weight according to the gradient information and / or brightness difference information is the same as in the above step S102, and can refer to the above step S102, and will not be repeated.

[0099] In step S203, multiple frames of original phase images are traversed to generate multiple reliability weights.

[0100] For example, for multiple frames of original phase images, the reliability weight of each pixel in each frame of the original phase image can be determined by referring to the above method.

[0101] Optionally, the disclosed embodiment also provides another image fusion method through the above method. After a terminal device shoots multiple frames of images under different exposure times, the irradiance information of each pixel of each frame of the image is determined according to the exposure time and grayscale information corresponding to each frame of the image, and the irradiance image corresponding to each frame of the image is generated according to the irradiance information. The irradiance of each pixel in the irradiance image is compared with the irradiance of the neighboring pixel, and the gradient information and / or brightness difference information between each pixel and the neighboring pixel is determined. The reliability weight of each pixel when performing image fusion is determined according to the gradient signal and / or the brightness difference information, and the image fusion is performed according to multiple reliability weights of the pixel at the same position in each frame of the image, so as to generate a target image without exposure abnormality. In this embodiment, based on the exposure time and grayscale information of each pixel in the image, the real irradiance of each pixel is determined, and the weight value of each pixel is determined according to the real irradiance, so as to obtain a more accurate weight value of each pixel, so that the obtained target image is more accurate.

[0102] Through the above method, the gradient information and / or brightness difference information between each pixel point and the neighboring pixel points in each frame of the original phase image is determined based on the irradiance image, and then the reliability weight of each pixel point is determined based on the information, so as to determine whether the pixel point is an abnormally exposed pixel point based on the actual brightness of each pixel point, thereby improving the trust value of the reliability weight and making the obtained defocus position more accurate.

[0103] Figure 4 is a flow chart of another auto-focusing method according to an exemplary embodiment. Figure 4 As shown, the method includes the following steps.

[0104] 1. Open the terminal device and preview the environment image;

[0105] 2. Obtain the lighting information in the environment and determine whether the area of ​​the abnormal exposure area in the picture occupies more than 5% of the picture; if so, the HDR (High Dynamic Range Imaging) opening condition is met; if not, it means that the ambient lighting is appropriate, and the odd and even rows of pixel points are masked to set the appropriate exposure time to generate the original phase image;

[0106] 3. When there is an abnormal exposure area, long exposure and short exposure are set on the sensor end of the terminal device. After one shot, two original phase images with different exposure amounts are generated.

[0107] 4. Restore the irradiance image: According to the exposure time and gray value, the original irradiance of the original phase image is obtained. The irradiance can be calculated according to the following formula:

[0108] E(i, j) = Func(T(i)*I(j))

[0109] Wherein, E(i, j) is the irradiance of the i-th, j-th pixel, T(i) is the exposure time of the i-th exposure, I(j) is the actual gray value information of the j-th pixel, and Func() is the irradiance calibration function.

[0110] The calibration can be performed based on the specific exposure time of the test part and the corresponding irradiance obtained by the grayscale of the pixel points in the image, and then the test data can be fitted using the least squares method to obtain the curve parameters, and then the actual exposure time and the image pixel grayscale value can be calculated for the corresponding irradiance. Theoretically, if there is no noise, then according to step 4, it can be completely fused into a target original phase image, that is, the original phase image obtained with other exposure times can be used to compensate for the over-exposure and under-exposure parts in an original phase image. However, considering that the calculated irradiance has a certain uncertainty, we need the one with the smallest uncertainty, so we need to use the weight map to fit the long-exposure original phase image and the short-exposure original phase image.

[0111] 5. Calculate the gradient information and brightness difference information between the masked pixel and the neighboring pixel in the original phase image obtained at different exposure times to examine the reliability of the irradiance image generated by the pixel, and then determine the weight map corresponding to the two original phase images with different exposure times. The weight of each pixel of an image is synthesized according to the radiance image to generate an irradiance weight map.

[0112] 6. Using the weight map, the two original phase maps of different exposures are fused to form a target original phase map.

[0113] 7. The target original phase map is passed into the PDlib algorithm code to calculate the phase difference value and the corresponding confidence of the phase difference value. After the fusion of the two original images, the obtained phase difference value is calculated more accurately, especially the phase difference value of the underexposed and overexposed areas is significantly optimized.

[0114] 8. Calculate the phase difference and trust, obtain the defocus distance through model mapping, and move the motor position to focus according to the defocus distance.

[0115] Through the above method, when there is exposure abnormality in the image, after generating multiple frames of images by adjusting the exposure time, the multiple frames of images are fused to avoid the influence of the exposure abnormality on the phase difference value, which can greatly improve the camera PDAF focusing effect, especially in dark light and overexposed environments, and improve the user's photo-taking experience.

[0116] Figure 5 is a block diagram of an automatic focusing device according to an exemplary embodiment. Figure 5The device includes a collection module 110, a determination module 120, a generation module 130 and an execution module 140.

[0117] The acquisition module 110 is configured to acquire multiple frames of original phase images under different exposure times, wherein each frame of the original phase image includes a phase pixel point corresponding to a preset masked pixel point;

[0118] The determination module 120 is configured to determine a plurality of reliability weights corresponding to each of the multiple frames of original phase images according to the gradient information and / or brightness difference information between each pixel point and the neighboring pixel points in the multiple frames of original phase images, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight;

[0119] The generating module 130 is configured to perform pixel fusion on pixels at the same position in multiple frames of original phase images based on multiple reliability weights to generate a target original phase image;

[0120] The execution module 140 is configured to determine a defocus position according to the target original phase image, and perform focusing based on the defocus position.

[0121] Optionally, the determination module 120 includes:

[0122] A first determination submodule is configured to determine a first irradiance image of each pixel in the first original phase image according to a first exposure time and first grayscale information of the first original phase image, wherein the first original phase image is any image in the multiple frames of original phase images;

[0123] A second determination submodule is configured to determine a first reliability weight of each pixel point according to gradient information and / or brightness difference information between each pixel point and neighboring pixel points in the first irradiance image;

[0124] The generating submodule is configured to traverse multiple frames of original phase images and generate multiple reliability weights.

[0125] Optionally, the first determining submodule is configured to:

[0126] According to the first exposure time and the first grayscale information, a first irradiance image is determined by an irradiance calibration function, wherein the irradiance calibration function is determined by:

[0127] The data of multiple irradiances under multiple calibrated exposure times and multiple calibrated grayscale information are fitted by the least square method to generate an irradiance curve;

[0128] According to the irradiance curve, determine the irradiance calibration function.

[0129] Optionally, the acquisition module 110 is configured to:

[0130] When an exposure abnormality is detected in the preview image, the area ratio of the exposure abnormality region in the preview image is obtained;

[0131] If the area ratio is greater than the set ratio threshold, multiple frames of original phase images with different exposure times are collected based on the preset masked pixels.

[0132] Optionally, the acquisition module 110 is configured to:

[0133] Based on the position of the preset masked pixel point in the preview image, determining the odd pixel rows and the even pixel rows in the preview image;

[0134] Under different exposure times, odd-numbered pixel rows and even-numbered pixel rows in the preview image are scanned to generate a plurality of odd-numbered pixel rows and a plurality of even-numbered pixel rows;

[0135] Multiple odd-numbered rows of pixels and multiple even-numbered rows of pixels are fused to generate multiple frames of original phase images.

[0136] Optionally, the execution module 140 is configured to:

[0137] Determine a left phase pixel point and a right phase pixel point of the target original phase image at a preset masked pixel point;

[0138] By comparing the distance between the left phase pixel point and the right phase pixel point, the phase difference value of the target original phase image is determined;

[0139] According to the phase difference value, the defocus position is determined through a preset distance mapping model.

[0140] Optionally, a duration difference between any two exposure durations among the different exposure durations is greater than a set duration threshold.

[0141] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0142] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, and the program instructions, when executed by a processor, implement the steps of the auto-focusing method provided by the present disclosure.

[0143] Figure 6 is a block diagram of an electronic device 600 according to an exemplary embodiment. For example, the electronic device 600 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0144] Reference Figure 6 , the electronic device 600 may include one or more of the following components: a processing component 602 , a memory 604 , a power component 606 , a multimedia component 607 , an audio component 610 , an input / output interface 612 , a sensor component 614 , and a communication component 616 .

[0145] The processing component 602 generally controls the overall operation of the electronic device 600, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 602 may include one or more modules to facilitate the interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate the interaction between the multimedia component 607 and the processing component 602.

[0146] The memory 604 is configured to store various types of data to support operations on the electronic device 600. Examples of such data include instructions for any application or method operating on the electronic device 600, contact data, phone book data, messages, pictures, videos, etc. The memory 604 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0147] The power supply component 606 provides power to the various components of the electronic device 600. The power supply component 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the electronic device 600.

[0148] The multimedia component 607 includes a screen that provides an output interface between the electronic device 600 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 607 includes a front camera and / or a rear camera. When the electronic device 600 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0149] The audio component 610 is configured to output and / or input audio signals. For example, the audio component 610 includes a microphone (MIC), and when the electronic device 600 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 604 or sent via the communication component 616. In some embodiments, the audio component 610 also includes a speaker for outputting audio signals.

[0150] The input / output interface 612 provides an interface between the processing component 602 and the peripheral interface modules, which may be keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0151] The sensor assembly 614 includes one or more sensors for providing various aspects of status assessment for the electronic device 600. For example, the sensor assembly 614 can detect the open / closed state of the electronic device 600, the relative positioning of the components, such as the display and keypad of the electronic device 600, and the sensor assembly 614 can also detect the position change of the electronic device 600 or a component of the electronic device 600, the presence or absence of contact between the user and the electronic device 600, the orientation or acceleration / deceleration of the electronic device 600, and the temperature change of the electronic device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 614 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0152] The communication component 616 is configured to facilitate wired or wireless communication between the electronic device 600 and other devices. The electronic device 600 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 616 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 616 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0153] In an exemplary embodiment, the electronic device 600 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the above methods.

[0154] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 604 including instructions, and the instructions can be executed by a processor 620 of an electronic device 600 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0155] In addition to being an independent electronic device, the above-mentioned device can also be a part of an independent electronic device. For example, in one embodiment, the device can be an integrated circuit (IC) or a chip, wherein the integrated circuit can be an IC or a collection of multiple ICs; the chip can include but is not limited to the following types: GPU (Graphics Processing Unit), CPU (Central Processing Unit), FPGA (Field Programmable Gate Array), DSP (Digital Signal Processor), ASIC (Application Specific Integrated Circuit), SOC (System on Chip, SoC), etc. The above-mentioned integrated circuit or chip can be used to execute executable instructions (or codes) to implement the above-mentioned auto-focus method. The executable instructions can be stored in the integrated circuit or chip, or can be obtained from other devices or equipment, such as the integrated circuit or chip including a processor, a memory, and an interface for communicating with other devices. The executable instruction may be stored in the memory, and when the executable instruction is executed by the processor, the above-mentioned auto-focus method is implemented; alternatively, the integrated circuit or chip may receive the executable instruction through the interface and transmit it to the processor for execution, so as to implement the above-mentioned auto-focus method.

[0156] In another exemplary embodiment, a computer program product is further provided. The computer program product includes a computer program executable by a programmable device. The computer program has a code portion for executing the above-mentioned auto-focus method when executed by the programmable device.

[0157] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.

[0158] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.

Claims

1. An automatic focusing method, characterized in that: The method comprises: Acquire multiple frames of original phase images under different exposure times, wherein each frame of the original phase image includes a phase pixel point corresponding to a preset masked pixel point; Determine the reliability weight corresponding to each of the multiple frames of original phase images according to the gradient information and / or brightness difference information between each pixel point and the neighboring pixel points in the multiple frames of original phase images, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight; Based on the reliability weight, pixel fusion is performed on the pixel points at the same position in the multiple frames of original phase images to generate a target original phase image; By presetting masked pixel points, a defocus position is determined according to the target original phase image, and focusing is performed based on the defocus position.

2. The method according to claim 1, characterized in that Determining a plurality of reliability weights corresponding to each of the plurality of frames of original phase images according to the gradient information and / or brightness difference information between each pixel point and a neighboring pixel point in the plurality of frames of original phase images comprises: Determine a first irradiance image of each pixel in the first original phase image according to a first exposure time and first grayscale information of the first original phase image, wherein the first original phase image is an image corresponding to any frame in the multiple frames of original phase images; Determine a first reliability weight of each pixel point according to gradient information and / or brightness difference information between each pixel point and neighboring pixel points in the first irradiance image; The multiple frames of original phase images are traversed to generate the multiple reliability weights.

3. The method according to claim 2, characterized in that The step of determining a first irradiance image of each pixel in the first original phase image according to the first exposure time and the first grayscale information of the first original phase image includes: The first irradiance image is determined by an irradiance calibration function according to the first exposure time and the first grayscale information, wherein the irradiance calibration function is determined by: Performing data fitting on the multiple calibrated exposure times and multiple irradiances under the multiple calibrated grayscale information by using the least square method to generate an irradiance curve; The irradiance calibration function is determined according to the irradiance curve.

4. The method according to claim 1, characterized in that: The step of acquiring multiple frames of original phase images at different exposure times includes: When an exposure abnormality is detected in the preview image, obtaining the area ratio of the exposure abnormality region in the preview image; If the area ratio is greater than a set ratio threshold, the multiple frames of original phase images under different exposure times are collected.

5. The method according to claim 1, characterized in that The step of acquiring multiple frames of original phase images at different exposure times includes: Determining odd pixel rows and even pixel rows in the preview image based on the positions of the preset masked pixel points in the preview image; Under the different exposure time lengths, scanning odd-numbered pixel rows and even-numbered pixel rows in the preview image to generate a plurality of odd-numbered pixel rows and a plurality of even-numbered pixel rows; The plurality of odd-numbered rows of pixels and the plurality of even-numbered rows of pixels are merged to generate the plurality of frames of original phase images.

6. The method according to claim 1, characterized in that Determining the defocus position according to the target original phase image includes: Determine a left phase pixel point and a right phase pixel point of the target original phase image at the preset masked pixel point; Determine the phase difference value of the target original phase image by comparing the distance between the left phase pixel point and the right phase pixel point; The defocus position is determined according to the phase difference value.

7. The method according to any one of claims 1 to 6, characterized in that A duration difference between any two exposure durations among the different exposure durations is greater than a set duration threshold.

8. An automatic focusing device, characterized in that: include: An acquisition module is configured to acquire multiple frames of original phase images under different exposure times, wherein each frame of the original phase image includes a phase pixel point corresponding to a preset masked pixel point; A determination module is configured to determine a plurality of reliability weights corresponding to each of the plurality of frames of original phase images according to gradient information and / or brightness difference information between each pixel point and a neighboring pixel point in the plurality of frames of original phase images, wherein the smaller the gradient of the pixel point and / or the lower the brightness difference, the smaller the corresponding reliability weight; A generating module is configured to perform pixel fusion on the pixel points at the same position in the multiple frames of original phase images based on the multiple reliability weights to generate a target original phase image; The execution module is configured to determine a defocus position according to the target original phase image, and perform focusing based on the defocus position.

9. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 7.

10. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.