Focusing method and device, electronic equipment, chip and medium
By obtaining PDAF and TOF parameters and adjusting the search range parameters of CAF, the problem of poor focus efficiency and accuracy in dark environments is solved, and efficient focus in dark environments is achieved.
Patent Information
- Application Number
- CN202410124189.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-29
- Publication Date
- 2025-07-29
AI Technical Summary
In dark environment scenarios where neither PDAF nor TOF algorithms are available, traditional autofocus methods lead to low focus efficiency and poor accuracy and poor user experience.
By obtaining the parameters of PDAF and TOF, the lighting intensity is judged, and the search range parameters of CAF are adjusted when the conditions are met, and the adjusted CAF parameters are used for focus.
In dark environments, the focus efficiency and accuracy are improved, the focus time is shortened, and the user experience is improved.
Smart Images

Figure CN120390143A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of autofocus, and in particular, to a focusing method, device, electronic device, chip, and medium. Background Art
[0002] Autofocus technology is one of the core technologies of digital cameras. Currently, the commonly used autofocus methods mainly include phase detection autofocus (PDAF) algorithms, contrast autofocus (CAF) algorithms, and time-of-flight (TOF) algorithms, etc. Summary of the Invention
[0003] The present disclosure provides a focusing method, device, electronic device, chip, and medium. By obtaining the focusing parameters of PDAF and TOF, and then judging the light intensity, in a dark environment scene, based on the focusing parameters of TOF, the search range parameter of CAF is adjusted for focusing search, so as to achieve the effects of improving the focusing efficiency and accuracy and shortening the focusing time.
[0004] In a first aspect embodiment of the present disclosure, a focusing method is proposed. The method includes: in response to a focusing operation instruction received by an electronic device, obtaining a first parameter of phase detection autofocus (PDAF) and a second parameter of time-of-flight autofocus (TOF) in the electronic device, where the first parameter includes the defocus value and the first credibility of PDAF, and the second parameter includes the distance value and the second credibility of TOF; when the first parameter and the second parameter meet a first preset condition, obtaining the light intensity of the environment where the electronic device is currently located; when the light intensity meets a second preset condition, adjusting the search range parameter of contrast autofocus (CAF) according to the distance value of TOF; and performing focusing using the adjusted search range parameter of CAF.
[0005] In some embodiments of the present disclosure, obtaining the first parameter of PDAF and the second parameter of TOF includes: inputting multiple frames of test images; respectively using PDAF and TOF to perform focusing on the multiple frames of test images; and obtaining the defocus value and the first credibility of PDAF for each frame of test image, and the distance value and the second credibility of TOF for each frame of test image.
[0006] In some embodiments of the present disclosure, when the light intensity meets a second preset condition, adjusting the search range parameter of contrast autofocus (CAF) according to the distance value of TOF includes: obtaining the distance value of TOF and the hyperfocal position; mapping the distance value to a first position; based on the first position, setting a second position as the nearest search position of the search range parameter, where the second position is between the first position and the lens position of the electronic device; and setting the hyperfocal position as the farthest search position of the search range parameter.
[0007] In some embodiments of the present disclosure, performing focusing using the adjusted search range parameter of CAF includes: setting a coarse search step and a fine search step; starting from the farthest search position and ending at the nearest search position, performing focusing according to the coarse search step and the fine search step.
[0008] In some embodiments of the present disclosure, the first preset condition is that the first confidence level and the second confidence level are less than or equal to a first threshold; the second preset condition is that the light intensity is less than a second threshold.
[0009] In some embodiments of the present disclosure, the method further includes: when neither the first parameter nor the second parameter satisfies the first preset condition, performing focusing using PDAF; when the first parameter satisfies the first preset condition and the second parameter does not satisfy the first preset condition, performing focusing using TOF; when the second parameter satisfies the first preset condition and the first parameter does not satisfy the first preset condition, performing focusing using PDAF.
[0010] In some embodiments of the present disclosure, the method further includes: when the light intensity does not satisfy the second preset condition, performing focusing using the original search range parameter of CAF.
[0011] An embodiment of the second aspect of the present disclosure provides a focusing device, including: a focusing module, configured to obtain a first parameter of phase detection autofocus (PDAF) and a second parameter of time of flight (TOF) in an electronic device in response to a focusing operation instruction received by the electronic device, where the first parameter includes a defocus value and a first confidence level of PDAF, and the second parameter includes a distance value and a second confidence level of TOF; when the first parameter and the second parameter satisfy the first preset condition, obtaining the light intensity of the environment where the electronic device is currently located; when the light intensity satisfies the second preset condition, adjusting the search range parameter of contrast autofocus (CAF) according to the distance value of TOF; and performing focusing using the adjusted search range parameter of CAF.
[0012] An embodiment of the third aspect of the present disclosure provides an electronic device, including: a processor and a memory for storing a computer program that can run on the processor, where the processor is configured to execute the method described in any one of the embodiments of the first aspect of the present disclosure when running the computer program.
[0013] An embodiment of the fourth aspect of the present disclosure provides a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause a computer to execute the method described in any one of the embodiments of the first aspect of the present disclosure.
[0014] A fifth aspect embodiment of the present disclosure provides a chip, including at least one processor and a communication interface. The communication interface is configured to receive signals input to the chip or signals output from the chip. The processor communicates with the communication interface and implements the method described in any one of the embodiments of the first aspect of the present disclosure through logic circuits or by executing code instructions.
[0015] In summary, the focus method, device, electronic device, chip, and medium provided by the present disclosure include: in response to a focus operation instruction received by the electronic device, obtaining a first parameter of the phase detection autofocus (PDAF) and a second parameter of the time-of-flight (TOF) in the electronic device. The first parameter includes the defocus value and the first credibility of the PDAF, and the second parameter includes the distance value and the second credibility of the TOF. When the first parameter and the second parameter meet a first preset condition, obtaining the light intensity of the environment where the electronic device is currently located. When the light intensity meets a second preset condition, adjusting the search range parameter of the contrast autofocus (CAF) according to the distance value of the TOF. Using the adjusted search range parameter of the CAF for focusing. The method provided by the present disclosure can, based on the judgment of credibility, in a dark environment scenario where both the PDAF and the TOF are not credible, adjust the search range parameter of the CAF according to the parameters of the TOF, and use the adjusted search range parameter of the CAF for focusing, which can improve the focusing efficiency and accuracy in the dark environment scenario.
[0016] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The accompanying drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present disclosure, and are used together with the specification to explain the principles of the present disclosure, and do not constitute an improper limitation to the present disclosure.
[0018] Figure 1 It is a flowchart showing a focus method provided by an embodiment of the present disclosure;
[0019] Figure 2 It is a flowchart of a method for obtaining the first parameter of the PDAF and the second parameter of the TOF provided by an embodiment of the present disclosure;
[0020] Figure 3 It is a flowchart of a method for adjusting the search range parameter of the CAF according to the distance value of the TOF provided by an embodiment of the present disclosure;
[0021] Figure 4 It is a flowchart of a method for focusing using the adjusted search range parameter of the CAF provided by an embodiment of the present disclosure;
[0022] Figure 5 It is a flowchart showing a focus method provided by an embodiment of the present disclosure;
[0023] Figure 6 Schematic flowchart of a focusing method proposed by an embodiment of the present disclosure;
[0024] Figure 7A Schematic flowchart of a focusing method provided by the present disclosure;
[0025] Figure 7B Schematic diagram of the search range of the adjusted CAF provided by the present disclosure;
[0026] Figure 8 Schematic structural diagram of a focusing device proposed by an embodiment of the present disclosure;
[0027] Figure 9 Schematic structural diagram of an electronic device proposed by an embodiment of the present disclosure;
[0028] Figure 10 Schematic structural diagram of a chip proposed by an embodiment of the present disclosure. Detailed implementation manners
[0029] The embodiments of the present disclosure will be described in detail below. The examples of the embodiments are shown in the accompanying drawings, where the same or similar reference numerals denote the same or similar elements or elements with the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to explain the present disclosure, but should not be construed as a limitation of the present disclosure.
[0030] In recent years, with the rapid development of digital technology, digital cameras have become increasingly popular. Automatic focusing technology is one of the core technologies of digital cameras. Currently, the commonly used automatic focusing methods mainly include automatic focusing methods such as PDAF focusing algorithms, CAF focusing algorithms, and TOF focusing algorithms. Most manufacturers combine the above three algorithms to improve the accuracy and efficiency of the focusing algorithm. However, in dark environment scenarios where both PDAF and TOF algorithms are not reliable, traditional solutions mainly adopt the CAF algorithm or the solution of directly pushing to the hyperfocal distance. When the target is in the middle and near focal distance positions, the solution of direct pushing results in very poor current clarity, which is often unacceptable to users. And adopting the CAF algorithm will result in too long focusing time and poor focusing experience. Therefore, in dark environment scenarios where both PDAF and TOF algorithms are unavailable, it is particularly important to improve the focusing efficiency and accuracy in this scenario.
[0031] In summary, to solve the technical problems in the related art, embodiments of the present disclosure provide a focusing method. By responding to a focusing operation instruction received by an electronic device, a first parameter of the phase detection autofocus (PDAF) and a second parameter of the time of flight (TOF) in the electronic device are obtained. The first parameter includes the defocus value and the first confidence level of the PDAF, and the second parameter includes the distance value and the second confidence level of the TOF. When the first parameter and the second parameter meet a first preset condition, the light intensity of the environment where the electronic device is currently located is obtained. When the light intensity meets a second preset condition, the search range parameter of the contrast autofocus (CAF) is adjusted according to the distance value of the TOF. The adjusted search range parameter of the CAF is used for focusing. The purpose of this technical solution is to adjust the search range of the CAF algorithm according to the maximum effective detection distance of the TOF in a dark environment scenario where both the PDAF and TOF algorithms are unavailable, effectively improving the focusing search efficiency while ensuring the focusing accuracy in this scenario.
[0032] The following will introduce the focusing method provided by this application in detail with reference to the accompanying drawings.
[0033] Figure 1 It is a schematic flowchart of a focusing method proposed by an embodiment of the present disclosure. As Figure 1 shown, the method may include the following steps.
[0034] Step 101, obtain the first parameter of the PDAF and the second parameter of the TOF.
[0035] In some embodiments, in response to a focusing operation instruction received by the electronic device, the first parameter of the PDAF and the second parameter of the TOF in the electronic device are obtained.
[0036] In some embodiments, the first parameter includes the defocus value and the first confidence level of the PDAF, and the second parameter includes the distance value and the second confidence level of the TOF.
[0037] In some embodiments, by inputting multiple frames of test images and using the PDAF and TOF for focusing respectively, the first parameter of the PDAF and the second parameter of the TOF are obtained.
[0038] Exemplarily, the PDAF algorithm can be used to focus on multiple frames of test images, outputting the defocus value defocus and the confidence value confidence1 for each frame, and the TOF algorithm can be used to focus on multiple frames of test images, outputting the distance value distance and the confidence value confidence2 for each frame.
[0039] In some embodiments, the defocus value of the PDAF refers to the difference between a certain point or area and the ideal focus position, and the distance value of the TOF refers to the distance from the camera to the target measured by the TOF sensor.
[0040] In some embodiments, the confidence level is a numerical value used to determine whether the output parameters of an algorithm are available. For example, when the confidence level value is greater than a preset threshold, it indicates that the algorithm is available, that is, the output parameters of the algorithm can be used for the algorithm to perform focus search.
[0041] In some embodiments, when there are only two focus methods, TOF and CAF, in an electronic device, the values of the first parameters of PDAF obtained are all zero. In the above embodiments, obtaining the first parameters of PDAF and the second parameters of TOF is to determine whether the above two algorithms can be used for focusing, that is, if neither of the two algorithms is available, the focusing method of the embodiments of the present disclosure is used for focusing.
[0042] Step 102, when the first parameter and the second parameter meet the first preset condition, obtain the light intensity of the environment where the electronic device is currently located.
[0043] In some embodiments, the first preset condition may be that the first confidence level of PDAF and the second confidence level of TOF are less than or equal to a first threshold.
[0044] In some embodiments, the first threshold is the preset value of the confidence level. For example, it can be confidence = 100.
[0045] In some embodiments, when the first parameter and the second parameter meet the first preset condition, it may be that the confidence level of each frame output by PDAF is less than or equal to the first threshold and the confidence level of each frame output by TOF is less than or equal to the first threshold.
[0046] For example, for a certain frame output by PDAF, the defocus value defocus = 10, the confidence level value confidence1 = 80, and the first threshold confidence = 100, then the PDAF algorithm of this frame is not credible. If the confidence level value of each frame is less than or equal to 100, the PDAF algorithm is not credible and the defocus value output by the PDAF algorithm cannot be used. Similarly, for a certain frame output by TOF, the distance value distance = 30, the confidence level value confidence2 = 90, and the first threshold confidence = 100, then the TOF algorithm of this frame is not credible. If the confidence level value of each frame is less than or equal to 100, the TOF algorithm is not credible and the distance value output by the TOF algorithm cannot be used.
[0047] In some embodiments, when neither the first parameter nor the second parameter meets the first preset condition, PDAF can be used for focusing.
[0048] For example, when the confidence levels of PDAF and TOF are both greater than the first threshold, PDAF is used for focusing.
[0049] In some embodiments, when only one of the first parameter and the second parameter does not meet the first preset condition, an algorithm that does not meet the first preset condition can be used for focusing.
[0050] Exemplarily, when the confidence of PDAF is greater than the first threshold and the confidence of TOF is less than or equal to the first threshold, PDAF is used for focusing.
[0051] Exemplarily, when the confidence of TOF is greater than the first threshold and the confidence of PDAF is less than or equal to the first threshold, TOF is used for focusing.
[0052] In the above embodiments, when both the first parameter and the second parameter meet the first preset condition, it is necessary to obtain the light intensity at the current moment to determine whether the scene is a dark environment or a bright environment at this time, so as to determine whether it is necessary to adjust the search range parameter of CAF, avoiding inaccurate focusing and low efficiency.
[0053] Step 103, when the light intensity meets the second preset condition, adjust the search range parameter of CAF according to the distance value of TOF.
[0054] In some embodiments, the second preset condition may be that the light intensity is less than the second threshold.
[0055] In some embodiments, the second threshold is a preset light intensity value for determining whether the current environment is a dark environment or a bright environment.
[0056] Exemplarily, when the light intensity is greater than or equal to the preset light intensity threshold, it is a bright environment, and using the original range parameter of CAF for focusing search can achieve a good focusing effect. If the light intensity is less than the preset light intensity threshold, it is a dark environment, and using the original range parameter of CAF for focusing search may lead to inaccurate focusing. Therefore, it is necessary to adjust the search range parameter of CAF to achieve the purpose of improving focusing efficiency and accuracy.
[0057] Exemplarily, the obtained light intensity is luma, and the set second threshold is lowlight_luma. When luma < lowlight_luma, that is, the current environment is a dark environment, it is necessary to adjust the search range parameter of CAF for accurate focusing search.
[0058] In some embodiments, adjusting the search range parameter of CAF according to the distance value of TOF may be to adjust the farthest search position and the nearest search position of CAF, as well as the coarse and fine search step sizes.
[0059] In some embodiments, when the light intensity does not meet the second preset condition, that is, when the current environment is a bright environment, the search range parameters of the CAF may not be adjusted, and the original search range parameters are used for focusing.
[0060] Exemplarily, when the light intensity is greater than or equal to the second threshold, the original search range parameters of the CAF are used for focusing.
[0061] Step 104, use the adjusted search range parameters of the CAF for focusing.
[0062] In some embodiments, the adjusted search range parameters of the CAF include the farthest search position and the nearest search position, and the coarse and fine search step sizes are respectively configured. Starting from the farthest search position and ending at the nearest search position, the focusing search is performed according to the coarse and fine search step sizes.
[0063] Exemplarily, the farthest search position after the CAF adjustment is Search far , the nearest search position is Search near , the coarse search step size is Step coarse , the fine search step size is Step fine , then starting from Search far and ending at Search near , the focusing search is performed according to Step coarse and Step fine search step sizes.
[0064] In summary, in the above embodiments of the present application, the first parameter of the PDAF and the second parameter of the TOF are obtained; when the first parameter and the second parameter meet the first preset condition, the light intensity of the environment where the electronic device is currently located is obtained; when the light intensity meets the second preset condition, the search range parameters of the CAF are adjusted according to the distance value of the TOF; the adjusted search range parameters of the CAF are used for focusing. The accuracy and efficiency of the focusing search using the CAF can be improved.
[0065] Figure 2 The flowchart of the method for obtaining the first parameter of the PDAF and the second parameter of the TOF proposed by the embodiments of the present disclosure. Based on Figure 1 The embodiments shown, Figure 2 is a further description of Figure 1 step 101. Figure 2 The embodiments shown may include the following steps.
[0066] Step 201, input multiple frames of test images.
[0067] In some embodiments, multiple frames of test images are respectively input to obtain the parameters of the PDAF and the TOF.
[0068] In some embodiments, it may be a test image of an input fixed frame. The fixed-frame test image is tested to obtain the output results of some of its frames; it may also be to obtain the output results of all frames.
[0069] Step 202: Use PDAF and TOF respectively to focus on multiple frames of test images.
[0070] In some embodiments, when using PDAF to focus on multiple frames of test images, the defocus value and credibility of each frame of the test image can be obtained.
[0071] In some embodiments, when using TOF to focus on multiple frames of test images, the distance value and credibility of each frame of the test image can be obtained.
[0072] Step 203: Obtain the defocus value and the first credibility of PDAF for each frame of the test image, and the distance value and the second credibility of TOF for each frame of the test image.
[0073] In some embodiments, by inputting multiple frames of test images and using PDAF and TOF respectively to perform focus search on the test images, the first parameter of PDAF, that is, the defocus value and credibility of each frame, and the second parameter of TOF, that is, the distance value and credibility of each frame, can be obtained.
[0074] In the above embodiments, the parameters of PDAF and TOF are obtained through the test images to be used for determining whether PDAF or TOF can be used for focusing.
[0075] Figure 3 This is a flowchart of the method for adjusting the search range parameter of CAF according to the distance value of TOF proposed in the embodiments of the present disclosure. Based on Figure 1 the embodiments shown, Figure 3 For Figure 1 step 103 in the embodiments, Figure 3 as shown, the following steps are included:
[0076] Step 301: Obtain the distance value of TOF and the hyperfocal position.
[0077] In some embodiments, obtaining the distance value of TOF and the hyperfocal position is to adjust the search range parameter of CAF.
[0078] Among them, the distance value of TOF is the distance measured by the TOF sensor from the camera to the target image, and the hyperfocal position refers to the distance between the front limit of the depth of field and the lens when the focusing target is at infinity. In other words, the hyperfocal position is the photographic object distance when the maximum depth of field can be obtained on the premise that the focal length and aperture of the lens are both determined.
[0079] Exemplarily, obtain the distance value distance of the TOF and the hyperfocal position Lens hyp 。
[0080] Step 302, map the distance value to the first position.
[0081] In some embodiments, the distance value of the TOF is the distance from the camera to the target image. Mapping the distance value to the first position is to map the distance value to the position of the lens corresponding to the maximum detection distance.
[0082] Exemplarily, after the TOF performs focus search, it outputs the distance value distance, and maps the distance value distance to the first position, which is the position Lens of the corresponding lens. tof_max 。
[0083] Step 303, based on the first position, set the second position as the nearest search position of the search range parameter.
[0084] In some embodiments, the second position is between the first position and the lens position of the electronic device, so that the focusing range of the CAF is larger.
[0085] Exemplarily, the first position is Lens tof_max , and the second position is Search near , so that Search near = Lens tof_max - ΔL, where ΔL is an integer greater than 0. Equivalently, the value of the second position is smaller than that of the first position, so that the second position is before the first position.
[0086] Step 304, set the hyperfocal position as the farthest search position of the search range parameter.
[0087] In some embodiments, setting the hyperfocal position as the farthest search position can make the focusing range of the CAF larger.
[0088] Exemplarily, set the farthest search position in the search range parameter of the CAF as Search far , so that Search far = Lens hyp 。
[0089] In the above embodiments, by obtaining the distance value of the TOF and the hyperfocal position; mapping the distance value to the first position; based on the first position, setting the second position as the nearest search position of the search range parameter; setting the hyperfocal position as the farthest search position of the search range parameter. Adjust the search range parameter of the CAF through the parameters of the TOF, so that the CAF can focus and search a larger range.
[0090] Figure 4Flowchart of a focusing method using adjusted search range parameters of CAF proposed in an embodiment of the present disclosure. Based on Figure 1 , Figure 2 , Figure 3 In the embodiments shown, Figure 4 For Figure 1 Step 104 in the embodiment is further described. As Figure 4 shown, it includes the following steps:
[0091] Step 401, set the coarse search step size and the fine search step size.
[0092] In some embodiments, the coarse search is to perform focusing with a larger step size to obtain the peak value of focusvalue within the focusing range, and the fine search is to perform precise search near the peak value to determine the position of a more precise peak value to achieve focusing.
[0093] In some embodiments, the values of the coarse search step size and the fine search step size can be set arbitrarily.
[0094] Exemplarily, set the coarse search step size to Step coarse = a, and set the fine search step size to Step fine = b.
[0095] Step 402, starting from the farthest search position and ending at the nearest search position, perform focusing according to the coarse and fine search step sizes.
[0096] In some embodiments, using Search far as the starting point of the focusing search and Search near as the ending point of the focusing search, and performing focusing according to the coarse search step size Step coarse and the fine search step size Step fine can shorten the focusing search time and improve the focusing efficiency.
[0097] In the above embodiments, by adjusting the search range parameters of CAF and using the adjusted CAF for focusing, the focusing time of CAF is shortened and the focusing efficiency is improved.
[0098] Figure 5 Flowchart of a focusing method proposed in an embodiment of the present disclosure. As Figure 5 shown, after step 102 in Figure 1 this method further includes the following steps:
[0099] Step 501, when neither the first parameter nor the second parameter satisfies the first preset condition, use PDAF for focusing.
[0100] In some embodiments, when neither the first parameter nor the second parameter satisfies the first preset condition, that is, the confidence of PDAF and the confidence of TOF are both greater than the first threshold, PDAF is used for focusing.
[0101] Exemplarily, the confidence of PDAF is confidence = 120, the confidence of TOF is confidence = 130, and the first threshold is 100. Then the confidence of PDAF is greater than 100, indicating that PDAF is reliable, that is, the parameters of PDAF are available, and PDAF can be used for focus search; at the same time, the confidence of TOF is also greater than 100, indicating that TOF is reliable, that is, the parameters of TOF are available, and TOF can be used for focusing. In this case, PDAF is preferentially used for focusing.
[0102] Step 502: When the first parameter satisfies the first preset condition and the second parameter does not satisfy the first preset condition, TOF is used for focusing.
[0103] In some embodiments, when the first parameter satisfies the first preset condition and the second parameter does not satisfy the first preset condition, that is, the confidence of PDAF is less than or equal to the first threshold and the confidence of TOF is greater than the first threshold, TOF is used for focusing.
[0104] Exemplarily, the confidence of PDAF is 80, the confidence of TOF is 120, and the first threshold is 100. Then the confidence of PDAF is less than 100, indicating that PDAF is not reliable, that is, the parameters of PDAF are not available; at the same time, the confidence of TOF is greater than 100, indicating that TOF is reliable, that is, the parameters of TOF are available, and TOF can be used for focusing. In this case, the reliable algorithm is used for focusing, that is, TOF is used for focusing.
[0105] Step 503: When the second parameter satisfies the first preset condition and the first parameter does not satisfy the first preset condition, PDAF is used for focusing.
[0106] In some embodiments, when the second parameter satisfies the first preset condition and the first parameter does not satisfy the first preset condition, that is, the confidence of TOF is less than or equal to the first threshold and the confidence of PDAF is greater than the first threshold, PDAF is used for focusing.
[0107] Exemplarily, the confidence of PDAF is 130, the confidence of TOF is 70, and the first threshold is 100. Then the confidence of PDAF is greater than 100, indicating that PDAF is reliable, that is, the parameters of PDAF are available; at the same time, the confidence of TOF is less than 100, indicating that TOF is not reliable, that is, the parameters of TOF are not available. In this case, the reliable algorithm is used for focusing, that is, PDAF is used for focusing.
[0108] In the above embodiments, by judging the different situations of the parameters of PDAF and TOF from the first preset condition and setting the algorithm used for focusing, the purpose of achieving both the focusing effect and shortening the focusing time can be achieved.
[0109] Figure 6 The flowchart of a focusing method proposed in an embodiment of the present disclosure is as follows. Figure 6 As shown, after step 103 in Figure 1 the method further includes the following steps:
[0110] Step 601, when the light intensity does not meet the second preset condition, use the original search range parameters of CAF for focusing.
[0111] In some embodiments, when the light intensity does not meet the second preset condition, that is, when both PDAF and TOF meet the first preset condition, that is, when both are not credible, the light intensity is greater than the second threshold, that is, the current environment is a bright environment. When the light intensity is relatively high, using the original search range parameters of CAF for focusing can achieve a better focusing effect.
[0112] Exemplarily, if the obtained light intensity is luma = 1500 and the second threshold lowlight_luma = 800, then the current light intensity is greater than the second threshold and the environment is a bright environment. The original search range parameters of CAF can be used for focusing without adjusting the search range parameters.
[0113] In the above embodiments, when the environment is a bright environment and both PDAF and TOF are not credible, a better focusing effect can be achieved without adjusting the search range parameters of CAF.
[0114] Figure 7A The schematic flowchart of a focusing method provided by the present disclosure is as follows. Figure 7A As shown, the focusing method includes the following steps:
[0115] Step 1, obtain the current camera PDAF focusing data, including the defocus value and credibility, and TOF focusing data, including the distance value and credibility.
[0116] Step 2, if both PDAF and TOF focusings are credible, preferentially use the PDAF algorithm for focusing; if only one of the algorithms is credible, adopt the credible algorithm for focusing.
[0117] Step 3, if both the PDAF and TOF algorithms of the current N frames are not credible, use the CAF algorithm for focusing. When the light intensity is high, the search range of the CAF algorithm remains unchanged; when the light intensity is relatively low, adjust the search range of the CAF algorithm according to the maximum effective detection distance of TOF.
[0118] 3.1. When the light intensity is relatively high, that is, in a bright environment at this time, the CAF search range remains unchanged, and direct CAF focus search is performed.
[0119] 3.2. When the light intensity is relatively low, that is, in a dark environment at this time, the CAF search range is adjusted according to the maximum effective detection distance of TOF. Assume that the maximum effective detection distance of TOF is d void_max , the corresponding position of the lens is Lens tof_max , the corresponding position of the hyperfocal distance is Lens hyp , at this time, set the nearest search position of CAF as Search near = Lens tof_max - ΔL, that is, this position is in front of the maximum detection distance of TOF, and the farthest search position of CAF is Search far = Lens hyp , the coarse search step size Step coarse = a, the fine search step size Step fine = b, starting from Search far as the starting point and Search near as the ending point, perform CAF focus search according to the new coarse and fine search step sizes. As Figure 7B shown, it is a schematic diagram of the adjusted CAF search range.
[0120] The focus method provided by the present disclosure can adjust the search range of the CAF algorithm in a dark environment where both the PDAF and TOF algorithms are unavailable, shorten the CAF focus time, and improve the focus efficiency.
[0121] Figure 8 FIG. is a schematic structural diagram of a focus device 800 according to an embodiment of the present disclosure. As Figure 8 shown, the device includes:
[0122] A focus module 801, configured to obtain a first parameter of phase detection autofocus PDAF and a second parameter of time of flight TOF in the electronic device in response to a focus operation instruction received by the electronic device, where the first parameter includes the defocus value and the first credibility of PDAF, and the second parameter includes the distance value and the second credibility of TOF; when the first parameter and the second parameter meet a first preset condition, obtain the light intensity of the environment where the electronic device is currently located; when the light intensity meets a second preset condition, adjust the search range parameters of contrast autofocus CAF according to the distance value of TOF; perform focus using the adjusted search range parameters of CAF.
[0123] In some embodiments, the focusing module is configured to: input multiple frames of test images; perform focusing on the multiple frames of test images using PDAF and TOF respectively; obtain the defocus value and the first confidence level of PDAF for each frame of test image, and the distance value and the second confidence level of TOF for each frame of test image.
[0124] In some embodiments, the focusing module is further configured to: obtain the distance value of TOF and the hyperfocal position; map the distance value to a first position; based on the first position, set a second position as the nearest search position of the search range parameter, where the second position is between the first position and the lens position of the electronic device; set the hyperfocal position as the farthest search position of the search range parameter.
[0125] In some embodiments, the focusing module is further configured to: set a coarse search step and a fine search step; perform focusing according to the coarse search step and the fine search step starting from the farthest search position and ending at the nearest search position.
[0126] In some embodiments, the first preset condition is that the first confidence level and the second confidence level are less than or equal to a first threshold.
[0127] In some embodiments, the second preset condition is that the light intensity is less than a second threshold.
[0128] In some embodiments, the focusing module is further configured to: when neither the first parameter nor the second parameter satisfies the first preset condition, perform focusing using PDAF; when the first parameter satisfies the first preset condition and the second parameter does not satisfy the first preset condition, perform focusing using TOF; when the second parameter satisfies the first preset condition and the first parameter does not satisfy the first preset condition, perform focusing using PDAF.
[0129] In some embodiments, the focusing module is further configured to: when the light intensity does not satisfy the second preset condition, perform focusing using the original search range parameter of CAF.
[0130] In summary, the focusing device proposed in the present disclosure, by responding to a focusing operation instruction received by the electronic device, obtains a first parameter of phase detection autofocus (PDAF) and a second parameter of time-of-flight (TOF) in the electronic device. The first parameter includes the defocus value and the first confidence level of PDAF, and the second parameter includes the distance value and the second confidence level of TOF. When the first parameter and the second parameter satisfy the first preset condition, obtain the light intensity of the environment where the electronic device is currently located. When the light intensity satisfies the second preset condition, adjust the search range parameter of contrast autofocus (CAF) according to the distance value of TOF. Perform focusing using the adjusted search range parameter of CAF. In the scenario of a dark environment, perform focusing by adjusting the search range parameter of CAF, so as to achieve the purpose of shortening the focusing time and improving the focusing accuracy.
[0131] Figure 9 It is a schematic structural diagram of an electronic device 900 for implementing the above-mentioned focusing method shown according to an exemplary embodiment.
[0132] Referring to Figure 9 , the electronic device 900 may include one or more of the following components: a processing component 902, a memory 904, a power supply component 906, a multimedia component 908, an audio component 910, an input / output (I / O) interface 912, a sensor component 914, and a communication component 916.
[0133] The processing component 902 generally controls the overall operation of the electronic device 900, such as operations associated with display, telephone call, data communication, camera operation, and recording operation. The processing component 902 may include one or more processors 920 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 902 may include one or more modules to facilitate the interaction between the processing component 902 and other components. For example, the processing component 902 may include a multimedia module to facilitate the interaction between the multimedia component 908 and the processing component 902.
[0134] The memory 904 is configured to store various types of data to support the operation of the electronic device 900. Examples of such data include instructions for any application or method operating on the electronic device 900, contact data, phone book data, messages, pictures, videos, etc. The memory 904 may 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.
[0135] The power supply component 906 provides power to various components of the electronic device 900. The power supply component 906 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the electronic device 900.
[0136] The multimedia component 908 includes a screen that provides an output interface between the electronic device 900 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 can be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensors can sense not only the boundaries of touch or swipe actions but also detect the duration and pressure associated with the touch or swipe operations. In some embodiments, the multimedia component 908 includes a front camera and / or a rear camera. When the electronic device 900 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera can receive external multimedia data. Each of the front camera and the rear camera can be a fixed optical lens system or have a focal length and optical zoom capabilities.
[0137] The audio component 910 is configured to output and / or input audio signals. For example, the audio component 910 includes a microphone (MIC) that is configured to receive external audio signals when the electronic device 900 is in an operating mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals can be further stored in the memory 904 or transmitted via the communication component 916. In some embodiments, the audio component 910 further includes a speaker for outputting audio signals.
[0138] The I / O interface 912 provides an interface between the processing component 902 and a peripheral interface module, which can be a keyboard, a click wheel, buttons, etc. These buttons can include, but are not limited to: a home button, a volume button, a power button, and a lock button.
[0139] The sensor component 914 includes one or more sensors for providing an assessment of various aspects of the status of the electronic device 900. For example, the sensor component 914 can detect the on / off state of the electronic device 900, the relative positioning of components, such as the display and keypad of the electronic device 900. The sensor component 914 can also detect a change in the position of the electronic device 900 or a component of the electronic device 900, the presence or absence of user contact with the electronic device 900, the orientation or acceleration / deceleration of the electronic device 900, and the temperature change of the electronic device 900. The sensor component 914 can include a proximity sensor configured to detect the presence of nearby objects without any physical contact. The sensor component 914 can also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor component 914 can further include an acceleration sensor, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
[0140] The communication component 916 is configured to facilitate communication between the electronic device 900 and other devices in a wired or wireless manner. The electronic device 900 can access a communication standard-based wireless network, such as WiFi, 2G or 3G, 4G LTE, 5G NR (New Radio), or a combination thereof. In an exemplary embodiment, the communication component 916 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 916 further 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.
[0141] In an exemplary embodiment, the electronic device 900 can 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 for performing the above method.
[0142] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 904 including instructions, and the above instructions can be executed by a processor 920 of the electronic device 900 to complete the above method. For example, the non-transitory computer-readable storage medium can be a ROM, Random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc.
[0143] Embodiments of the present disclosure also propose a non-transitory computer-readable storage medium storing computer instructions, where the computer instructions are used to cause a computer to execute the focusing method described in the above embodiments of the present disclosure.
[0144] Embodiments of the present disclosure also propose a computer program product, including a computer program, and the computer program executes the focusing method described in the above embodiments of the present disclosure when being executed by a processor.
[0145] Figure 10 is a schematic structural diagram of a chip 1000 for implementing the above focusing method shown according to an exemplary embodiment. Referring to Figure 10 , the chip 1000 includes at least one communication interface 1001 and a processor 1002. The communication interface 1001 is used to receive signals input to the chip 1000 or signals output from the above chip 1000, and the processor 1002 communicates with the communication interface 1001 and implements the focusing method described in the above embodiments of the present disclosure through logic circuits or by executing code instructions.
[0146] It should be noted that the terms "first", "second", etc. in the description of the present disclosure, the claims and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described here can be implemented in an order other than those illustrated or described here. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0147] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "schematic embodiments", "examples", "specific examples" or "some examples", etc. means that the specific features, structures, materials or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present disclosure. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0148] Any process or method description shown in the flowchart or described in other ways herein can be understood to represent a module, segment or part of code including one or more executable instructions for implementing a specific logical function or process, and the scope of the preferred embodiments of the present disclosure includes additional implementations, where the functions can be executed in a manner that is not shown or discussed in sequence, including in a substantially simultaneous manner or in a reverse order according to the functions involved, which should be understood by those skilled in the technical field to which the embodiments of the present disclosure belong.
[0149] The logic and / or steps represented in the flowchart or otherwise described herein can, for example, be considered as a definitional sequence list of executable instructions for implementing logical functions, and can be embodied specifically in any computer-readable medium for use by an instruction execution system, apparatus, or device (such as a computer-based system, a system including a processing module, or other systems that can fetch and execute instructions from the instruction execution system, apparatus, or device), or used in conjunction with these instruction execution systems, apparatuses, or devices. For the purposes of this specification, a "computer-readable medium" can be any device that can contain, store, communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium include the following: an electrical connection portion with one or more wirings (control method), a portable computer disk cartridge (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Additionally, the computer-readable medium can even be paper or other suitable media on which a program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other media, followed by editing, interpretation, or otherwise processing as appropriate, and then stored in a computer memory.
[0150] It should be understood that various parts of the embodiments of the present disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one or a combination of the following techniques known in the art can be used: discrete logic circuits having logic gate circuits for implementing logical functions on data signals, application-specific integrated circuits having suitable combinational logic gate circuits, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0151] Those of ordinary skill in the art of this technology can understand that all or part of the steps carried by the methods of the above embodiments can be completed by instructing relevant hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0152] In addition, each functional unit in various embodiments of the present disclosure may be integrated into one processing module, or each unit may exist physically alone, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium. The above-mentioned storage medium may be a read-only memory, a magnetic disk, an optical disc, or the like.
[0153] Although the embodiments of the present disclosure have been shown and described above, it can be understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. Those of ordinary skill in the art can make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.
Claims
1. A focusing method, characterized in that, The method includes: In response to a focus operation instruction received by an electronic device, obtaining a first parameter of a phase detection autofocus (PDAF) and a second parameter of a time-of-flight autofocus (TOF) in the electronic device, where the first parameter includes a defocus value and a first confidence level of the PDAF, and the second parameter includes a distance value and a second confidence level of the TOF; When the first parameter and the second parameter meet a first preset condition, obtaining the light intensity of the environment where the electronic device is currently located; When the light intensity meets a second preset condition, adjusting a search range parameter of a contrast autofocus (CAF) according to the distance value of the TOF; Performing focus using the adjusted search range parameter of the CAF.
2. The method according to claim 1, characterized in that, The obtaining of the first parameter of the PDAF and the second parameter of the TOF includes: Inputting multiple frames of test images; Respectively using the PDAF and the TOF to perform focus on the multiple frames of test images; Obtaining the defocus value and the first confidence level of the PDAF for each frame of the test images, and the distance value and the second confidence level of the TOF for each frame of the test images.
3. The method according to claim 1, characterized in that, The adjusting of the search range parameter of the contrast autofocus (CAF) according to the distance value of the TOF when the light intensity meets the second preset condition includes: Obtaining the distance value of the TOF and the hyperfocal position; Mapping the distance value to a first position; Based on the first position, setting a second position as the nearest search position of the search range parameter, where the second position is between the first position and the lens position of the electronic device; Setting the hyperfocal position as the farthest search position of the search range parameter.
4. The method according to claim 3, characterized in that, The performing of focus using the adjusted search range parameter of the CAF includes: Setting a coarse search step and a fine search step; Starting from the farthest search position and ending at the nearest search position, performing focus according to the coarse search step and the fine search step.
5. The method according to any one of claims 1 to 4, wherein The first preset condition is that the first confidence level and the second confidence level are less than or equal to a first threshold; The second preset condition is that the light intensity is less than a second threshold.
6. The method according to claim 1, characterized in that, The method further includes: When the first parameter and the second parameter do not both meet the first preset condition, using the PDAF to perform focus; When the first parameter meets the first preset condition and the second parameter does not meet the first preset condition, using the TOF to perform focus; When the second parameter meets the first preset condition and the first parameter does not meet the first preset condition, using the PDAF to perform focus.
7. The method according to claim 1, wherein The method further includes: When the light intensity does not meet the second preset condition, using the original search range parameter of the CAF to perform focus.
8. A focusing device, characterized in that, Including a focus module, The focusing module is configured to obtain a first parameter of phase detection autofocus (PDAF) and a second parameter of time-of-flight (TOF) in the electronic device in response to a focusing operation received by the electronic device. The first parameter includes a defocus value and a first confidence level of the PDAF, and the second parameter includes a distance value and a second confidence level of the TOF. When the first parameter and the second parameter meet a first preset condition, obtain the light intensity of the environment where the electronic device is currently located. When the light intensity meets a second preset condition, adjust the search range parameter of contrast autofocus (CAF) according to the distance value of the TOF. Use the adjusted search range parameter of the CAF for focusing.
9. An electronic device, characterized in that, It includes: a processor and a memory for storing a computer program that can run on the processor, wherein, when the processor is used to run the computer program, it executes the method described in any one of claims 1-7.
10. A non-transitory computer-readable storage medium storing computer instructions, characterized in that, The computer instructions are used to cause the computer to execute the method described in any one of claims 1-7.
11. A chip, characterized in that, It includes at least one processor and a communication interface; the communication interface is used to receive signals input to the chip or signals output from the chip, and the processor communicates with the communication interface and implements the method described in any one of claims 1-7 through logic circuits or by executing code instructions.