Defocus amount acquisition method, device, electronic device and readable storage medium
Through the pre-trained focus model and focus reference image, the target defocus amount is determined using the outputs of the first and second modules, which solves the problem of insufficient accuracy in the calculation of defocus amount in the prior art, and improves the phase detection autofocus focus effect.
Patent Information
- Application Number
- CN202310961905.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-01
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2043-08-01
AI Technical Summary
In the existing phase detection automatic focus technology, the accuracy of defocusing amount calculation is insufficient, resulting in unsatisfactory focus effect.
Using a pre-trained focus model, by acquiring multiple sets of focus reference images, the first module and the second module respectively output the predicted defocus amount and confidence, and the second module is trained based on the confidence, determine the target defocus amount and improve the focus. accuracy.
Improves the focus effect, ensures the accuracy and efficiency of the focus process, and improves the performance of phase detection automatic focus.
Smart Images

Figure CN117714859B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminals, and in particular to a method, device, electronic device and readable storage medium for obtaining defocus value. Background Art
[0002] Phase Detection Auto Focus (PDAF) is the mainstream focusing method in the field of mobile photography. Compared with the traditional contrast focusing method, the phase focusing method has a faster focusing speed. The principle of phase focusing is to cover the left and right halves of the photosensitive element with two acquisition units symmetrically arranged on the photosensitive element, respectively, to simulate the difference in the angle of sight of the human eye, and to calculate whether the focus is accurate based on the difference in the angle of sight. When calculating whether the focus is accurate, it is necessary to calculate the defocus (Defocus), that is, the distance when the focus motor drives the lens to the focus. The accuracy of the calculated defocus will directly affect the focusing effect of PDAF.
[0003] However, the defocus amount calculated by the currently commonly used defocus amount calculation method is not accurate enough, which leads to unsatisfactory focusing effect of PDAF. Summary of the invention
[0004] The present application provides a method, device, electronic device and readable storage medium for obtaining defocus amount, which determines whether the target parameter of the electronic device meets the first preset condition before controlling the electronic device to enter the long standby mode, and if so, determines to control the electronic device to enter the long standby mode. The problem of inaccurate time of entering the long standby mode, resulting in insignificant effect of reducing power consumption or affecting the user's experience, can be improved.
[0005] In order to achieve the above objectives, this application adopts the following technical solutions:
[0006] In a first aspect, a method for obtaining a defocus amount is provided, which is applied to an electronic device, and the method comprises:
[0007] Acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene from different perspectives; obtain predicted defocus amounts and confidence levels of predicted defocus amounts corresponding to each group of focus reference images based on the multiple groups of focus reference images using a pre-trained focus model, wherein the focus model includes a first module and a second module, the first module is used to output predicted defocus amounts, the second module is used to output the confidence level of the predicted defocus amounts, and the second module is trained based on the error between the predicted defocus amounts output by the first module and the actual defocus amounts, and the confidence level of the predicted defocus amounts; determine a target defocus amount from among multiple defocus amounts based on the confidence levels corresponding to each of the multiple predicted defocus amounts.
[0008] In the embodiments of the present application, the defocus amount acquisition method can be applied to electronic devices that include a camera function and support PDAF, including mobile phones, tablet computers, handheld game consoles, wearable devices, augmented reality / virtual reality devices, laptops, super mobile personal computers, netbooks, personal digital assistants, etc.
[0009] In the first aspect, the confidence of the predicted defocus amount is obtained by prediction by the second module, and the error between the predicted defocus amount and the actual defocus amount is taken into account when the second module is trained. Since the smaller the error, the more accurate the confidence, the confidence output by the trained second module according to the focus reference image is more accurate, the determined target defocus amount is more accurate, and the focusing effect when focusing according to the target defocus amount is also better.
[0010] In some possible implementations, the second module is obtained by training according to the error between the predicted defocus amount output by the first module and the actual defocus amount and the confidence of the predicted defocus amount, including:
[0011] Acquire multiple groups of focus reference image samples, extract image features of each group of focus reference image samples, each group of focus reference image samples includes at least two images of the same scene with different viewing angles and a true defocus amount; input the image features of each group of focus reference image samples into a first module and a second module respectively, obtain a predicted defocus amount corresponding to each group of focus reference image samples and a confidence level of the predicted defocus amount; obtain an error between the predicted defocus amount corresponding to each group of focus reference image samples and the true defocus amount; based on the error, mark the confidence level that meets a first preset condition as true, and mark the confidence level that does not meet the first preset condition as false; train the second module based on the confidence level mark to obtain a trained second module.
[0012] Among them, when training the second module, the predicted defocus amount is first output through the first module, the confidence of the predicted defocus amount is output through the second module, and then the error between the predicted defocus amount and the actual defocus amount is calculated. According to the error, the confidence of each predicted defocus amount is marked, and the second module is trained according to the mark of the confidence to obtain the trained second module. Since the first module and the second module use the same image features, both the error and the image features are considered during training, so that the confidence output by the second module obtained by training can more accurately indicate whether the corresponding predicted defocus amount is correct, so that the determined target defocus amount is more accurate, and the focusing effect when focusing according to the target defocus amount is also better.
[0013] In some possible implementations, based on the errors, the confidence levels that meet the first preset condition are marked as true, and the confidence levels that do not meet the first preset condition are marked as false, including: sorting the errors; determining that the confidence levels corresponding to the errors that meet the first threshold in the sorted errors meet the first preset condition; and determining that the confidence levels corresponding to the errors that do not meet the first threshold in the sorted errors do not meet the first preset condition.
[0014] In some possible implementations, the errors are sorted in order from small to large, and the first threshold is p%;
[0015] Determining that the confidences corresponding to the errors that meet the first threshold in the sorted errors meet the first preset condition includes: determining that the confidences corresponding to the first p% errors in the sorted errors meet the first preset condition. Determining that the confidences corresponding to the errors that do not meet the first threshold in the sorted errors do not meet the first preset condition includes: determining that the confidences corresponding to the last (100-p)% errors in the sorted errors do not meet the first preset condition.
[0016] In some possible implementations, the errors are sorted in ascending order, and the first threshold is a preset error number n, where n is an integer greater than or equal to 1;
[0017] Determining that the confidence corresponding to the errors that meet the first threshold in the sorted errors meets the first preset condition includes: determining that the confidence corresponding to the first n errors in the sorted errors meets the first preset condition. Determining that the confidence corresponding to the errors that do not meet the first threshold in the sorted errors does not meet the first preset condition includes: determining that the confidence corresponding to the errors after the nth in the sorted errors does not meet the first preset condition.
[0018] In some possible implementations, the focus model further includes a feature extraction module, and the first module and the second module are respectively connected to the feature extraction module.
[0019] In some possible implementations, a pre-trained focus model is used to obtain the defocus amount and confidence corresponding to each group of focus reference images according to multiple groups of focus reference images, including: obtaining image features of the focus reference images according to the focus reference images through a feature extraction module. Obtaining the predicted defocus amount of the focus reference images according to the image features through a first module. Obtaining the confidence of the predicted defocus amount of the focus reference images according to the image features through a second module.
[0020] In a second aspect, a defocus amount acquisition device is provided, which is applied to an electronic device, comprising:
[0021] An acquisition module is used to acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene from different perspectives. The acquisition module is also used to acquire the predicted defocus amount and the confidence of the predicted defocus amount corresponding to each group of focus reference images based on the multiple groups of focus reference images through a pre-trained focus model, wherein the focus model includes a first module and a second module, the first module is used to output the predicted defocus amount, the second module is used to output the confidence of the predicted defocus amount, and the second module is trained based on the error between the predicted defocus amount output by the first module and the actual defocus amount and the confidence of the predicted defocus amount. A determination module is used to determine the target defocus amount from multiple predicted defocus amounts based on the confidences corresponding to the multiple predicted defocus amounts.
[0022] In some possible embodiments, the device also includes a training module, which is used to obtain multiple groups of focus reference image samples and extract image features of each group of focus reference image samples, each group of focus reference image samples including at least two images of the same scene from different perspectives and an actual defocus amount; input the image features of each group of focus reference image samples into the first module and the second module respectively to obtain a predicted defocus amount corresponding to each group of focus reference image samples and a confidence level of the predicted defocus amount; obtain an error between the predicted defocus amount corresponding to each group of focus reference image samples and the actual defocus amount; based on the error, mark the confidence level that meets the first preset condition as true, and mark the confidence level that does not meet the first preset condition as false; train the second module based on the confidence level mark to obtain a trained second module.
[0023] Some possible implementations further include a marking module for sorting errors; determining that the confidence levels corresponding to the errors that meet the first threshold among the sorted errors meet the first preset condition; and determining that the confidence levels corresponding to the errors that do not meet the first threshold among the sorted errors do not meet the first preset condition.
[0024] In some possible implementations, the errors are sorted in order from small to large, and the first threshold is p%;
[0025] The marking module is specifically used to determine whether the confidences corresponding to the first p% errors in the sorted errors meet the first preset condition; the marking module is specifically used to determine whether the confidences corresponding to the last p% errors in the sorted errors do not meet the first preset condition.
[0026] In some possible implementations, the errors are sorted in ascending order, and the first threshold is a preset error number n, where n is an integer greater than or equal to 1;
[0027] A marking module, specifically used to determine whether the confidences corresponding to the first n errors in the sorted errors meet the first preset condition;
[0028] The marking module is specifically used to determine whether the confidence corresponding to the error after the nth one in the sorted errors does not meet the first preset condition.
[0029] In some possible implementations, the focus model further includes a feature extraction module, and the first module and the second module are respectively connected to the feature extraction module.
[0030] In some possible implementations, the acquisition module is specifically used to obtain the defocus amount and confidence corresponding to each group of focus reference images according to multiple groups of focus reference images through a pre-trained focus model, including: obtaining image features of the focus reference image according to the focus reference image through a feature extraction module. Obtaining the predicted defocus amount of the focus reference image according to the image features through a first module. Obtaining the confidence of the predicted defocus amount of the focus reference image according to the image features through a second module.
[0031] In a third aspect, an electronic device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program and performs the steps of processing in the first aspect or any one of the methods in the first aspect.
[0032] In a fourth aspect, a chip is provided, comprising: a processor for calling and running a computer program from a memory, so that a device equipped with the chip executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0033] In a fifth aspect, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0034] In a sixth aspect, a computer program product is provided, the computer program product comprising: a computer program code, when the computer program code is executed by an electronic device, the electronic device executes the steps of processing in the first aspect or any one of the methods in the first aspect.
[0035] Among them, the beneficial effects of the second to sixth aspects can refer to the first aspect and will not be elaborated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 This is a schematic diagram of an application scenario of a method for obtaining a defocus amount provided in an embodiment of the present application;
[0037] Figure 2 It is a hardware structure block diagram of an electronic device provided in an embodiment of the present application;
[0038] Figure 3is a system structure block diagram of an electronic device provided in an embodiment of the present application;
[0039] Figure 4 is a software structure block diagram of the electronic device provided in the embodiment of the present application;
[0040] Figure 5 is a flow chart of a method for obtaining defocus amount provided in an embodiment of the present application;
[0041] Figure 6 It is a schematic diagram of the training process of the second module in the method for obtaining the defocus amount provided in an embodiment of the present application;
[0042] Figure 7 is a structural block diagram of a defocus amount acquisition device provided in an embodiment of the present application;
[0043] Figure 8 It is a schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0044] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0045] In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0046] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of this embodiment, unless otherwise specified, "plurality" means two or more.
[0047] Phase Detection Auto Focus (PDAF) is the mainstream focusing method in the field of mobile photography. Compared with the traditional contrast focusing method, the phase focusing method is faster. The principle of phase focusing is to cover the left and right halves of the photosensitive element with two symmetrically arranged acquisition units, respectively, to simulate the difference in the sight angle of the human eye, and calculate whether the focus is accurate based on the difference in the sight angle.
[0048] When calculating whether the focus is accurate, it is necessary to calculate the defocus amount (Defocus), which is the distance when the focus motor drives the lens to move to the focus. The accuracy of the calculated defocus amount will directly affect the focusing effect of PDAF.
[0049] In one solution, when calculating the defocus amount, a classification network is used to output the probability distribution of the defocus amount, and then the defocus amount and confidence level are output based on the probability distribution. However, this method does not take into account factors such as image features and defocus amount errors, and the calculated defocus amount is not accurate enough, which in turn leads to unsatisfactory PDAF focusing effect.
[0050] In view of this, the present application provides a method for obtaining a defocus amount, which is applied to an electronic device, and the method includes:
[0051] Acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene from different perspectives; obtain predicted defocus amounts and confidence levels of predicted defocus amounts corresponding to each group of focus reference images based on the multiple groups of focus reference images using a pre-trained focus model, wherein the focus model includes a first module and a second module, the first module is used to output predicted defocus amounts, the second module is used to output the confidence level of the predicted defocus amounts, and the second module is trained based on the error between the predicted defocus amounts output by the first module and the actual defocus amounts, and the confidence level of the predicted defocus amounts; determine a target defocus amount from among multiple defocus amounts based on the confidence levels corresponding to each of the multiple predicted defocus amounts.
[0052] In the present application, the confidence of the predicted defocus amount is obtained by prediction by the second module, and the error between the predicted defocus amount and the actual defocus amount is taken into account when the second module is trained. Since the smaller the error, the more accurate the confidence, the confidence output by the trained second module based on the focus reference image is more accurate, the determined target defocus amount is more accurate, and the focusing effect when focusing based on the target defocus amount is also better.
[0053] Figure 1 It is a schematic diagram of an application scenario of a method for obtaining defocus amount provided in an embodiment of the present application.
[0054] refer to Figure 1 First, the application scenarios of the embodiments of the present application are briefly described.
[0055] Figure 1 The electronic device 100 is shown in FIG. 1 . When the electronic device 100 responds to an operation to enter a camera application to start taking photos or recording videos, the camera application calls the camera to obtain a preview image of the subject 21 and performs PDAF based on the preview image.
[0056] When performing PDAF, two acquisition units symmetrically arranged on the photosensitive element can cover the left half and the right half respectively to acquire the preview image, thereby obtaining a first perspective image 22 and a second perspective image 23 of the same photographed object 21 at different perspectives.
[0057] Then, PDAF is performed according to the first-view image 22 and the second-view image 23 through the focus model to obtain the defocus amount, which is the distance that the motor in the camera drives the lens to move when the focus is accurate.
[0058] Finally, the camera application controls the motor in the camera to drive the lens to move to the distance indicated by the defocus amount to complete the focusing.
[0059] Figure 2 It is a hardware structure block diagram of an electronic device provided in an embodiment of the present application.
[0060] In the present application, the electronic device includes a camera function and supports PDAF. As an example, the electronic device may include a mobile phone, a tablet computer, a handheld game console, a wearable device, an augmented reality (AR) / virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), etc. The embodiments of the present application do not impose any restrictions on the specific type of the electronic device.
[0061] refer to Figure 2The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0062] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0063] For example, when the electronic device 100 is a mobile phone or a tablet computer, it may include all the components shown in the figure, or may include only some of the components shown in the figure.
[0064] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0065] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0066] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0067] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.
[0068] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0069] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device through the power management module 141.
[0070] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the display screen 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0071] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0072] Antenna 1 and antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve the utilization of antennas. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.
[0073] The mobile communication module 150 can provide wireless communication solutions including 2G / 3G / 4G / 5G etc. applied on the electronic device 100 .
[0074] The modulation and demodulation processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing.
[0075] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0076] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0077] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.
[0078] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is a positive integer greater than 1.
[0079] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0080] ISP is used to process the data fed back by camera 193. For example, when taking a photo, the shutter is opened, and the light is transmitted to the camera photosensitive element through the lens. The light signal is converted into an electrical signal, and the camera photosensitive element transmits the electrical signal to ISP for processing and converts it into an image visible to the naked eye. ISP can also perform algorithm optimization on the noise, brightness, and skin color of the image. ISP can also optimize the exposure, color temperature and other parameters of the shooting scene. In some embodiments, ISP can be set in camera 193.
[0081] The camera 193 is used to capture still images or videos. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0082] NPU is a neural network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain, it can quickly process input information and can also continuously self-learn. Through NPU, applications such as intelligent cognition of electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.
[0083] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.
[0084] The internal memory 121 can be used to store computer executable program codes, which include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.
[0085] The electronic device 100 can implement audio functions such as music playing and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0086] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.
[0087] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0088] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0089] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0090] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0091] The pressure sensor 180A is used to sense pressure signals and convert the pressure signals into electrical signals.
[0092] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.
[0093] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.
[0094] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip leather case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover according to the magnetic sensor 180D. Then, according to the detected opening and closing state of the leather case or the opening and closing state of the flip cover, the flip cover can be automatically unlocked.
[0095] The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in all directions (generally three axes). When the electronic device 100 is stationary, the magnitude and direction of gravity can be detected. It can also be used to identify the posture of the electronic device and is applied to applications such as horizontal and vertical screen switching and pedometers.
[0096] The distance sensor 180F is used to measure the distance. The electronic device 100 can measure the distance by infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure the distance to achieve fast focusing.
[0097] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user holds the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.
[0098] The ambient light sensor 180L is used to sense the ambient light brightness. The electronic device 100 can adaptively adjust the brightness of the display screen 194 according to the perceived ambient light brightness. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touches.
[0099] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0100] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of a processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to avoid abnormal shutdown of the electronic device 100 due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 performs a boost on the output voltage of the battery 142 to avoid abnormal shutdown caused by low temperature.
[0101] In an embodiment of the present application, the temperature sensor 180J may include multiple ones for detecting the temperatures at different positions of the electronic device 100, such as being set near the processor to obtain the temperature of the processor, being set near the battery to obtain the temperature of the battery, or being set on the inside of the outer casing of the electronic device 100 to obtain the temperature of the outer casing of the electronic device 100.
[0102] The touch sensor 180K is also called a "touch control device". The touch sensor 180K can be set on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch control screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.
[0103] The key 190 includes a power key, a volume key, etc. The key 190 may be a mechanical key or a touch key. The electronic device 100 may receive key input and generate key signal input related to user settings and function control of the electronic device 100.
[0104] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0105] Indicator 192 may be an indicator light, which may be used to indicate charging status, power changes, messages, missed calls, notifications, etc.
[0106] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to and separated from the electronic device 100 by inserting it into the SIM card interface 195 or pulling it out from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0107] For the scenario in the above example, the operating system of the electronic device 100 may include but is not limited to Symbian, Android, Windows, MacOS, iOS, Blackberry, HarmonyOS, Linux or Unix operating systems.
[0108] Figure 3 It is a system structure block diagram of the electronic device provided in the embodiment of the present application.
[0109] As an example, when the defocus amount acquisition method provided in the present application is executed on the electronic device 100, the operating system of the electronic device 100 may be Android, and its system structure may refer to Figure 3 .
[0110] Among them, the layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, and the kernel layer.
[0111] The application layer can include a series of application packages.
[0112] like Figure 3 As shown, the application package may include camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message and other applications.
[0113] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.
[0114] like Figure 3 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0115] The window manager is used to manage window programs. The window manager can obtain the display screen size, determine whether there is a status bar, lock the screen, capture the screen, etc.
[0116] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.
[0117] The view system includes visual controls, such as controls for displaying characters, controls for displaying pictures, etc. The view system can be used to build applications. A display interface can be composed of one or more views. For example, a display interface including a text message notification icon can include a view for displaying characters and a view for displaying pictures.
[0118] The phone manager is used to provide communication functions for electronic devices, such as the management of call status (including answering, hanging up, etc.).
[0119] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0120] The notification manager enables applications to display notification information in the status bar. It can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of a chart or scroll bar text, such as notifications of applications running in the background, or a notification that appears on the screen in the form of a dialog window. For example, a text message is displayed in the status bar, a prompt sound is emitted, an electronic device vibrates, an indicator light flashes, etc.
[0121] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0122] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0123] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0124] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0125] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0126] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0127] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing, etc.
[0128] A 2D graphics engine is a drawing engine for 2D drawings.
[0129] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.
[0130] Figure 4 It is a software structure block diagram of the electronic device provided in the embodiment of the present application.
[0131] refer to Figure 4 The software structure of the electronic device includes a focus model, and the focus model includes a feature extraction module, a first module and a second module. Figure 1 The software structure of the electronic device also includes a photo taking application, which calls the camera to obtain multiple groups of focus reference images through the photosensitive components and lenses in the camera, and each group of focus reference images includes at least one first-perspective image and one second-perspective image.
[0132] The feature extraction module in the focus model is used to obtain image features based on the first-view image and the second-view image. The image features may include image blur, brightness, signal-to-noise ratio, etc. The feature extraction module may be a convolutional layer in a neural network, such as a combination of multiple convolutional layers and pooling layers.
[0133] The first module and the second module are respectively connected to the feature extraction module, and share the image features extracted by the feature extraction module. The two heads of the feature extraction module have similar structures, and can be a group of fully connected layers. For example, the first module or the second module can be a combination of three fully connected layers.
[0134] Figure 5 It is a flow chart of the method for obtaining the defocus amount provided in an embodiment of the present application.
[0135] refer to Figure 5 , the defocus amount acquisition method includes:
[0136] S501, obtaining image features of a focus reference image, and executing S502 and S504.
[0137] In some possible implementations, the goal of the feature extraction module is to extract representative features from the input image. As an example, the feature extraction module may include 4 fully convolutional layers, each layer having a different size and number of channels.
[0138] For example, the size of the first fully convolutional layer can be 192*192 and have 2 channels. In the first fully convolutional layer, the focus reference image can generate an output with two feature channels after the convolution operation. The size of the second fully convolutional layer can be 64*64 and have 16 channels. Through the convolution operation, the second fully convolutional layer will further extract more abstract and complex features in the focus reference image. The size of the third fully convolutional layer can be 16*16 and the number of channels is 64. In this layer, more refined features will be extracted to capture more subtle patterns and structures in the focus reference image. The size of the last fully convolutional layer of the feature extraction module can be 1*1 and the number of channels is 256. The main task of this layer is to integrate and compress the previously extracted features to prepare them for input into subsequent modules for further processing and analysis.
[0139] In some possible implementations, each convolution layer in the feature extraction module can be transferred through a rectified linear unit (ReLU) activation function. Through the ReLU activation function, each convolution layer can retain the feature information in the input focus reference image and pass it to the next layer, which helps the feature extraction module to better learn and capture different features in the input focus reference image, and provide more useful and rich input for subsequent processing.
[0140] It should be noted that, after acquiring the image features of the focus reference image, the feature extraction module may simultaneously send the image features to the first module and the second module respectively (ie, execute S502 and S504 ).
[0141] In this embodiment, the first module and the second module share a feature extraction module and receive image features provided by the same feature extraction module, which reduces the amount of model training, reduces the calculation scale, reduces resource usage, and improves training efficiency.
[0142] S502: Send the image features of the focus reference image to the first module.
[0143] In some possible implementations, the feature extraction module may send the image features of the focus reference image to the first module in the form of a tensor.
[0144] Among them, Tensor is a multidimensional array structure that can represent various data types, such as images, sounds, text, etc. In deep learning, Tensor is the basic data structure for data transmission and calculation in neural networks.
[0145] As an example, an image feature may include multiple features, each of which can be represented by a vector. If the lengths of the vectors corresponding to all features are equal, the image features can be organized into a two-dimensional Tensor. Each row in the Tensor is a vector corresponding to a feature.
[0146] Assuming the number of features is A and the vector length is B, a Tensor with a shape of (A, B) can be generated. After determining the shape of the Tensor, you can also determine whether the data type of the Tensor is a floating point number or an integer based on the actual application scenario. Then, fill the image features of the focus reference image into the Tensor. Finally, the filled Tensor is used as input to the first module, and the image features of the focus reference image are sent to the first module.
[0147] By sending the image features of the focus reference image to the first module in the form of Tensor, the feature data can be organized and processed more efficiently, so that the first module can more easily process the image features of the focus reference image to complete the prediction task.
[0148] S503: The first module obtains the defocus amount according to the image features of the focus reference image.
[0149] In some possible implementations, the first module may include three fully connected layers, each layer having 256, 64, and 1 nodes, respectively. Each layer is passed to the next layer through a ReLU activation function. The first module may also be called a defocus amount prediction module. When the first module receives the image features of the focus reference image from the feature extraction module, it may process the image features through three fully connected layers in sequence to obtain the defocus amount.
[0150] As an example, the first fully connected layer has 256 nodes. In the first fully connected layer, each node can be associated with a different combination of image features, which are further combined and mapped to obtain higher-level and more abstract features. This layer passes the extracted features and their output to the next layer through the ReLU activation function. Among them, the ReLU activation function can make negative values become zero and retain positive values, effectively introducing nonlinear properties.
[0151] The second fully connected layer has 64 nodes. Similar to the first fully connected layer, the second fully connected layer receives the features output by the first fully connected layer and associates each node with the features output by the first fully connected layer, obtaining more abstract and complex features based on the features output by the first fully connected layer. Similarly, the ReLU activation function is applied to the output of this layer to introduce nonlinear properties.
[0152] The third fully connected layer has 1 node, and its output is the predicted defocus. This node further combines and calculates the input features, such as mapping and transforming them using linear or nonlinear functions, to obtain the predicted defocus.
[0153] S504: Send the image features of the focus reference image to the second module in the form of Tensor.
[0154] In some possible implementation modes, the implementation mode of S504 is the same as that of S502. For details, please refer to the content of S502, which will not be described in detail here.
[0155] S505. The second module obtains the confidence level of the predicted defocus amount according to the image features of the focus reference image.
[0156] In some possible implementations, the confidence level indicates the probability that the predicted defocus amount obtained by the first module based on the image features of the focus reference image is the actual defocus amount (i.e., the defocus amount when the focus is accurate). The confidence level can be a value between [0,1]. The closer the confidence level is to 1, the greater the probability that the predicted defocus amount obtained by the first module based on the image features of the focus reference image is the actual defocus amount; the closer the confidence level is to 0, the smaller the probability that the defocus amount obtained by the first module based on the image features of the focus reference image is the actual defocus amount.
[0157] In some possible implementations, the second module includes three fully connected layers, each layer having 256, 64, and 1 nodes, respectively. Each layer is passed to the next layer through a ReLU activation function. After the image features of the focus reference image are input into the second module, the second module performs calculations based on the image features of the focus reference image to generate a confidence level corresponding to the focus reference image.
[0158] As an example, the first two fully connected layers in the second module may process features in a similar manner to the first two convolutional layers in the first module, which will not be described in detail here.
[0159] The third fully connected layer in the second module sets a node whose output is the confidence. This node further combines and calculates the input features of the previous two layers to obtain the confidence of the defocus amount calculated based on the image features of the focus reference image.
[0160] In this embodiment, the second module needs to be pre-trained to improve its prediction accuracy. Figure 6 It is a schematic diagram of the training process of the second module in the defocus amount acquisition method provided in an embodiment of the present application.
[0161] In some possible implementations, reference is made to Figure 6 , when training the second module, you can follow the steps below:
[0162] S601: Acquire multiple groups of focus reference image samples, and extract image features of each group of focus reference image samples.
[0163] In some possible implementations, multiple groups of focus reference image samples may be pre-set, and each group of focus reference image samples includes at least two images of the same scene at different viewing angles and a true defocus value.
[0164] In this embodiment, the method of extracting the image features of each group of focus reference image samples is the same as the method of acquiring the image features of the focus reference image in S501, and is not described in detail here.
[0165] S602: Input the image features of each group of focus reference image samples into the first module and the second module respectively, and obtain the predicted defocus amount and the confidence level of the predicted defocus amount corresponding to each group of focus reference image samples.
[0166] In some possible implementations, the first module may be pre-trained and frozen when the second module is trained, that is, the training result of the second module will not cause the parameters of the first module to change.
[0167] In some possible implementations, after the image features of the focus reference image sample are input into a pre-trained first module, the first module will output a predicted defocus amount (defocus') based on the image features, and after the image features of the focus reference image sample are input into a second module, the second module will output a confidence (confidence) of the predicted defocus amount output by the first module based on the image features.
[0168] S603: Obtain the error between the predicted defocus amount and the actual defocus amount corresponding to each group of focus reference image samples.
[0169] In some possible implementations, the error d between the actual defocus amount (defocus) and the predicted defocus amount (defocus') can be calculated by Formula 1:
[0170] d=|defocus-defocus'|(Formula 1)
[0171] By calculating the error between the predicted defocus amount and the actual defocus amount corresponding to each group of focus reference image samples, multiple errors d can be obtained.
[0172] In some other possible implementations, the error d may also be calculated by other methods, for example, by using Formula 2:
[0173]
[0174] S604. According to the error, mark the confidence level that meets the first preset condition as true, and mark the confidence level that does not meet the first preset condition as false.
[0175] In some possible implementations, the errors may be sorted first, and then the confidence levels may be marked according to a first preset condition.
[0176] As an example, the first preset condition may include determining that the confidence level corresponding to the errors in the sorted errors that meet the first threshold meets the first preset condition, and determining that the confidence level corresponding to the errors in the sorted errors that do not meet the first threshold does not meet the first preset condition.
[0177] The first threshold may be a percentage (p%), the number of errors (n, where n is an integer greater than or equal to 1), or the like.
[0178] In some possible implementations, when the first threshold can be a percentage (p%), it can be determined that the confidence levels corresponding to the first p% of the sorted errors meet the first preset condition, and it can be determined that the confidence levels corresponding to the last (100-p)% of the sorted errors do not meet the first preset condition.
[0179] As an example, assuming that there are 64 groups of focus reference image samples in total and 64 errors are obtained, the errors can be sorted in ascending order.
[0180] When the first threshold is a percentage, the first threshold may be 10%, then the first 10% includes 6.4 errors, which can be rounded up, that is, the confidence corresponding to the first 7 errors meets the first preset condition. The last 90% includes 57.6 errors, which can be rounded down, that is, the confidence corresponding to the last 57 errors does not meet the first preset condition.
[0181] When the first threshold is the number of errors, the first threshold may be 10, that is, the confidences corresponding to the first 10 errors meet the first preset condition, and the confidences corresponding to the last 54 errors do not meet the first preset condition.
[0182] In some possible implementations, when a confidence level that meets the first preset condition is marked as true and a confidence level that does not meet the first preset condition is marked as false, a confidence label (confidencelabel) may be set for each confidence level. When a confidence level meets the first preset condition, the confidence label of the confidence level may be marked as 1, indicating that the confidence level is marked as true. Similarly, when a confidence level does not meet the first preset condition, the confidence label of the confidence level may be marked as 0, indicating that the confidence level is marked as false.
[0183] S605: Train the second module according to the confidence mark to obtain a trained second module.
[0184] In some possible implementations, the second module may be trained by back propagation based on the confidence labels corresponding to the confidence levels of each set of in-focus reference image samples.
[0185] In some possible implementations, during training, multiple groups of focus reference image samples may be divided into different batches and trained separately.
[0186] Since the smaller the error of a set of focus reference image samples, the greater the probability that the corresponding confidence label is true. The same set of focus reference image samples may have different confidence labels in different training batches. Training based on different batches can make the confidence output of the second module obtained by training more accurate.
[0187] In this embodiment, when training the second module, the confidence label is determined according to the error sorting, and then training is performed according to the confidence label. In this way, when training the second module, the smaller the error, the higher the confidence obtained, and the larger the error, the lower the confidence obtained. Moreover, the error is obtained from the defocus output by the first module, and the first module and the second module share the features output by the feature extraction module. The second module obtained by training in this way takes into account the characteristics and errors of the image, and the output confidence is more accurate and more in line with the requirements. The defocus amount determined according to the confidence is also more accurate, closer to the actual defocus amount, and the PDAF effect is also better.
[0188] S506: The camera application determines a target defocus amount among the multiple predicted defocus amounts according to the confidence level corresponding to each predicted defocus amount.
[0189] In some possible implementations, the camera application may select a predicted defocus amount with the highest confidence as the target defocus amount based on the confidence levels corresponding to the predicted defocus amounts.
[0190] The camera application can then drive the motor in the camera according to the target defocus amount, placing the lens at the position indicated by the target defocus amount, completing PDAF.
[0191] It should be understood that the above examples are intended to help those skilled in the art understand the embodiments of the present application, and are not intended to limit the embodiments of the present application to the specific numerical values or specific scenarios illustrated.
[0192] It is obvious that those skilled in the art can make various equivalent modifications or changes based on the above examples, and such modifications or changes also fall within the scope of the embodiments of the present application.
[0193] Corresponding to the method for obtaining the defocus amount provided in the above embodiment, Figure 7 This is a structural block diagram of a defocus amount acquisition device provided in an embodiment of the present application. For the sake of convenience of explanation, only the parts related to the embodiment of the present application are shown.
[0194] Reference Figure 7 , a defocus amount acquisition device, applied to electronic equipment, comprising:
[0195] The acquisition module 71 is used to acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene from different viewing angles.
[0196] The acquisition module 71 is also used to obtain the predicted defocus amount and the confidence of the predicted defocus amount corresponding to each group of focus reference images according to multiple groups of focus reference images through a pre-trained focus model, wherein the focus model includes a first module and a second module, the first module is used to output the predicted defocus amount, the second module is used to output the confidence of the predicted defocus amount, and the second module is trained based on the error between the predicted defocus amount output by the first module and the actual defocus amount and the confidence of the predicted defocus amount.
[0197] The determination module 72 is used to determine a target defocus amount from a plurality of predicted defocus amounts according to confidence levels corresponding to the plurality of predicted defocus amounts.
[0198] In some possible embodiments, the device also includes a training module 73, which is used to obtain multiple groups of focus reference image samples and extract image features of each group of focus reference image samples, each group of focus reference image samples including at least two images of the same scene from different perspectives and an actual defocus amount; input the image features of each group of focus reference image samples into the first module and the second module respectively to obtain a predicted defocus amount corresponding to each group of focus reference image samples and a confidence level of the predicted defocus amount; obtain an error between the predicted defocus amount corresponding to each group of focus reference image samples and the actual defocus amount; based on the error, mark the confidence level that meets the first preset condition as true, and mark the confidence level that does not meet the first preset condition as false; train the second module based on the confidence level mark to obtain a trained second module.
[0199] Some possible implementations further include a marking module 74 for sorting errors; determining that the confidence levels corresponding to the errors that meet the first threshold among the sorted errors meet the first preset condition; and determining that the confidence levels corresponding to the errors that do not meet the first threshold among the sorted errors do not meet the first preset condition.
[0200] In some possible implementations, the errors are sorted in order from small to large, and the first threshold is p%;
[0201] The marking module 74 is specifically used to determine whether the confidence corresponding to the first p% errors in the sorted errors meets the first preset condition.
[0202] The marking module 74 is specifically configured to determine that the confidences corresponding to the last p% errors in the sorted errors do not meet the first preset condition.
[0203] In some possible implementations, the errors are sorted in ascending order, and the first threshold is a preset error number n, where n is an integer greater than or equal to 1;
[0204] The marking module 74 is specifically configured to determine whether the confidences corresponding to the first n errors in the sorted errors meet the first preset condition.
[0205] The marking module 74 is specifically configured to determine whether the confidences corresponding to the errors after the nth one in the sorted errors do not meet the first preset condition.
[0206] In some possible implementations, the focus model further includes a feature extraction module, and the first module and the second module are respectively connected to the feature extraction module.
[0207] In some possible implementations, the acquisition module 71 is specifically configured to acquire image features of the focus reference image according to the focus reference image through the feature extraction module. Through the first module, the predicted defocus amount of the focus reference image is acquired according to the image features. Through the second module, the confidence of the predicted defocus amount of the focus reference image is acquired according to the image features.
[0208] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0209] Each functional unit and module in the embodiment may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit, and the above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional unit. For example, a "module" may be a software program, a hardware circuit, or a combination of the two that implements the above-mentioned functions. The hardware circuit may include an application specific integrated circuit (ASIC), an electronic circuit, a processor (such as a shared processor, a dedicated processor, or a group processor, etc.) and a memory for executing one or more software or firmware programs, a merged logic circuit, and / or other suitable components that support the described functions.
[0210] Therefore, the modules of each example described in the embodiments of the present application can be implemented with electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0211] In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other and are not used to limit the protection scope of this application. The specific working process of the units and modules in the above system can refer to the corresponding process in the above method embodiment, which will not be repeated here.
[0212] It should be understood that the hardware system and chip in the embodiments of the present application can execute the various methods of entering the long standby mode in the aforementioned embodiments of the present application, that is, the specific working processes of the following various products can refer to the corresponding processes in the aforementioned method embodiments.
[0213] An embodiment of the present application also provides another electronic device, including a processor and a memory.
[0214] Memory is used to store computer programs that can be executed on the processor.
[0215] The processor is used to execute the processing steps in the method for entering the long standby mode as described above.
[0216] An embodiment of the present application also provides a computer-readable storage medium, in which computer instructions are stored; when the computer-readable storage medium is executed on an electronic device, the electronic device executes the method as shown above.
[0217] The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means.
[0218] The computer-readable storage medium may be any available medium that can be accessed by a computer or may include one or more servers, data centers, and other data storage devices that can be integrated with the medium.
[0219] The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium, or a semiconductor medium (eg, a solid state disk (SSD)).
[0220] The embodiment of the present application also provides a computer program product including computer instructions, which, when executed on an electronic device, enables the electronic device to execute the technical solution shown above.
[0221] Figure 8 It is a schematic diagram of the structure of a chip provided in an embodiment of the present application. Figure 8 The chip shown can be a general-purpose processor or a dedicated processor. The chip includes a processor 801. The processor 801 is used to support the electronic device to execute the technical solution shown above.
[0222] Optionally, the chip further includes a transceiver 802, and the transceiver 802 is used to accept the control of the processor 801 and to support the communication device to execute the technical solution shown above.
[0223] Optional, Figure 8 The chip shown may also include: a storage medium 803 .
[0224] It should be noted that Figure 8 The chip shown can be implemented using the following circuits or devices: one or more field programmable gate arrays (FPGAs), programmable logic devices (PLDs), controllers, state machines, gate logic, discrete hardware components, any other suitable circuits, or any combination of circuits that can perform the various functions described throughout this application.
[0225] The electronic device, computer storage medium, computer program product, and chip provided in the above-mentioned embodiments of the present application are all used to execute the methods provided above. Therefore, the beneficial effects that can be achieved can refer to the corresponding beneficial effects of the methods provided above, and will not be repeated here.
[0226] It should be understood that the above is only to help those skilled in the art to better understand the embodiments of the present application, and is not intended to limit the scope of the embodiments of the present application. Those skilled in the art can obviously make various equivalent modifications or changes based on the above examples given.
[0227] For example, some steps in each embodiment of the above method may be unnecessary, or some new steps may be added, etc. Or a combination of any two or any multiple embodiments above. Such modified, changed or combined solutions also fall within the scope of the embodiments of the present application.
[0228] It should also be understood that the above description of the embodiments of the present application focuses on emphasizing the differences between the various embodiments. The same or similar points that are not mentioned can be referenced to each other. For the sake of brevity, they will not be repeated here.
[0229] It should also be understood that the size of the serial numbers of the above-mentioned processes does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0230] It should also be understood that in the embodiments of the present application, "pre-setting" and "pre-definition" can be achieved by pre-saving corresponding codes, tables or other methods that can be used to indicate relevant information in a device (for example, including an electronic device), and the present application does not limit its specific implementation method.
[0231] It should also be understood that the division of the methods, situations, categories and embodiments in the embodiments of the present application is only for the convenience of description and should not constitute a special limitation. The features of various methods, categories, situations and embodiments can be combined without contradiction.
[0232] It should also be understood that in the various embodiments of the present application, unless otherwise specified or there is a logical conflict, the terms and / or descriptions between different embodiments are consistent and can be referenced to each other, and the technical features in different embodiments can be combined to form new embodiments according to their internal logical relationships.
[0233] Finally, it should be noted that the above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any changes or substitutions within the technical scope disclosed in the present application should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A method for obtaining a defocus amount, characterized in that: Applied to electronic equipment, the method comprises: Acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene at different viewing angles; By using a pre-trained focus model, according to a plurality of groups of focus reference images, a predicted defocus amount and a confidence level of the predicted defocus amount corresponding to each group of the focus reference images are obtained, wherein the focus model includes a first module and a second module, the first module is used to output the predicted defocus amount, the second module is used to output the confidence level of the predicted defocus amount, and the second module is obtained by training according to the error between the predicted defocus amount output by the first module and the actual defocus amount and the confidence level of the predicted defocus amount, including: Acquire multiple groups of focus reference image samples, and extract image features of each group of the focus reference image samples, wherein each group of the focus reference image samples includes at least two images of the same scene at different viewing angles and a true defocus value; Inputting the image features of each group of the focus reference image samples into the first module and the second module respectively, to obtain the predicted defocus amount corresponding to each group of the focus reference image samples and the confidence of the predicted defocus amount; Obtaining an error between a predicted defocus amount corresponding to each group of the focus reference image samples and the actual defocus amount; According to the error, marking the confidence level that meets the first preset condition as true, and marking the confidence level that does not meet the first preset condition as false; Training the second module according to the confidence mark to obtain a trained second module; According to the confidence levels corresponding to the multiple predicted defocus amounts, a target defocus amount is determined from the multiple predicted defocus amounts.
2. The method according to claim 1, characterized in that The step of marking the confidence level that meets the first preset condition as true and marking the confidence level that does not meet the first preset condition as false according to the error includes: sorting the errors; Determining that the confidence corresponding to the error that meets the first threshold among the sorted errors meets the first preset condition; It is determined that the confidence corresponding to the error that does not meet the first threshold among the sorted errors does not meet the first preset condition.
3. The method according to claim 2, characterized in that The errors are sorted in ascending order, and the first threshold is p%. The determining that the confidence corresponding to the error that meets the first threshold among the sorted errors meets the first preset condition includes: Determining that the confidences corresponding to the first p% of the errors after sorting meet the first preset condition; The determining that the confidence corresponding to the error that does not meet the first threshold among the sorted errors does not meet the first preset condition includes: It is determined that the confidences corresponding to the last (100-p)% of the errors after sorting do not meet the first preset condition.
4. The method according to claim 2, characterized in that: The errors are sorted in ascending order, the first threshold being a preset error number n, where n is an integer greater than or equal to 1; The determining that the confidence corresponding to the error that meets the first threshold among the sorted errors meets the first preset condition includes: Determining whether the confidences corresponding to the first n errors in the sorted errors meet the first preset condition; The determining that the confidence corresponding to the error that does not meet the first threshold among the sorted errors does not meet the first preset condition includes: It is determined that the confidences corresponding to the errors after the nth one in the sorted errors do not meet the first preset condition.
5. The method according to claim 1, characterized in that The focus model also includes a feature extraction module, and the first module and the second module are respectively connected to the feature extraction module.
6. The method according to claim 5, characterized in that The pre-trained focus model is used to obtain the defocus amount and confidence level corresponding to each group of the focus reference images according to the multiple groups of the focus reference images, including: Acquiring, by means of the feature extraction module, image features of the focus reference image according to the focus reference image; Acquire the predicted defocus amount of the focus reference image according to the image feature through the first module; The confidence level of the defocus amount predicted by the focus reference image is obtained according to the image features through the second module.
7. A defocus amount acquisition device, characterized in that: Used in electronic equipment, including: An acquisition module, used to acquire multiple groups of focus reference images, each group of focus reference images includes at least two images of the same scene from different viewing angles; The acquisition module is further used to acquire, by means of a pre-trained focus model, a predicted defocus amount corresponding to each group of the focus reference images and a confidence level of the predicted defocus amount according to a plurality of groups of the focus reference images, wherein the focus model includes a first module and a second module, the first module is used to output the predicted defocus amount, and the second module is used to output the confidence level of the predicted defocus amount; A training module is used to obtain multiple groups of focus reference image samples, extract image features of each group of focus reference image samples, each group of focus reference image samples includes at least two images of the same scene at different viewing angles and a true defocus amount; input the image features of each group of focus reference image samples into the first module and the second module respectively, obtain the predicted defocus amount corresponding to each group of focus reference image samples and the confidence of the predicted defocus amount; obtain the error between the predicted defocus amount corresponding to each group of focus reference image samples and the true defocus amount; based on the error, mark the confidence that meets the first preset condition as true, and mark the confidence that does not meet the first preset condition as false; train the second module based on the mark of the confidence to obtain the trained second module; A determination module is used to determine a target defocus amount from the multiple predicted defocus amounts according to the confidence levels corresponding to the multiple predicted defocus amounts.
8. An electronic device, characterized in that: The method comprises a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 6 when executing the computer program.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions. When the program instructions are executed by a processor, the processor executes the method according to any one of claims 1 to 6.
