Shooting method and electronic equipment

By generating different types of window fittings in the focus frame, selecting the appropriate window fittings according to the size of the focus frame, determining and pushing the focus horse to reach the target position, the problem of position deviation between the focus frame and the subject is solved, and the focus effect and image quality are improved.

CN120343394APending Publication Date: 2025-07-18HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410040008.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-10
Publication Date
2025-07-18

AI Technical Summary

Technical Problem

During the shooting of electronic devices, in the prior art, there is a deviation between the position of the focus frame and the shooting subject, resulting in poor focus effect.

Method used

By generating different types of window fittings in the focus frame, select the appropriate window fitting form according to the size of the focus frame, combine the focus frame and the window fitting position to determine the target focus position, and use the corresponding focus motor to push it to the target position for focus.

Benefits of technology

Improves the accuracy and focus effect of focus to ensure the quality of the captured image.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120343394A_ABST
    Figure CN120343394A_ABST
Patent Text Reader

Abstract

A shooting method and an electronic device, the method being applied to the electronic device, the method comprising: in response to a first operation, the electronic device displaying a first interface, and displaying a preview image collected through a camera on the first interface; the electronic equipment focuses on a first main body in the first preview image, and the first interface displays the first preview image; under the condition that the electronic equipment determines a target configuration window based on the first focusing frame, the electronic equipment determines a target focusing position based on all sub-configuration windows in the target configuration window and the focusing position of the first focusing frame; the first focusing frame comprises a first main body; the electronic device pushes the focusing horse to the target focusing position. The embodiment of the invention can be used for improving the focusing effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of terminal devices, and particularly to a shooting method and an electronic device. Background Art

[0002] During the process of a user using an electronic device to take a photo, the electronic device can use the autofocus method to take a photo. However, during the shooting process of a frame of image, there is always a deviation between the focus frame and the position of the shooting subject, which may lead to inaccurate results of focusing on the focus frame and poor focusing effect. Summary of the Invention

[0003] Embodiments of this application provide a shooting method and an electronic device, which can be used to improve the focusing effect.

[0004] In a first aspect, embodiments of this application provide a shooting method, which is applied to an electronic device. The method includes: in response to a first operation, the electronic device displays a first interface, and a preview image collected by a camera is displayed on the first interface; the electronic device focuses on a first subject in the first preview image, and the first preview image is displayed on the first interface; when the electronic device determines a target window based on a first focus frame, the electronic device determines a target focus position based on all sub-windows in the target window and the focus position of the first focus frame; the first focus frame includes the first subject; the electronic device drives a focus motor to the target focus position.

[0005] Among them, the first subject can be a portrait, or a cat or dog, an object, a plant or animal, etc., without limitation. The first operation can be an operation of clicking to open the camera, and the target window includes multiple sub-windows.

[0006] In an embodiment of this application, the electronic device can determine a target window based on the current focus frame, and determine a target focus position based on the sub-windows of the target window and the focus frame. The target focus position jointly determined by multiple sub-windows and the focus frame can ensure the accuracy of the target focus position, thereby ensuring a better focusing effect and a better quality of the captured image.

[0007] In a possible implementation manner, the method further includes: the electronic device determines a focusing ratio of the first focus frame; the focusing ratio is the ratio of the size of the first focus frame to the size of the image collected by the camera; the electronic device determines a target window based on the focusing ratio. In this way, the size of the first focus frame can determine the target window, ensuring that different focus frames will have different windowing situations. The accuracy of windowing is related to the accuracy of the target focus position, ensuring a better focusing effect.

[0008] In a possible implementation, determining the target window based on the focusing ratio includes: when the focusing ratio is greater than or equal to a first threshold, determining the target window as a first type of window; when the focusing ratio is less than the first threshold and greater than or equal to a second threshold, determining the target window as a second type of window; when the focusing ratio is less than the second threshold and greater than or equal to a third threshold, determining the target window as a third type of window; when the focusing ratio is less than the third threshold, determining that the target window is not required; wherein, the first type of window is a window form that subdivides the inside of the first focusing frame through a first sub-window; the second type of window is a window form that subdivides the inside of the first focusing frame through a second sub-window and expands the outside of the first focusing frame through a third sub-window; the third type of window is a window form that expands the outside of the first focusing frame through a fourth sub-window. In this way, the larger the area of the focusing frame, the more likely the main subject of focusing is inside the focusing frame. Therefore, the electronic device can subdivide the first type of window into multiple sub-windows to further refine the determination of the accurate focusing position. When the area of the focusing frame is medium, it is impossible to determine whether the main subject of focusing is inside or outside the focusing frame, and the second type of window is used to further determine the accuracy and range of focusing. When the area of the focusing frame is very small, etc., the main subject of focusing is more likely to be outside the focusing frame, and the third type of window form is used to further determine the situation outside the focusing frame to further determine the accuracy and range of focusing.

[0009] In a possible implementation, the first threshold is greater than the second threshold, and the second threshold is greater than the third threshold. In this way, for different sizes of focusing frames, it is possible to consider the possible deviations of the corresponding out-of-focus subjects, and select the corresponding window form to accurately find the main subject to be focused as much as possible to ensure the accuracy of focusing.

[0010] In a possible implementation, the electronic device determines the target accurate focusing position based on all sub-windows in the target window and the accurate focusing position of the first focusing frame, including: when the first subject is a portrait, if the difference between the accurate focusing position of the human body frame and the accurate focusing position of the face frame in the first preview screen is greater than a first depth-of-field threshold, the electronic device uses the accurate focusing position of the human body frame as the target accurate focusing position. In this way, in the case of portrait focusing, when the electronic device determines that the difference between the accurate focusing positions of the human body frame and the face frame is greater than the first depth-of-field threshold, the accurate focusing position of the human body frame is used for focusing. The object distances of the human body frame and the face frame are generally not very different, and the human body area of the human body frame is large, so the focusing accuracy is higher, which can ensure better shooting effects for people.

[0011] In a possible implementation, the electronic device determines the target standard focus position based on the in-focus position of all sub-matching windows in the target matching window and the first focus frame, and further includes: when the first subject is a portrait, if the difference between the in-focus position of the human body frame and the in-focus position of the face frame in the first preview image is less than or equal to the first depth of field threshold, the electronic device determines the target standard focus position based on the near-field priority principle. In this way, when the in-focus position of the focus frame and all matching windows differs greatly, the nearest subject can be selected for in-focus, meeting the goal of near-field priority shooting. Such a shooting process also meets the needs of actual shooting, ensuring the accuracy of the medium-focus subject shot.

[0012] In a possible implementation, the electronic device determines the target standard focus position based on the in-focus position of all sub-matching windows in the target matching window and the first focus frame, and further includes: when the first subject is not a portrait, the electronic device determines the target standard focus position based on the principle of near-field priority. In this way, when the in-focus position of the focus frame and all matching windows is greatly different, the nearest subject can be selected for in-focus, meeting the goal of near-field priority shooting. Such a shooting process also meets the needs of actual shooting, ensuring the accuracy of the medium-focus subject shot.

[0013] In a possible implementation, the electronic device determines the target standard focus position based on the near-view priority principle, including: the electronic device obtains a pre-selected frame set; the pre-selected frame set includes the sub-matching window in the target matching window and the first focus frame and the corresponding quasi-focus position; when the difference between the maximum and minimum values of the quasi-focus position in the pre-selected frame set is greater than the second depth of field threshold, the quasi-focus position with the closest object distance is determined as the target standard focus position. In this way, when the quasi-focus position of the focus frame and all matching windows is greatly different, the nearest shooting subject can be selected for quasi-focus, meeting the goal of near-view priority shooting. Such a shooting process also meets the needs of actual shooting, ensuring the accuracy of the medium-focus subject shot.

[0014] In a possible implementation, the electronic device determines the target focus position according to the principle of foreground priority, and further includes: when the difference between the maximum value and the minimum value of the focus positions in the set of preselected frames is less than or equal to a second depth-of-field threshold, if focusing with the first focus frame is reliable, the focus position of the first focus frame is used as the target focus position; if focusing with the first focus frame is unreliable, the average value of all the focus positions in the set of preselected frames is used as the target focus position. In this way, when the value is less than or equal to (less than) the second depth-of-field threshold and the detection data of the focus of the first focus frame is reliable, the focus position corresponding to the first focus frame is directly used for focusing, which simplifies the method for determining the target focus position while ensuring the reliability of the focus position. When focusing with the first focus frame is unreliable, the average value of all the focus positions corresponding to all the preselected frames in the set of preselected frames is used for focusing, which ensures the reliability of the focus position.

[0015] In a possible implementation, when the confidence level of focusing with the first focus frame is greater than a second confidence threshold, focusing with the first focus frame is reliable; when the confidence level of focusing with the first focus frame is less than or equal to the second confidence threshold, focusing with the first focus frame is unreliable.

[0016] In a possible implementation, the focusing confidence levels of all the preselected frames in the set of preselected frames are greater than or equal to a first confidence threshold; the preselected frames are sub-windows in the target window and / or the first focus frame. By screening the window and the focus frame and removing the focus frames with a large side gap, the reliability and accuracy of subsequent determination of the target focus position can be ensured.

[0017] In a second aspect, an embodiment of the present application provides an electronic device, which includes one or more processors and one or more memories; the one or more processors are coupled to the one or more memories, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device executes a shooting method according to the first aspect or any possible implementation manner of the first aspect.

[0018] In a third aspect, an embodiment of the present application provides a computer program product containing instructions. When the computer program product runs on an electronic device, the electronic device is caused to execute a shooting method according to the first aspect or any possible implementation manner of the first aspect.

[0019] Fourthly, an embodiment of the present application provides a computer-readable storage medium, including instructions, which, when running on an electronic device, cause the electronic device to execute a shooting method as described in the first aspect or any one of the possible implementation manners of the first aspect.

[0020] Fifthly, an embodiment of the present application provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, and the processors are used to call computer instructions to cause the electronic device to execute a shooting method as described in the first aspect or any one of the possible implementation manners of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1A is a schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present application;

[0022] Figure 1B is a schematic diagram of the software structure of an electronic device proposed by an embodiment of the present application;

[0023] Figures 2A - 2E is a set of schematic diagrams of user interfaces proposed by an embodiment of the present application;

[0024] Figure 3 is a schematic diagram of the process of a focusing method proposed by an embodiment of the present application;

[0025] Figure 4 is a schematic diagram of a shooting screen proposed by an embodiment of the present application;

[0026] Figure 5 is a schematic diagram of the process of another focusing method proposed by an embodiment of the present application;

[0027] Figure 6 is a flowchart of a dynamic windowing method proposed by an embodiment of the present application;

[0028] Figure 7 is a schematic diagram of five specific windowing forms proposed by an embodiment of the present application;

[0029] Figures 8A - 8C is a schematic diagram of several windowing types proposed by an embodiment of the present application;

[0030] Figure 9 is a schematic diagram of the process of a method for selecting a second focusing frame proposed by an embodiment of the present application;

[0031] Figure 10 is a schematic diagram of the process of a method for determining a second focusing frame proposed by an embodiment of the present application;

[0032] Figure 11 is a schematic diagram of a face frame and a body frame proposed by an embodiment of the present application. Detailed implementation manners

[0033] The terms used in the following embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the present application. As used in the specification and appended claims of the present application, the singular forms "a", "an", "the", "above-mentioned", "said", "this" are also intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used in the present application refers to and includes any or all possible combinations of one or more of the listed items.

[0034] First, the terms related to the embodiments of the present application will be introduced below.

[0035] I. Focusing:

[0036] Focusing is the process of changing the distance between the lens and the imaging surface (image sensor) through the camera focusing mechanism so that the image of the object to be photographed is clear. The common focusing types can be divided into three types: phase detection autofocus (PDAF), contrast detection autofocus (CDAF), and laser detection autofocus (LDAF).

[0037] Phase Detection Auto-focus (PDAF) is a focusing method that detects the light input of the left and right paired pixel points in the image sensor with the objects in the scene respectively, compares the correlation values (pd values) on the left and right sides, and can find the corresponding focus point of the current pd value based on the corresponding relationship between the pd value and the in-focus position, and then pushes the motor of the lens to the corresponding position. Laser focusing is to emit low-power laser to the object to be photographed through the infrared laser sensor beside the camera, receive it after reflection by the sensor, calculate the distance from the object to be photographed, find the corresponding focus point of the current object distance value based on the corresponding relationship between the object distance and the in-focus position, and then the inter-lens motor directly pushes the lens to the corresponding position to complete the focusing. Contrast focusing is to assume that the contrast between adjacent pixel points is the largest after successful focusing. Based on this assumption, a focus point is determined during the focusing process, the contrast between this focus point and adjacent pixel points is judged, and after repeatedly moving the voice coil motor, a local gradient maximum value is obtained to complete the focusing.

[0038] Auto Focus of Mobile Phones. Auto focus utilizes the principle of object light reflection. The reflected light is received by the image sensor (CCD or CMOS) on the camera in the mobile phone to obtain the original image. The method of driving the electric focusing device to focus by calculating and processing the original image is called auto focus. Essentially, it is a set of data calculation methods integrated in the mobile phone ISP (Image Signal Processor). When the viewfinder captures the most original image, these image data will be transmitted to the ISP as original materials. At this time, the ISP will analyze the image data to obtain the distance that the lens needs to be adjusted, and then drive the focusing motor to make adjustments to make the image clear - this process is what the mobile phone user sees as the auto focus process. Among them, in the auto focus of the mobile phone, the lens is locked in the focusing motor, and driving the focusing motor can change the position of the lens.

[0039] The mobile phone can use the driving code value of the motor in the target camera as the moving adjustment accuracy of the focusing distance to determine the target focusing distance. Among them, the code value of the motor represents a quantified current magnitude, and this current magnitude can be converted into the corresponding motor thrust, so as to push the camera motor to move. Generally, the camera motor is fixed on the lens assembly, so it can push the lens to move, thereby changing the image distance. The code value of the camera motor corresponds to the image distance. Specifically, there are various types of camera motors, and the principles and mechanisms for their conversion into motor position changes are also diverse, which are not restricted here.

[0040] II. Related Concepts during the Focusing Process:

[0041] AF focusing follows the imaging formula 1 / f = 1 / u + 1 / v. Among them, f is the focal length of the camera imaging lens, u is the object distance, and v is the image distance. In a common scene, the object distance u of the object being photographed is fixed, and f is an optical property that basically does not change. The task of AF is to control the lens movement to change v so that the above formula is satisfied as much as possible.

[0042] Combined with the above formula, the focal length is the distance from the focus to the optical center, the object distance is the distance from the object to the optical center of the convex lens, and the image distance is the distance from the image formed by the lens to the optical center of the lens. The light rays passing through the lens and parallel to the principal optical axis converge at a point on the principal optical axis, which is called the focus.

[0043] Among them, the depth of field refers to the range of the front and back distances of the object being photographed that can obtain a clear image when measured at the front edge of the camera lens or other imagers. There is a certain range of object distances before and after focusing for which the photographed objects are clear, and the clear range is recorded as the depth of field range.

[0044] The electronic device in the embodiments of the present application may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a smart bracelet, a super mobile personal computer, a netbook, a personal telephone, a personal data assistant, a touch screen device such as augmented reality (AR) / virtual reality (VR), etc. The specific form of the electronic device is not limited in the present application.

[0045] The following introduces the device involved in the embodiments of the present application.

[0046] Figure 1A It is a schematic diagram of the hardware structure of an electronic device provided for the embodiments of the present application.

[0047] The 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, a headphone interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric 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.

[0048] It can be understood that the structure schematically shown in the embodiments of the present application does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0049] 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 processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0050] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can save the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0051] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0052] The charging management module 140 is configured to receive a charging input from a charger. Among them, the charger may be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 may receive the charging input of the wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 may receive the wireless charging input through the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device through the power management module 141.

[0053] 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 the inputs from the battery 142 and / or the charging management module 140 and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as the battery capacity, the number of battery charge cycles, and the battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.

[0054] The wireless communication function of the electronic device can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.

[0055] The electronic device implements the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, which is connected to 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, which execute program instructions to generate or change the display information.

[0056] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can adopt 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), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is a positive integer greater than 1.

[0057] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.

[0058] The camera 193 is used to capture static images or videos. An object generates an optical image through a lens and projects it onto a photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to the ISP to be converted into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard format such as RGB or YUV. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.

[0059] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the photosensitive element of the camera. The optical signal is converted into an electrical signal, and the photosensitive element of the camera transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also perform algorithm optimization on the noise, brightness, etc. of the image. The ISP can also optimize parameters such as exposure and color temperature of the shooting scene. In some embodiments, the ISP can be disposed in the camera 193. The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc. The ISP can also be used to perform autofocus on the focus information determined for the focused subject.

[0060] The touch sensor 180K, also known as the "touch panel". The touch sensor 180K can be disposed on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also known as the "touch display screen". The touch sensor 180K is used to detect touch operations acting on or near it.

[0061] In the embodiments of the present application, the electronic device 100 can detect user operations through the touch sensor 180K. User operations can include touch events where the user touches the display 194. For example, the user clicks on an object in the shooting preview screen for focusing.

[0062] Optionally, the user operation can also be an air operation, a voice operation instruction, etc. For example, a gesture sensing sensor is installed in the electronic device, and the gesture sensing sensor can detect the user's air operation.

[0063] Figure 1B It is a schematic diagram of the software structure of an electronic device provided in the embodiments of the present application.

[0064] As Figure 1BAs shown in the figure, the software framework of the electronic device involved in this application may include an application layer, an application framework layer (framework, FWK), a hardware abstraction layer (hardware abstract layer, HAL), a hardware layer, and a kernel layer (kernel).

[0065] Among them, the application layer may include a series of application packages, such as application programs in the gallery, mail, text messages, camera, call, etc. (also referred to as applications, some of the above applications are not shown). In the embodiments of this application, the application program may be any application program in the application layer, and the user can open, close the application program, or perform operations in the application program.

[0066] The application framework layer provides application programming interfaces (application programming interface, API) and programming frameworks for the application programs in the application layer. The application framework layer includes some predefined functions.

[0067] The application framework layer includes some predefined functions. In the embodiments of this application, the application framework layer may include a camera access interface. Among them, the camera access interface may include camera management and camera devices. The camera access interface is used to provide application programming interfaces and programming frameworks for camera applications.

[0068] The hardware abstraction layer is an interface layer located between the application framework layer and the driver layer, providing a virtual hardware platform for the operating system. In the embodiments of this application, the hardware abstraction layer may include a camera hardware abstraction layer (camera HAL) and a camera algorithm library. The camera algorithm library may include algorithms such as automatic focus (automatic focus, AF) and automatic exposure (automatic exposure, AE). The camera algorithm library may also include algorithms of types such as noise reduction, color correction, and contrast adjustment, which are not limited in this application.

[0069] The kernel layer is the basis of the Android operating system, and all the final functions of the Android operating system are completed through the kernel layer. The kernel layer at least includes a display driver, etc. The display driver can obtain the completed image frames that have been rendered and synthesized from the buffer cache and control the display to display them in sequence.

[0070] The hardware layer may include a display, a graphics processing unit (graphics processing unit, GPU), a touch sensor, an image sensor (sensor), a focus motor, etc. Among them, the touch sensor can detect the jump events of the user's touch operations. The display can display the image frames of the startup window. The graphics processor can execute the rendering and synthesis process of the image. The central processing unit (CPU) can draw the image.

[0071] It should be noted that the software structure diagram of the electronic device shown in this application is only an example, and does not limit the specific module division in different layers of the Android operating system. For details, reference can be made to the introduction of the software structure of the Android operating system in the conventional technology. In addition, the shooting method provided in this application can also be implemented based on other operating systems, and this application will not list them one by one. Figure 1B Shown in the software structure diagram of the electronic device only as an example, does not limit the specific module division in different layers of the Android operating system, specifically can refer to the introduction of the Android operating system software structure in the conventional technology. In addition, the shooting method provided in this application can also be implemented based on other operating systems, this application will not list them one by one.

[0072] Next, in combination with the above software structure, the working processes of the software and hardware in the embodiments of this application when taking pictures using an electronic device will be exemplarily described.

[0073] In response to the user's operation of opening the camera application, for example, the operation of clicking on the camera application icon (combined with Figure 2A the user operation), the camera application calls the camera access interface of the application framework layer to start the camera application, and then sends an instruction to start the camera through the camera device in the camera HAL. The camera HAL sends this instruction to the camera device driver in the kernel layer. This camera device driver can start the image sensor of the corresponding camera, and collect the image optical signal through the image sensor. One camera device in the camera hardware abstraction layer corresponds to one image sensor in the hardware layer. The image sensor can transmit the collected image optical signal to the image signal processor for preprocessing to obtain an image electrical signal, and transmit the above original image to the camera HAL through the camera device driver. The camera HAL can send the original image to the camera algorithm library. The program code for implementing the focusing-based method provided in the embodiments of this application is stored in the camera algorithm library. The camera algorithm library can send the processed image to the camera HAL, and the camera HAL can display the processed image.

[0074] During the shooting process, the electronic device can calculate the focusing position of the focusing motor through the AF algorithm, and then the camera driver can control the focusing motor to adjust the position to complete the focusing. When it is necessary to adjust the size and / or position of the focusing frame, the camera driver can drive the focusing motor, and the focusing motor can push the lens to the corresponding focusing position.

[0075] Figures 2A - 2E This is a set of user interface schematic diagrams exemplarily disclosed in the embodiments of this application.

[0076] Figures 2A - 2E Exemplarily shows the user interface schematic diagram of the focusing process of the electronic device. The user turns on his own electronic device, so that the display screen of the electronic device displays the desktop of the electronic device, that is, the user interface 210. As Figure 2A shown, the user can click on the camera control 211 in the user interface 210. After the electronic device receives the operation acting on the camera control 211, it can displayFigure 2B The user interface shown Figure 2B is an exemplary user interface for shooting

[0077] As Figure 2B shown, the electronic device shoots a scene of multiple people. The user interface 220 includes a preview image 11, a shooting mode menu 12, an album 10A, shooting controls 10B, a switch camera control 10C, and a settings menu 13 (including a flash switch, a filter switch, and settings controls, etc.). Among them:

[0078] Among them, the preview image 11 is an image of the shooting scene collected in real time by the electronic device 1 through the camera. The images of people collected by the electronic device through the camera are displayed in the preview image. The shooting mode menu 12 may include options for various camera modes such as aperture, night scene, photo, portrait, video recording, professional, more, etc. Different camera modes can achieve different shooting functions. The camera mode pointed to by the "triangle" in the shooting mode menu 12 is used to indicate the initial or user-selected camera mode. As Figure 2B shown, the "triangle" points to "photo", indicating that the current camera is in the photo shooting mode. The album 10A is used for the user to view the captured pictures and videos. The shooting controls 10B, in response to the user's operation, cause the electronic device to shoot pictures or videos. The switch camera control 10C is used to switch the camera for collecting images between the front camera and the rear camera.

[0079] When the electronic device displays a preview screen, it is possible to focus on the shooting subject. The following describes the focusing process based on different types:

[0080] 1. Automatic face focusing in portrait mode:

[0081] When the electronic device displays the user interface 220 as Figure 2B shown, if the user wants to take a photo of a person, they can click the "portrait" control in the shooting mode menu 12 to enter the portrait mode. As Figure 2C shown, when the electronic device displays the portrait mode, it can recognize that there are 3 faces in the picture and focus on one of the faces. The left face is selected for focusing in the user interface 230, and a focus frame 14 is displayed in the preview screen.

[0082] It should be noted that when the electronic device recognizes a face, it can track the face focus, so face focusing is not limited to the portrait mode.

[0083] 2. Manual focusing:

[0084] As Figure 2DAs shown, the electronic device displays the user interface 240 to shoot the preview screen 15. If the user wants to shoot a person, he can manually click on the person in the screen, and the electronic device can display the corresponding focus frame based on the click position. Figure 2E As shown, the electronic device responds to Figure 2D During the focus operation in the image processing unit, a focus frame 16 can be displayed, and the electronic device can focus at the position of the focus frame 16.

[0085] 3. Automatic recognition and focus:

[0086] When the electronic device enters the auto focus mode, it can identify the subject in the preview image and focus on the subject. In the above process, the electronic device may display the focus frame or may not display the focus frame, which is not limited in this application.

[0087] It should be noted that the above-mentioned focusing processes are all exemplary descriptions, and other focusing types are also possible, which are not limited in this application.

[0088] Figure 3 Schematic diagram of a focusing method disclosed in an exemplary embodiment of the present application. Figure 3 As shown, the focusing method may include but is not limited to the following steps:

[0089] S301: The electronic device determines a first focus frame in response to a focus request.

[0090] When the electronic device displays a preview image of the camera, it can be determined that a first focusing frame is to be used.

[0091] In one possible implementation, when the electronic device displays a preview image of the camera, it extracts semantic information from the image and automatically focuses based on the semantic information. Figure 2C As shown, when the electronic device recognizes that the current picture includes multiple faces, the electronic device can select the position of one of the faces as the first focus frame. For another example, the electronic device can extract voice information from the preview picture, determine that the photographed object is a kitten, and the electronic device can automatically focus on the photographed kitten. The above-mentioned focus object is not limited.

[0092] In another possible implementation, when the electronic device displays a preview screen of the camera, the user can click on the first subject in the preview screen as the focus subject, and the electronic device can determine that the first focus frame includes the focus subject. Figure 2C In the display screen shown, when the electronic device turns on the camera and enters the shooting preview screen, the electronic device can focus the screen. The user can manually select the focus position and shoot the screen. Figure 2D As shown, the user clicks a position in the preview image to focus.

[0093] It should be noted that in the actual shooting process, there are many ways to determine the focus frame, and the above two embodiments of the present application are only examples and are not limiting.

[0094] S302: The electronic device determines a focus position of a first focusing frame.

[0095] The in-focus position may be a target code corresponding to the position of the focus motor. After determining the first focus frame, the electronic device may determine the in-focus position based on the first focus frame.

[0096] like Figure 2E As shown, during the shooting process, since the first focus frame is in a square shape, the first focus frame can include not only the face of the person, but also the background picture of the face. The code corresponding to the background picture of the face is different from the code value of the face picture. When the electronic device needs to determine the target code value, it needs to refer to these code values, and may choose an intermediate value between the code corresponding to the background picture and the code value of the face picture, and cannot effectively focus on the face.

[0097] S303: The electronic device drives the focus motor to reach a focus position.

[0098] After determining the quasi-focus position of the first focus frame, the electronic device can drive the focus motor to the quasi-focus position through the camera to complete the focusing process. For the specific focusing process, please refer to Figure 1B As for the description of focus, I will not go into details here.

[0099] In the above process, since the focus frame is square in shape and the focused subjects are of various shapes, the edge shape of the focused subject is almost impossible to coincide with the shape of the focus frame during the focusing process. Generally, the focus frame will at least include the focused subject and often also include other background images outside the focus frame.

[0100] For example, Figure 4 Schematic diagram of a shooting screen shown in an exemplary embodiment of the present application. Figure 4 As shown, the focus frame in the preview image includes leaves, part of the face and part of the background. The object distances of these three parts are inconsistent, and the corresponding focus codes are different. The electronic device will make a balance and choice in the process of selecting the above three codes for focus. However, the subject that the user really wants to focus on often deviates from the subject that the user really wants to focus on when the electronic device is determining the code focus. For example, in user interface 410, the subject that the user really wants to focus on is the leaves, not the face or the background. In user interface 250, the user wants to focus on the side face of the user, but the focus frame includes the background. In the above situation, since the focus frame includes more than just the focus subject, the accuracy of the focus result is poor.

[0101] During the above-mentioned shooting process, the effect of autofocus in side face scenes, hollow scenes, and close-up subject detection scenes is unsatisfactory. The reason is that AF can only obtain the focus frame and cannot perceive any semantic information within it, especially in hollow scenes or scenes with too large a focus frame, it is extremely difficult for AF to focus on the user's desired focus area.

[0102] In response to the above problems, an embodiment of the present application proposes a shooting method, which can generate different types of matching windows based on the size of the focus frame. When the focus frame area is large, the window is matched inside the focus frame; when the focus frame area is moderate, the window is matched inside and outside the focus frame; when the focus frame area is small, the window is mainly matched outside the focus frame. Ensuring different types of matching windows can help the electronic device determine the subject that is more worthy of focus and ensure the accuracy of focus. After the window matching process, the electronic device can determine the target standard focus position based on the current focus frame, all matching windows and the type of the focus subject, and push the focus motor to the target standard focus position to complete the focus. Among them, if the type of the focus subject is a portrait, the electronic device can tend to use the human body frame to focus. If it is not a portrait, select close-up priority focus to ensure that nearby objects can be given priority focus processing, ensure the accuracy of focus, and better match the needs of the user's specific focus scene.

[0103] Figure 5 FIG. 1 is a schematic diagram of another focusing method process disclosed in an exemplary embodiment of the present application. Figure 5 As shown, the focusing method may include but is not limited to the following steps:

[0104] S501: The electronic device determines a first focus frame in response to a focus request.

[0105] The electronic device may determine that the size of the first focus frame is x*y pixels.

[0106] The specific description of S501 can refer to the relevant content of S301 and will not be repeated here.

[0107] S502: The electronic device determines a window matching form based on the first focus frame, and performs a window matching process.

[0108] The window matching form is the position distribution form of each focus frame, and different window matching forms may include multiple sub-window matching. The window matching form may include three types of window matching forms, and the above-mentioned window matching form may be formed by multiple sub-window matching. The electronic device may determine the window matching form according to the size of the first focus frame and perform window matching processing. In the process of window matching processing, the electronic device may determine the position and size of each sub-window matching.

[0109] Figure 6It is a flowchart of a dynamic window matching method disclosed in an embodiment of the present application. As Figure 6 shown, the dynamic window matching method may include but is not limited to the following steps:

[0110] S5021: The electronic device calculates the focusing ratio of the first focusing frame.

[0111] Among them, the focusing ratio A is the ratio of the area of the first focusing frame to the first area. The first area is the size of the image captured by the camera of the electronic device. Assume that the first area is M*N. The focusing ratio can be A = x*y / M*N. Wherein, both M and N are integers greater than 1, x is an integer from 1 to M, and y is an integer from 1 to N.

[0112] The electronic device can determine the target window matching based on the focusing ratio, which will be specifically described in combination with S5022 - S5028.

[0113] S5022: The electronic device determines whether the focusing ratio is greater than (greater than or equal to) the first threshold. If the focusing ratio is greater than (greater than or equal to) the first threshold, S5023 is executed; if the focusing ratio is less than or equal to (less than) the first threshold, S5024 is executed.

[0114] The electronic device compares the focusing ratio A with the first threshold K1, and determines whether to execute S5023 or S5024 based on the size relationship between A and K1. The range of K1 is 0 - 1.

[0115] Exemplarily, when K1 is 0.3 and A is 0.32, 0.32 > 0.3, the electronic device executes S5023; when A is 0.28 and 0.28 < 0.3, S5024 is executed. The above is only an exemplary expression, and does not limit the specific values of K1 and A.

[0116] S5023: The electronic device determines the first type of window matching as the target window matching.

[0117] When the focusing ratio is greater than (greater than or equal to) the first threshold, the electronic device can determine the first type of window matching as the target window matching.

[0118] Among them, the first type of window matching can be a window matching form that divides the inside of the first focusing frame through the first sub - window. Multiple first sub - windows can divide the area of the first focusing frame. Exemplarily, the first type of window matching can be a "grid window matching" or a "nine - grid window matching", etc. The sub - windows in the first type of window matching are all within the area of the first focusing frame.

[0119] Figure 7 It is a schematic diagram of five specific window matching forms shown in an embodiment of the present application. As Figure 7Among them, (a) and (b) are "window matching in a grid of four squares" and "window matching in a grid of nine squares" respectively. Among them, the number of sub-window matches in "window matching in a grid of four squares" is 4; the number of sub-window matches in "window matching in a grid of nine squares" is 9. The division of "window matching in a grid of nine squares" is more refined. It should be noted that Figure 7 This is only an exemplary description, and the present application does not limit the specific form of the window matching form.

[0120] Figures 8A - 8C are schematic diagrams of several window matching types in the exemplary description of the embodiments of the present application. Combining Figure 6 with the window matching logic, several different window matching types are described respectively, as follows:

[0121] For example Figure 8A As shown, in the user interface 810, the window matching in a grid of four squares 811 has four sub-window matches (all inside the first focus frame). The upper left sub-window match includes a small part of the leaves and most of the background; the upper right sub-window match is mostly a human face and a small part of the leaves; the lower left sub-window match is mostly the background and a small part of the leaves; the lower right sub-window match only includes leaves. It should be noted that during the specific shooting process, the user interface can only display the first focus frame and not display the window match, and the window match is only used for calculation. Of course, the window match can also be displayed. The present application does not limit the specific shooting display situation.

[0122] S5024: The electronic device determines whether the focus ratio is greater than (greater than or equal to) a second threshold. If it is greater than (greater than or equal to) the second threshold, S5025 is executed; otherwise, S5026 is executed.

[0123] The electronic device compares the focus ratio A with the second threshold K2, and determines whether to execute S5025 or S5026 based on the size relationship between A and K2. The range of K2 is 0 to 1, and K2 < K1.

[0124] Exemplarily, when K2 is 0.2 and A is 0.22, 0.22 > 0.2, and the electronic device executes S5025; when A is 0.19 and 0.19 < 0.2, S5026 is executed. The above is only an exemplary expression, and the specific values of K2 and A are not limited.

[0125] S5025: The electronic device determines the second type of window match as the target window match.

[0126] The second type of window match is a window matching form that subdivides the inside of the first focus frame through a second sub-window match and expands the outside of the first focus frame through a third sub-window match. In the second type of window match, at least one second sub-window match is inside the first focus frame, and at least one third sub-window match includes the first focus frame and the area outside the first focus frame. Exemplarily, the second type of window match can be a window match in a double-square. For example Figure 7As shown in (c), the square-within-square window includes a sub-window (window 1) within the first focus frame and another sub-window (window 2) that includes the first focus frame and has an area larger than the first focus frame.

[0127] As Figure 8B shown, in the user interface 820, the square-within-square window 821 includes two sub-windows. One sub-window is within the first focus frame, and the other includes the first focus frame and is shown as a nested two-layer frame. The inner sub-window shows a human face, and the outer sub-window shows a human face, part of the background, and part of the human body.

[0128] S5026: The electronic device determines whether the focus ratio is greater than (greater than or equal to) the third threshold. If it is greater than (greater than or equal to) the third threshold, S5027 is executed; otherwise, S5028 is executed.

[0129] The electronic device compares the focus ratio A with the second threshold K3 and determines whether to execute S5027 or S5028 based on the size relationship between A and K3. The range of K3 is 0 to 1, and K3 < K2 < K1.

[0130] Among them, the corresponding focus frame of the third threshold can be in the range of 100*100 to 120*120 pixels. That is, the third threshold can be 100*100 / x*y to 120*120 / x*y. The specific size of the third threshold is not limited.

[0131] Exemplarily, when K3 is 0.1 and A is 0.12, 0.12 > 0.1, the electronic device executes S5025; when A is 0.09 and 0.09 < 0.1, S5026 is executed. The above is only an exemplary expression, and the specific values of K3 and A are not limited.

[0132] S5027: The electronic device determines the third type of window as the target window.

[0133] The third type of window is a window form that expands the outside of the first focus frame through the fourth sub-window. At least one of the fourth sub-windows in the third type of window includes the outside area of the first focus frame. For example, the third type of window is a cross window. As Figure 7 shown in (d) and (e) are both cross windows. Figure 7 In (d), the window type includes 4 sub-windows, Figure 7 In (e), the window type includes 8 sub-windows. It should be noted that the sub-windows of the cross window can all be outside the first focus frame; or some can be outside the first focus frame and some can be inside the first focus frame, which is not limited in this application.

[0134] Among them, the number of the first sub-window, the second sub-window, the third sub-window, and the fourth sub-window in the first type of window, the second type of window, and the third type of window is greater than or equal to 1, which is not limited in this application.

[0135] As Figure 8C As shown, in the user interface 830, the cross window 831 includes 8 sub-windows. Each of the four sides of the first focus frame is adjacent to a sub-window, forming four outer windows. The interior of the first focus frame includes another four sub-windows.

[0136] S5028: The electronic device maintains the first focus frame.

[0137] The electronic device can determine that the target window is not needed and maintain the first focus frame.

[0138] Among them, the first threshold > the second threshold > the third threshold.

[0139] When the focus ratio is less than or equal to (less than) the third threshold, the electronic device can keep the first focus frame unchanged.

[0140] The above Figure 6 In the above embodiments, the larger the area of the focus frame, the more likely the subject to be focused is inside the focus frame. Therefore, the electronic device can further refine the determination of the focus position by dividing the first type of window into multiple sub-windows. When the area of the focus frame is medium, it is impossible to determine whether the subject to be focused is inside or outside the focus frame, and the second type of window is used to further determine the accuracy and range of focusing. When the area of the focus frame is very small, etc., the subject to be focused is more likely to be outside the focus frame, and the third type of window form is used to further determine the situation outside the focus frame and further determine the accuracy and range of focusing. In this way, for different sizes of focus frames, the possible deviation of the corresponding out-of-focus subject can be considered, and the subject to be focused can be accurately found as much as possible by selecting the corresponding window form to ensure the accuracy of focusing.

[0141] S503: The electronic device calculates the focus positions of all sub-windows in the target window and the first focus frame.

[0142] Among them, the focus position is the code value corresponding to the focus motor when the above corresponding area (sub-window or first focus frame) is in focus. The first focus frame corresponds to codeA, and the target window includes S sub-windows. The codes corresponding to each sub-window are: code1, code2, code3,..., codeS in sequence. S is an integer greater than 1. The electronic device can calculate the above codeA, code1, code2, code3,..., codeS respectively through the autofocus method.

[0143] Exemplarily, asFigure 8A As shown, the electronic device can calculate that the first diagonal frame corresponds to codeA, the upper left sub-window corresponds to code1, the upper right sub-window corresponds to code2, the lower left sub-window corresponds to code3, and the lower right sub-window corresponds to code4.

[0144] Among them, when the electronic device calculates the accurate focusing position of the focusing frame or the window, it can be calculated by means of laser focusing, that is, obtaining the corresponding object distance and determining the corresponding code based on the mapping relationship between the object distance and the code. It can also be calculated by means of phase focusing, etc. The specific calculation method of the accurate focusing position in this application is not limited.

[0145] It should be noted that the code value is positively correlated with the image distance in the focusing process. However, the larger the code value (the larger the image distance), the smaller the corresponding object distance, and the closer the shooting subject is to the camera.

[0146] S504: The electronic device determines the target accurate focusing position based on the target window and the first focusing frame.

[0147] Among them, the second focusing frame is the focusing frame determined for the motor pushing target in S505.

[0148] Figure 9 is a schematic flowchart of a method for selecting a second focusing frame publicly disclosed in an exemplary embodiment of this application. As Figure 9 shown, the method for selecting the second focusing frame may include but is not limited to the following steps:

[0149] S5041: The electronic device calculates the confidence levels of all sub-windows and the first focusing frame in the target window, and filters them according to the confidence levels to obtain a set of preselected frames.

[0150] The electronic device can obtain the confidence levels of all sub-windows and the first focusing frame in each target window. Determine whether each confidence level is greater than the first confidence level threshold. When the confidence level of the corresponding sub-window or the first focusing frame is greater than (greater than or equal to) the first confidence level threshold, the sub-window or the focusing frame corresponding to the confidence level is retained; when the confidence level is less than or equal to (less than) the first confidence level threshold, the sub-window or the focusing frame corresponding to the confidence level is excluded. The confidence levels are the confidence levels corresponding to all sub-windows and the first focusing frame in the target window in turn. After the above comparisons are completed in turn, the retained windows or focusing frames are determined as the set of preselected frames. Among them, the preselected frame is a sub-window and / or the first focusing frame in the target window, and the focusing confidence levels of all preselected frames in the set of preselected frames are greater than or equal to (greater than) the first confidence level threshold.

[0151] In the above process, the electronic device screens the focus frames and window matching with poor focus reliability through confidence levels, ensuring the reliability and accuracy of data when using the codes of the preselected frame set later, excluding data with large deviations, ensuring accurate focus, and achieving better focus effects.

[0152] S5042: The electronic device sorts the focus positions of the preselected frame set to obtain the first sequence information.

[0153] The electronic device can sort the focus positions of all window matching and focus frames in the preselected frame set. For example, it can be sorted in ascending order of the code (the shooting object distance is from far to near), or it can be sorted in descending order of the code (the shooting object distance is from near to far). The focus frames or window matching in the preselected frame set can be sorted in sequence according to the order of the code values to obtain the first sequence information.

[0154] S5043: The electronic device determines whether the first focus frame is for portrait focus. In the case of portrait focus, S5044 is executed; in the case of non-portrait focus, S5045 is executed.

[0155] During the execution of S501, the electronic device can extract semantic information, determine whether the current shooting subject (the focus subject of the first focus frame) is a person, and can judge whether the first focus frame is for portrait focus. In the case of portrait focus, S5044 is executed; in the case of non-portrait focus, S5045 is executed.

[0156] In the above embodiments, for different focus subjects, the focus methods are different. The shooting subjects are divided into portrait types and other types. Portrait type focus uses the human body frame for focus to ensure the accuracy of focus and the reliability of focus effects. For non-other type focus, it can be focused based on the principle of near view priority to ensure the accuracy and reliability of image focus.

[0157] S5044: The electronic device determines whether the difference between the focus position of the human body frame and the focus position of the face frame is greater than (greater than or equal to) the first depth of field threshold. In the case of being greater than the first depth of field threshold, S5045 is executed; in the case of being less than or equal to the first depth of field threshold, S5046 is executed.

[0158] When the electronic device is in the case of portrait focus, it can determine the focus positions (code values) of the face frame and the human body frame of the focus subject (the first person). When the difference between the two focus positions is greater than (greater than or equal to) the first depth of field threshold, the electronic device can execute S5046; when it is less than or equal to (less than) the first depth of field threshold, the electronic device can execute S5045.

[0159] The first depth of field threshold can be set to a fixed value or a variable value. When the first depth of field threshold is a variable value, the second depth of field threshold th2 is w times the current depth of field length. The range of the second depth of field threshold is 0.5 and the depth of field length to 1.5 depth of field lengths. For example, the second depth of field threshold is a depth of field length, for example, 30 codes, and the above example is not limited. The electronic device can obtain the current depth of field length during the focusing process and calculate the first depth of field threshold.

[0160] Figure 11 FIG. 1 is a schematic diagram of a face frame and a body frame exemplarily shown in an embodiment of the present application. Figure 11 As shown, during the process of the electronic device focusing on the first person, the user interface 1110 may display a focus frame 1111, and the electronic device may determine the face of the first person and determine a face frame 1113, as well as the body of the first person and determine a body frame 1112. During the specific shooting process, the electronic device may not display the face frame and the body frame, but only display the focus frame.

[0161] Among them, the method for determining the quasi-focus position of the human body frame and the face frame can refer to phase focusing and laser focusing, etc., which will not be described in detail.

[0162] S5045: The electronic device determines the target focal position based on the near view priority principle.

[0163] The electronic device can give priority to focusing on the window with a closer shooting distance.

[0164] Figure 10 FIG. 1 is a flow chart of a method for determining a second focus frame exemplarily proposed in an embodiment of the present application. Figure 10 As shown, the specific description of S5045 may include at least the contents of S1001 to S1005, which are described in detail below:

[0165] S1001: The electronic device obtains the maximum and minimum values of the in-focus position in the pre-selected frame set, and determines whether the difference between the maximum and minimum values is greater than a second depth of field threshold. If it is greater than (greater than or equal to) the second depth of field threshold, S1003 is executed. If it is less than or equal to (less than) the second depth of field threshold, S1002 is executed.

[0166] Among them, the second depth-of-field threshold can be a fixed value or a variable value. The second depth-of-field threshold can be equal to the first depth-of-field threshold. When the second depth-of-field threshold is a variable value, the second depth-of-field threshold th2 is m times the current depth-of-field length. The range of the second depth-of-field threshold is from 0.5 times the depth-of-field length to 1.5 times the depth-of-field length. For example, the second depth-of-field threshold is one depth-of-field length, for example, 30 codes. The above examples are illustrative and not restrictive. Among them, the first depth-of-field threshold can be equal to the second depth-of-field threshold, or the first depth-of-field threshold can be not equal to the second depth-of-field threshold.

[0167] The electronic device can determine that if code(max) - code(min) > (≥) th2, execute S1003. If code(max) - code(min) ≤ (<) th2, execute S1002.

[0168] S1002: The electronic device determines whether the focusing with the first focusing frame is reliable. In the case of reliability, execute S1005; in the case of unreliability, execute S1004.

[0169] The electronic device determines that the confidence level during the focusing process of the first focusing frame is greater than (greater than or equal to) the second confidence threshold; in the case where the confidence level during the focusing process of the first focusing frame is greater than (greater than or equal to) the second confidence threshold, execute S1005; in the case where the confidence level (detection data) during the focusing process of the first focusing frame is less than or equal to (less than) the second confidence threshold, execute S1004.

[0170] Among them, the second confidence threshold is greater than or equal to the first confidence threshold.

[0171] S1003: The electronic device determines the focusing position of the preselection frame with the closest object distance in the preselection frame set as the target focusing position.

[0172] The electronic device can determine that the object distance corresponding to the largest code in the preselection frame set is the closest, that is, the largest code is the target code (target focusing position). In this way, when the difference between the focusing positions of the focusing frame and all matching windows is large, the closest shooting subject can be selected for focusing, meeting the goal of giving priority to shooting close-ups. Such a shooting process also meets the actual shooting needs and ensures the accuracy of the focused subject during shooting.

[0173] S1004: The electronic device determines the average value of all focusing positions in the preselection frame set as the target focusing position.

[0174] In the case of being less than or equal to (less than) the second depth-of-field threshold and when the focusing with the first focusing frame is unreliable, the average value of all codes corresponding to all preselection frames in the preselection frame set is used for focusing to ensure the reliability of the focusing position.

[0175] S1005: The electronic device determines the target in-focus position as the in-focus position corresponding to the first focus frame.

[0176] When it is less than or equal to (less than) the second depth-of-field threshold and the first focus frame is in-focus reliable, directly use the in-focus position corresponding to the first focus frame for focusing. While ensuring the reliability of the focusing position, it simplifies the method for determining the target code and improves the processing efficiency.

[0177] S5046: The electronic device determines the in-focus position of the human body frame as the target in-focus position.

[0178] When the electronic device determines that the difference between the in-focus positions of the human body frame and the face frame is greater than (greater than or equal to) the first depth-of-field threshold, the electronic device can focus based on the human body frame. At this time, the human body frame is farther from the camera and the face frame is closer. When both the human body frame and the face frame are in the captured image, the user tends to take a full-body photo. The position of the human body frame can ensure the clarity of the overall image, and the proportion of the human body in the human body frame is very large, so the focusing is more accurate. It can be decided to use the human body frame for focusing to ensure better focusing effect.

[0179] S505: The electronic device drives the focus motor to the target in-focus position.

[0180] In S504, after the electronic device determines the target code, it can drive the focus motor to the target code. Among them, S505 can specifically refer to the relevant description of S303 and will not be elaborated here.

[0181] In the above implementation method, the electronic device can select different windowing forms based on the size of the first focus frame. After windowing, the electronic device can use different focusing methods for different types of shooting subjects. When using portrait focusing, the electronic device can give priority to using human body focusing to ensure the accuracy of focusing on people. In the case of non-portrait focusing, it can give priority to near-view focusing to ensure the priority shooting and clearing of nearby objects. For example, Figure 8A in, the electronic device will give priority to focusing on the leaves. Figure 8C in, the electronic device is more inclined to focus on the face.

[0182] In the above embodiments, depending on the context, the term "when..." can be interpreted to mean "if..." or "after..." or "in response to determining..." or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if detecting (the stated condition or event)" can be interpreted to mean "if determining..." or "in response to determining..." or "when detecting (the stated condition or event)" or "in response to detecting (the stated condition or event)".

[0183] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present application are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, digital subscriber line) or a wireless manner (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, hard disk, magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid-state drive), etc.

[0184] Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be completed by instructing relevant hardware with a computer program. The program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the above method embodiments. The foregoing storage medium includes various media that can store program codes such as ROM or random access memory RAM, magnetic disks, or optical discs.

Claims

1. A shooting method, characterized in that, The method is applied to an electronic device, and the method includes: In response to a first operation, the electronic device displays a first interface, and a preview image captured by a camera is displayed on the first interface; The electronic device focuses on a first subject in the first preview image, and the first preview image is displayed on the first interface; When the electronic device determines a target window based on a first focus frame, the electronic device determines a target focus position based on all sub-windows in the target window and the focus position of the first focus frame; the first focus frame includes the first subject; The electronic device drives a focus motor to the target focus position.

2. The method according to claim 1, wherein The method further includes: The electronic device determines a focus ratio of the first focus frame; the focus ratio is a ratio of a size of the first focus frame to a size of an image captured by the camera; The electronic device determines a target window based on the focus ratio.

3. The method according to claim 2, wherein The determining the target window based on the focus ratio includes: When the focus ratio is greater than or equal to a first threshold, determining the target window as a first type of window; when the focus ratio is less than the first threshold and greater than or equal to a second threshold, determining the target window as a second type of window; when the focus ratio is less than the second threshold and greater than or equal to a third threshold, determining the target window as a third type of window; when the focus ratio is less than the third threshold, determining that the target window is not required; Wherein, the first type of window is a window form that subdivides the inside of the first focus frame through a first sub-window; the second type of window is a window form that subdivides the inside of the first focus frame through a second sub-window and expands the outside of the first focus frame through a third sub-window; the third type of window is a window form that expands the outside of the first focus frame through a fourth sub-window.

4. The method according to claim 3, wherein The first threshold is greater than the second threshold, and the second threshold is greater than the third threshold.

5. The method according to any one of claims 1 to 4, characterized in that, The electronic device determining the target focus position based on all sub-windows in the target window and the focus position of the first focus frame includes: When the first subject is a portrait, if a difference between a focus position of a human body frame in the first preview screen and a focus position of a face frame is greater than a first depth-of-field threshold, the electronic device uses the focus position of the human body frame as the target focus position.

6. The method according to claim 5, characterized in that The electronic device determining the target focus position based on all sub-windows in the target window and the focus position of the first focus frame further includes: When the first subject is a portrait, if the difference between the focus position of the human body frame in the first preview screen and the focus position of the face frame is less than or equal to the first depth-of-field threshold, the electronic device determines the target focus position according to the principle of foreground priority.

7. The method according to claim 5 or 6, characterized in that, The electronic device determining the target focus position based on all sub-windows in the target window and the focus position of the first focus frame further includes: When the first subject is not a portrait, the electronic device determines the target focus position according to the principle of foreground priority.

8. The method according to claim 6 or 7, characterized in that, The electronic device determines the target focus position according to the principle of foreground priority, including: The electronic device obtains a set of preselection frames; the set of preselection frames includes sub-windows and the first focus frame in the target window and corresponding focus positions; When the difference between the maximum value and the minimum value of the focus positions in the set of preselection frames is greater than the second depth-of-field threshold, the focus position with the closest object distance is determined as the target focus position.

9. The method according to claim 8, wherein The electronic device determines the target focus position according to the principle of foreground priority, further including: When the difference between the maximum value and the minimum value of the focus positions in the set of preselection frames is less than or equal to the second depth-of-field threshold, if the focus with the first focus frame is reliable, the focus position of the first focus frame is used as the target focus position; if the focus with the first focus frame is not reliable, the average value of all the focus positions in the set of preselection frames is used as the target focus position.

10. The method according to claim 9, wherein When the confidence level of focusing with the first focus frame is greater than the second confidence level threshold, the focus with the first focus frame is reliable; when the confidence level of focusing with the first focus frame is less than or equal to the second confidence level threshold, the focus with the first focus frame is not reliable.

11. The method according to claim 8, characterized in that The focus confidence levels of all the preselection frames in the set of preselection frames are greater than or equal to the first confidence level threshold; the preselection frames are sub-windows and / or the first focus frame in the target window.

12. An electronic device, characterized in that, Including: One or more processors and one or more memories; the one or more processors are coupled to the one or more memories, and the one or more memories are used to store computer program code, and the computer program code includes computer instructions. When the one or more processors execute the computer instructions, the electronic device executes the method according to any one of claims 1-11.

13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1-11 is implemented.