Focusing method and electronic device
By detecting the focus frame status and using the appropriate focus frame to focus, the problem of focus jitter caused by unstable face detection is solved, the stability and accuracy of focus are improved, and the user experience is improved.
Patent Information
- Application Number
- CN202310622151.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-29
- Publication Date
- 2024-09-24
- Estimated Expiration
- 2043-05-29
AI Technical Summary
In cameras of electronic devices, unstable face detection causes the focus subject to change, causing obvious focus jitter, which affects the user experience.
By detecting the focus frame state and using the historical focus frame in a stable state to focus, the impact of unstable face detection on focus is reduced. When a face is detected and the focus frame status is stable, the historical focus frame is used to focus; when a face is detected and the focus frame status is unstable, the focus frame issued based on the face detection result is used to focus; When the focus frame status changes from unstable to stable, a new stable focus frame is updated for focusing.
It improves the stability and accuracy of focus, reduces focus jitter, and improves user experience.
Smart Images

Figure CN117714857B
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal devices, and in particular to a focusing method and electronic equipment. Background Art
[0002] Cameras are an important application in smart electronic devices such as mobile phones and tablets. Currently, cameras in electronic devices can detect faces in captured image frames and focus the image frames based on the face detection results. In this focusing method, different focus frames are used for focusing according to the two situations of detecting faces in the image frames and not detecting faces.
[0003] However, face detection is unstable in some scenarios, such as when the face in the image frame is in profile, in a dark environment, or with a dark complexion. When face detection is unstable, the focus subject may change, causing focus pull and obvious focus jitter, affecting the user experience. Summary of the invention
[0004] In order to solve the above technical problems, the present application provides a focusing method and an electronic device, which determine the focus frame used for focusing based on the focus frame status detection result, reduce the impact of unstable face detection on focusing, improve focus stability, and enhance user experience.
[0005] In a first aspect, the present application provides a focusing method, which is applied to an electronic device, and includes: performing face detection on a first image frame; if no face is detected from the first image frame, detecting a focus frame state; if the focus frame state is a stable state, focusing in the first image frame according to a first stable focus frame in the stable state, the first stable focus frame being determined according to a historical focus frame used by an image frame before the first image frame. In this way, the focus frame used for focusing is determined based on the focus frame state detection result, which reduces the impact of unstable face detection on focusing, improves focus stability, and enhances user experience.
[0006] According to the first aspect, it also includes: performing face detection on the second image frame; when a face is detected from the second image frame, detecting the focus frame state; if the focus frame state is a stable state, focusing on the second image frame according to the first stable focus frame in the stable state. In this way, when a face is detected and the focus frame state is stable, focusing is performed using the first stable focus frame obtained according to the historical focus frame data, rather than using the focus frame issued for the face detection result, which can reduce focus jitter and improve focus stability.
[0007] According to the first aspect, it also includes: performing face detection on the third image frame; in the case where a face is detected from the third image frame, detecting the focus frame state; if the focus frame state is an unstable state, focusing in the third image frame according to the first target focus frame, the first target focus frame is the focus frame issued for the face detection result of the third image frame. In this way, in the case where a face is detected and the focus frame state is unstable, focusing is performed using the focus frame issued for the face detection result, and the accurate focus frame position can be re-determined according to the face detection result, thereby improving the focus accuracy.
[0008] According to the first aspect, it also includes: performing face detection on the fourth image frame; in the case where a face is detected from the fourth image frame, detecting the focus frame state; if the focus frame state is a stable state, focusing in the fourth image frame according to the second stable focus frame in the stable state. In this way, after the focus frame state enters a stable state again from an unstable state, a new stable focus frame, i.e., a second stable focus frame, is determined for the new stable state according to historical focus frame data, and the new stable focus frame is used to focus on multiple image frames in the new stable state, thereby improving the focus accuracy.
[0009] According to the second aspect, the second stable focus frame is the focus frame issued for the face detection result of the fourth image frame; or, the second stable focus frame is determined based on the focus frame issued for each of the N consecutive image frames according to the face detection result, and the fourth image frame is the last frame of the N consecutive image frames. In this way, a new stable focus frame, i.e., the second stable focus frame, can be determined based on the new historical focus frame data, so that the new stable focus frame can be used to focus on multiple image frames in the new stable state, thereby improving the focusing accuracy.
[0010] According to the first aspect, it also includes: performing face detection on the fifth image frame; if no face is detected from the fifth image frame, detecting the focus frame state; if the focus frame state is a stable state, focusing in the fifth image frame according to the second stable focus frame in the stable state. In this way, after the focus frame state enters a stable state, even if no face is detected in the image, the focus can be stably focused in the image frame according to the second stable focus frame in the stable state, thereby avoiding the situation where the focus point changes too much in a short period of time and causes focus jitter.
[0011] According to the first aspect, it also includes: performing face detection on the sixth image frame; if no face is detected from the sixth image frame, detecting the focus frame state; if the focus frame state is an unstable state, focusing in the sixth image frame according to the focus frame determined in a preset manner.
[0012] Exemplarily, the focus frame determined in a preset manner may be a central focus frame.
[0013] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame previous to an image frame to be focused; if the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being a center point of a first stable focus frame, and the second center point being a center point of a focus frame issued according to a face detection result of the image frame to be focused; if so, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to a face detection result of the image frame to be focused is greater than a first area; if so, determining that the focus frame state is a stable state, and setting the count value equal to 0.
[0014] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame previous to an image frame to be focused; if the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being a center point of a first stable focus frame, and the second center point being a center point of a focus frame issued according to a face detection result of the image frame to be focused; if so, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to a face detection result of the image frame to be focused is greater than a first area; if not, determining whether a count value is greater than a first value; if not, determining that the focus frame state is a stable state, and increasing the count value by 1.
[0015] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame previous to an image frame to be focused; if the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being a center point of a first stable focus frame, and the second center point being a center point of a focus frame issued according to a face detection result of the image frame to be focused; if so, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to a face detection result of the image frame to be focused is greater than a first area; if not, determining whether a count value is greater than a first value; if so, determining that the focus frame state is an unstable state.
[0016] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame previous to an image frame to be focused; if the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being a center point of a first stable focus frame, and the second center point being a center point of a focus frame issued according to a face detection result of the image frame to be focused; if not, determining whether a count value is greater than a first value; if not, determining that the focus frame state is a stable state, and increasing the count value by 1.
[0017] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame previous to an image frame to be focused; if the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being a center point of a first stable focus frame, and the second center point being a center point of a focus frame issued according to a face detection result of the image frame to be focused; if not, determining whether a count value is greater than a first value; if yes, determining that the focus frame state is an unstable state.
[0018] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame before the image frame to be focused; if the first focus frame state is an unstable state, obtaining data of N focus frames corresponding to N consecutive image frames before the image frame to be focused, N being a natural number, and N being greater than a second value; judging whether the distance between the center points of the N focus frames is less than a first length, and judging whether the overlapping area of the N focus frames is greater than the first area, based on the data of the N focus frames; if the distance between the center points of the N focus frames is less than the first length, and the overlapping area of the N focus frames is greater than the first area, determining that the focus frame state is a stable state, updating the first focus frame in the stable state to a second stable focus frame based on the N focus frames, and setting the count value equal to 0.
[0019] According to the first aspect, the focus frame state is detected, including: obtaining a first focus frame state corresponding to a target image frame, the target image frame being an image frame before an image frame to be focused; if the first focus frame state is an unstable state, obtaining data of N focus frames corresponding to N consecutive image frames before the image frame to be focused, N being a natural number, and N being greater than a second value; judging whether a distance between center points of the N focus frames is less than a first length, and judging whether an overlapping area of the N focus frames is greater than a first area, based on the data of the N focus frames; if the distance between center points of the N focus frames is greater than or equal to the first length, or an overlapping area of the N focus frames is less than or equal to the first area, determining that the focus frame state is an unstable state.
[0020] According to the first aspect, the distance between the center points of the N focus frames is equal to the maximum value of the center point distances of the focus frames corresponding to all adjacent image frames in the N image frames; or, the distance between the center points of the N focus frames is equal to the average value of the center point distances of the focus frames corresponding to all adjacent image frames in the N image frames.
[0021] According to the first aspect, the overlapping area of N focus frames is equal to the maximum value of the overlapping areas of focus frames corresponding to all adjacent image frames in the N image frames; or, the overlapping area of N focus frames is equal to the average value of the overlapping areas of focus frames corresponding to all adjacent image frames in the N image frames.
[0022] According to the first aspect, updating a first focus frame in a stable state to a second stable focus frame according to N focus frames includes: determining the focus frame that appears earliest among the N focus frames as the second stable focus frame in the stable state; or, determining the focus frame that appears latest among the N focus frames as the second stable focus frame in the stable state; or, connecting the N focus frames into a first figure with center points as vertices, and determining a focus frame whose center point coincides with the center point of the first figure as the second stable focus frame in the stable state.
[0023] According to the first aspect, the electronic device is a mobile phone or a tablet.
[0024] In a second aspect, the present application provides a focusing method, which is applied to an electronic device, and the method includes: performing target detection on a first image frame; if the target is not detected from the first image frame, detecting the state of a focus frame; if the state of the focus frame is a stable state, focusing in the first image frame according to a first stable focus frame in the stable state. In this way, the focus frame used for focusing is determined based on the focus frame state detection result, which reduces the impact of unstable target detection on focusing, improves focus stability, and enhances user experience.
[0025] For example, the target may be a human face, a vehicle, an animal, a tree, etc.
[0026] In a third aspect, the present application provides an electronic device, comprising: a memory and a processor, wherein the memory is coupled to the processor; the memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the focusing method of any one of the first aspect or the second aspect.
[0027] In a fourth aspect, the present application provides a computer-readable storage medium, including a computer program. When the computer program is executed on an electronic device, the electronic device executes the focusing method of any one of the first aspect or the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a schematic structural diagram of an illustrative electronic device 100;
[0029] Figure 2 1 is a software structure block diagram of an electronic device 100 according to an embodiment of the present application;
[0030] Figure 3 This is an example diagram of a scene in which face detection is unstable;
[0031] Figure 4 is a flowchart of a focusing method according to the present embodiment;
[0032] Figure 5 For example, the use Figure 4 The focusing method shown is Figure 3 (a) is a schematic diagram of the result of focusing the image frame in the scene shown in FIG.
[0033] Figure 6 FIG. 2 is another flowchart of the focusing method in this embodiment;
[0034] Figure 7 is a schematic diagram showing an exemplary focus frame overlap area and a focus frame center point distance;
[0035] Figure 8 is an exemplary diagram of a process for detecting a focus frame state;
[0036] Fig. 9 FIG. 4 is another flowchart illustrating the focusing method in this embodiment. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0038] The term "and / or" in this article is merely a description of the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.
[0039] The terms "first" and "second" in the description and claims of the embodiments of the present application are used to distinguish different objects rather than to describe a specific order of objects. For example, a first target object and a second target object are used to distinguish different target objects rather than to describe a specific order of target objects.
[0040] This embodiment provides a focusing method, which can be applied to electronic devices with camera functions such as mobile phones and tablets.
[0041] In this embodiment, the structure of the electronic device can be as follows Figure 1 shown.
[0042] Figure 1 FIG. 1 is a schematic diagram of the structure of an electronic device 100 exemplarily shown. It should be understood that Figure 1The illustrated electronic device 100 is merely one example of an electronic device, and the electronic device 100 may have more or fewer components than those shown in the figure, may combine two or more components, or may have a different configuration of components. Figure 1 The various components shown in the EMBODIMENTS 2000 may be implemented in hardware, software, or a combination of hardware and software, including one or more signal processing and / or application specific integrated circuits.
[0043] See also Figure 1 The electronic device 100 may include: a processor 110, 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, an indicator 192, a camera 193, etc.
[0044] 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 memory, 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.
[0045] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.
[0046] 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.
[0047] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. 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.
[0048] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.
[0049] 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.
[0050] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the 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 passes 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 RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0051] The digital signal processor is used to process digital signals, and can process not only digital image signals but also 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.
[0052] Video codecs are used to compress or decompress digital videos. The electronic device 100 may support one or more video codecs. Thus, the electronic device 100 may play or record videos in a variety of coding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.
[0053] Figure 2 1 is a block diagram of the software structure of the electronic device 100 according to an embodiment of the present application.
[0054] The layered architecture of the electronic device 100 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 may include an application layer, an application framework layer, a system library, and a kernel layer.
[0055] The application layer can include a series of application packages.
[0056] like Figure 2 As shown, the application package may include camera, calendar, map, WLAN, music, short message, gallery, call, navigation, Bluetooth, video and other applications. Of course, these applications are only exemplary. In other embodiments, the application layer may include Figure 2 Applications not shown in the figure may also not include Figure 2 One or more applications shown in .
[0057] Among them, the camera application includes a focusing module, and the focusing module is used to execute the focusing method of the embodiment of the present application.
[0058] like Figure 2 As shown, the application framework layer may include a window manager, a resource manager, a view system, etc.
[0059] 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.
[0060] The view system includes visual controls, such as controls for displaying text, controls for displaying images, 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 notification icon can include a view for displaying text and a view for displaying images.
[0061] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.
[0062] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.
[0063] 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.
[0064] 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.
[0065] 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.
[0066] The surface manager is used to manage the display subsystem and provide the fusion of 2D and 3D layers for multiple applications.
[0067] 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.
[0068] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.
[0069] A 2D graphics engine is a drawing engine for 2D (two-dimensional) drawing.
[0070] The kernel layer is the layer between hardware and software.
[0071] like Figure 2 As shown, the kernel layer may include display driver, camera driver, audio driver, sensor driver, Bluetooth driver, etc.
[0072] Understandably, Figure 2 The layers in the software structure shown and the components included in each layer do 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 layers than shown, and each layer may include more or fewer components, which is not limited in the present application.
[0073] Figure 3 FIG. 1 is an example diagram showing a scene where face detection is unstable. Figure 3Figure (a) is a scene of a person with long hair and side face. When the face in the image frame is a person with long hair and side face, it is possible that the face is detected for a while and not detected for a while, that is, the face detection result indicates that there is no face in the image frame. Figure 3 Figure (b) is a darker face scene. When the face in the image frame is black, it is possible that the face is detected for a while and not detected for a while. In these cases, although there is actually a face in the image frame, the face detection algorithm cannot stably detect the face.
[0074] Figure 4 FIG. 1 is a flowchart of a focusing method according to an exemplary embodiment of the present invention. Figure 4 In this embodiment, the focusing method may include the following steps:
[0075] S401, determine whether a face is detected, if yes, execute step S402, otherwise execute step S403.
[0076] S402, focusing is performed according to the focus frame issued according to the face detection result, and the focusing process of the current image frame is ended.
[0077] S403, focusing is performed according to the central focusing frame, and the focusing process of the current image frame ends.
[0078] Figure 5 For example, the use Figure 4 The focusing method shown is Figure 3 Schematic diagram of the result of focusing the image frames in the scene shown in Figure (a).
[0079] exist Figure 4 In the embodiment shown, the priority of the face is the highest. When the face can be detected, the focus will be performed according to the focus frame issued according to the face detection result. Figure 5 When the face cannot be detected, the focus is performed based on the fixed center focus frame, which is shown in the focus frame 1 of FIG. Figure 5 As shown in the focus frame 2 of Figure (b).
[0080] In this way, due to the instability of face detection results, the face is detected sometimes and not detected sometimes, so the focus frame will be Figure 5 The image (a) and (b) switch frequently, with the focus sometimes being close and sometimes being far away, resulting in obvious focus jitter.
[0081] For example, Figure 5In the real-life scene shown, it is very easy to have unstable face detection results. For example, the face detection result is 11100000111, where 1 represents a face detected from the current image frame and 0 represents no face detected from the current image frame. When the detection result is 1, the focus will be on a close distance (such as Figure 5 (a) Figure 1 shows the focus frame); when the detection is 0, it will focus on the long distance (such as Figure 5 (b) Figure 2 shows the focus frame. If the focus point switches in a short time, for example, 11100000111, there will be three close-up frames, five long-distance frames, and three close-up frames, which will cause obvious focus jitter. This will greatly affect the user experience, because the user experience is not obvious for unidirectional movement, such as the focus point changes from a stable close-up to a stable long-distance, but the back-and-forth fluctuation (for example, the focus situation of close-up-long-distance in a short time) is strongly felt.
[0082] Figure 6 FIG. 2 is another example flow chart of the focusing method in this embodiment. Figure 6 In this embodiment, the focusing method may include the following steps:
[0083] S601, performing face detection on a first image frame.
[0084] S602: If no face is detected from the first image frame, detect a focus frame state.
[0085] S603: If the focus frame state is a stable state, focusing is performed in the first image frame according to a first stable focus frame in the stable state.
[0086] The first image frame may be an image frame captured by a camera.
[0087] The first stable focus frame is determined according to a historical focus frame used by an image frame before the first image frame.
[0088] The focus frame state may include a stable state and an unstable state. In this embodiment, the focus frame state of the current face can be determined based on the historical focus frame data of face detection. If the stable state considered by this embodiment is reached, a stable focus point will be maintained, thereby avoiding the occurrence of focus jitter.
[0089] In this embodiment, whether the focus frame state is a stable state is determined mainly based on two time domain performances, one is the overlap area of the focus frame, and the other is the distance of the focus frame center point, such as Figure 7 shown.
[0090] Figure 7 Schematic diagram showing the overlap area of the focus frame and the distance between the center points of the focus frame. Figure 7In Figure (a), the shaded area is the overlap area of focus frame a and focus frame b. Figure 7 In the figure (b), the center point of focus frame a is point Q1, the center point of focus frame b is point Q2, and the distance between point Q1 and point Q2 is the center point distance between focus frame a and focus frame b. The center point distance may be calculated in a manner including but not limited to Euclidean distance, Manhattan distance, and the like.
[0091] When the overlapping area is large and the center point distance is small, it is considered that the current focus frame displacement is small. By adjusting different thresholds according to different situations, the focus frame state can be considered to be stable.
[0092] In one example, you can follow Figure 8 The process shown detects the focus frame status.
[0093] Figure 8 FIG. 1 is an example of a flow chart showing the detection of the focus frame state. Figure 8 In this embodiment, the process of detecting the focus frame state may include the following steps:
[0094] S801, determining whether the focus frame state corresponding to the previous image frame d of the current image frame c is a stable state, if it is a stable state, executing step S802, otherwise executing step S808.
[0095] The current image frame is image frame c. Image frame c is the image frame to be focused.
[0096] It should be noted that, in one example, for the front N (where N is the same as N in the subsequent step S808) image frames in a group of image frames, the focus frame state of the front N image frames can be directly determined as an unstable state, and starting from the N+1th image frame, the focus frame state of the front N image frames can be directly determined as an unstable state. Figure 8 The focus frame state detection is performed in the manner of the embodiment shown. That is, when the number of stored image frames is less than N, the focus frame state is an unstable state.
[0097] S802, determining whether the distance between the center point of the focus frame issued according to the face detection result of the image frame c and the center point of the focus frame L1 in the current stable state is less than a first length, if so, executing step S803, otherwise executing step S805.
[0098] When the focus frame state corresponding to the image frame d is a stable state, the actual focus frame of the image frame d is the focus frame L1, that is, when focusing on the image frame d, the focus is performed based on the L1 frame.
[0099] S803, determining whether the overlapping area between the focus frame issued according to the face detection result of the image frame c and the focus frame L1 in the current stable state is greater than the first area, if yes, executing step S804, otherwise executing step S805.
[0100] In this embodiment, the distance of the focus frame center points is first determined (such as step S802) and then the focus frame overlap area is determined (such as step S803). It should be noted that in other embodiments, the judgment can also be performed in other orders, such as first determining the focus frame overlap area and then determining the focus frame center point distance, or determining the focus frame overlap area and the focus frame center point distance in parallel.
[0101] S804, determine that the focus frame state is a stable state, and set the count value count to 0, and end.
[0102] S805, determine whether the current count value count is greater than K, if so, execute step S812, otherwise execute step S806.
[0103] Wherein, K is a natural number. The value of K can be determined according to actual application requirements.
[0104] S806, increase the current count value count by 1.
[0105] S807, determine that the focus frame state is a stable state, and end.
[0106] S808, obtaining data of N focus frames corresponding to N consecutive image frames before the image frame c.
[0107] Wherein, N is a natural number, and N is greater than the second value.
[0108] The data of the N focus frames may include the center point position of each of the N focus frames and the position of the entire focus frame, or include the center point position of each of the N focus frames and the size of the focus frame (in this way, the position of the focus frame can be determined based on the center point position of the focus frame and the size of the focus frame).
[0109] In practical applications, the value of N can be adjusted according to the usage effect.
[0110] S809, judging whether the distance between the center points of the N focus frames is less than the first length according to the data of the N focus frames, if so, executing step S810, otherwise executing step S812.
[0111] In an example, the distance between the center points of the N focus frames may be equal to the maximum value of the center point distances of the focus frames corresponding to all adjacent image frames in the N image frames.
[0112] In another example, the distance between the center points of the N focus frames may be equal to the average value of the distances between the center points of the focus frames corresponding to all adjacent image frames in the N image frames.
[0113] Of course, the distances between the center points of the N focus frames may also be obtained in other ways, which will not be listed one by one in this embodiment.
[0114] S810, judging whether the overlapping area of the N focusing frames is greater than the first area according to the data of the N focusing frames, if so, executing step S811, otherwise executing step S812.
[0115] In an example, the overlapping area of the N focus frames may be equal to the maximum value of the overlapping areas of the focus frames corresponding to all adjacent image frames in the N image frames.
[0116] In another example, the overlapping area of the N focus frames may be equal to the average value of the overlapping areas of the focus frames corresponding to all adjacent image frames in the N image frames.
[0117] Of course, the overlapping area of the N focus frames may also be obtained in other ways, which will not be listed one by one in this embodiment.
[0118] S811, determine that the focus frame state is a stable state, update the focus frame in the stable state from the L1 frame to the L2 frame according to the N focus frames, and set the count value count to 0, and end.
[0119] S812, determine that the focus frame state is an unstable state, and end.
[0120] According to Figure 8 The focus frame status detection process shown in Figure 5 In the scene shown, in the continuous K frames, no matter what the face detection result is, Figure 8 The focus will be adjusted based on the stable face focus frame to ensure that the focus point is always in a stable state.
[0121] Among them, K can be adjusted according to the actual effect.
[0122] In this embodiment, the L frame represents the focus frame in a stable state. The above-mentioned L1 frame and L2 frame respectively represent the focus frames in the stable state at different stages. For example, time periods T1, T2, and T3 are three time periods sequentially connected in time. Assume that the focus frame state of the image frame in the time period T1 is a stable state; the focus frame state of the image frame in the time period T2 is an unstable state; and the focus frame state of the image frame in the time period T3 is a stable state. The focus frame used by the image frame in the time period T1 is the focus frame L1 frame in the stable state, and the focus frame used by the image frame in the time period T3 is the focus frame L2 frame in the stable state.
[0123] Fig. 9 FIG. 2 is another example flow chart of the focusing method in this embodiment. Fig. 9 In this embodiment, the focusing method may include the following steps:
[0124] S901, after performing face detection on the current image frame, determine whether a face is detected in the current image frame, if yes, execute step S902, otherwise execute step S904.
[0125] S902, determining whether the focus frame state is a stable state, if so, executing step S905, otherwise executing step S903.
[0126] The focus frame state in this step refers to the focus frame state corresponding to the current image frame.
[0127] In this embodiment, according to Figure 8 The process shown determines whether the focus frame state is a stable state.
[0128] S903, focusing in the current image frame according to the focus frame determined in a preset manner.
[0129] S904, determining whether the focus frame state is a stable state, if so, executing step S905, otherwise executing step S906.
[0130] The focus frame state in this step refers to the focus frame state corresponding to the current image frame.
[0131] In this embodiment, according to Figure 8 The process shown determines whether the focus frame state is a stable state.
[0132] S905, focusing in the current image frame according to the focus frame in the stable state, and ending.
[0133] S906, focusing in the current image frame according to the focus frame issued by the face detection result of the current image frame, and ending.
[0134] The focusing method of this embodiment is further described in detail below by using examples.
[0135] In this example, assuming that K=5, N=10, faces are stably detected in the first 10 image frames P1-P10, and the default initial focus frame state is an unstable state, then the focus frame states of image frames P1-P10 are all unstable states, and the focus frame sent for the image frame is used for focusing.
[0136] For the image frame P11, since the distance between the center points of the 10 focus frames A1-A10 corresponding to the 10 consecutive (N=10) image frames before the image frame P11 is less than the first length, and the overlapping area of the focus frames A1-A10 is greater than the first area, according to Figure 8 In the process shown, it is determined that the focus frame corresponding to the image frame P11 is in a stable state, and the focus frame A11 issued for the image frame P11 is determined to be the first focus frame in the stable state, and the count value count is set to 0, and the focus frame A11 is used to focus on the image frame P11.
[0137] When performing face detection on the image frame P12, due to unstable face detection, such as side faces or dark faces, no face is detected in the image frame P12. Figure 8 In the process shown, the distance between the center point of the focus frame A12 sent by the image frame P12 and the focus frame A11 is greater than the first length, but the value of count is 0, which is less than 5 (K=5), so it is determined that the focus frame corresponding to the image frame P12 is in a stable state, and count is set to 1. At this time, the focus frame A11 (i.e., the first focus frame in the stable state) is used to focus on the image frame P12.
[0138] When face detection is performed on the image frame P13, no face is detected in the image frame P13 due to instability of face detection. Figure 8 In the process shown, the distance between the center point of the focus frame A13 sent by the image frame P13 and the center point of the focus frame A11 is greater than the first length, but the value of count is 1, which is less than 5 (K=5), so it is determined that the focus frame corresponding to the image frame P13 is in a stable state, and count is equal to 2. At this time, the focus frame A11 (i.e., the first focus frame in the stable state) is used to focus on the image frame P13.
[0139] When face detection is performed on the image frame P14, a face is detected in the image frame P14. Figure 8 In the process shown, the distance between the center point of the focus frame A14 and the focus frame A11 issued by the image frame P14 is less than the first length, and the overlap area of the two is greater than the first area, and it is determined that the focus frame corresponding to the image frame P14 is in a stable state. At this time, the focus frame A11 (i.e., the first focus frame in the stable state) is used to focus on the image frame P14. And the value of count is reset to 0.
[0140] Next, when face detection is performed on image frames P15-P20, faces are detected in image frames P15-P20. Assume that the center point distances between focus frames A15-A20 and focus frame A11 issued based on the face detection results of image frames P15-P20 are greater than the first length. However, since count is less than or equal to 5 (the values of count after the focus frame detection process of image frames P15-P19 are 1, 2, 3, 4, and 5, respectively), the focus frames of image frames P15-P20 are all in a stable state. After the focus frame state detection process of image frame P20, count is equal to 6. For image frames P15-P20, focus frame A11 is used for focusing.
[0141] When face detection is performed on image frame P21, a face is detected in image frame P21. If the center point distances of focus frame A21 and focus frame A11 issued based on the face detection result of image frame P21 are both greater than the first length, then, since the value of count is 6, which is greater than 5, it is determined that the focus frame state of image frame P21 is an unstable state, and for image frame P21, focus frame A21 is used for focusing.
[0142] When face detection is performed on the image frame P22, a face is detected in the image frame P22. Figure 8 The process shown in FIG. 1 determines whether the center point distance of the focus frames of the 10 consecutive image frames P12-P21 before the image frame P22 is less than the first length, and whether the overlapping area is greater than the first area. If at least one of the judgment results is no, then it is determined that the focus frame state of the image frame P22 is an unstable state. For the image frame P22, the focus frame A22 issued based on the face detection result of the image frame P22 is used for focusing.
[0143] When face detection is performed on the image frame P23, a face is detected in the image frame P23. Figure 8 The process shown in FIG. 1 determines whether the center point distance of the focus frames of the 10 consecutive image frames P13-P22 before the image frame P23 is less than the first length, and whether the overlapping area is greater than the first area. If at least one of the judgment results is no, then it is determined that the focus frame state of the image frame P23 is an unstable state. For the image frame P23, the focus frame A23 issued based on the face detection result of the image frame P23 is used for focusing.
[0144] In this way, assuming that faces are detected in image frames P24-P31, and the focus frame states of image frames P24-P31 are all unstable, the actual focus frames of image frames P24-P31 are focus frames A24-A31 issued based on the face detection results.
[0145] When face detection is performed on the image frame P32, a face is detected in the image frame P32. Figure 8 According to the process shown, it is determined that the center point distances of the focus frames of the 10 consecutive image frames P22-P31 before the image frame P32 are all less than the first length, and the overlapping areas are all greater than the first area, then it is determined that the focus frame state of the image frame P32 is a stable state, and for the image frame P32, the focus frame A32 issued based on the face detection result of the image frame P32 is used for focusing, and the focus frame A32 is set as the second focus frame in the stable state.
[0146] When face detection is performed on the image frame P33, a face is detected in the image frame P33. Figure 8 In the process shown, the distance between the center point of the focus frame A33 and the focus frame A32 issued by the image frame P33 is less than the first length, and the overlap area of the two is greater than the first area, and it is determined that the focus frame corresponding to the image frame P33 is in a stable state. At this time, the focus frame A32 (i.e., the second focus frame in the stable state) is used to focus on the image frame P33. And the value of count is reset to 0.
[0147] As can be seen from the above, the focusing method provided by this embodiment determines the focus frame state of the current image frame to be focused based on the historical focus frame data. If the focus frame state is a stable state, the focus is performed in the current image frame according to the existing focus frame in the stable state. In this way, when face detection is occasionally unstable and there are a few image frames in which no faces are detected, the focus will still be performed according to the existing focus frame in the stable state, so that the focus remains stable and the focus is avoided from switching frequently between close and long distances. Therefore, the focusing method provided by this embodiment reduces the impact of unstable face detection on focusing, improves focus stability, and thus can enhance user experience.
[0148] The focusing method provided in this embodiment can also be applied to tracking scenes.
[0149] It should be noted that, although the above embodiment is described by taking face detection as an example, it should be understood that the focusing method provided in this embodiment can also be applied to other target detection scenarios and is not limited to faces.
[0150] An embodiment of the present application also provides an electronic device, which includes a memory and a processor, wherein the memory is coupled to the processor, and the memory stores program instructions. When the program instructions are executed by the processor, the electronic device implements the focusing method executed by the aforementioned electronic device.
[0151] It is understandable that, in order to realize the above functions, the electronic device includes hardware and / or software modules corresponding to the execution of each function. In combination with the algorithm steps of each example described in the embodiments disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application in combination with the embodiments, but such implementation should not be considered to be beyond the scope of the present application.
[0152] This embodiment further provides a computer storage medium, in which computer instructions are stored. When the computer instructions are executed on an electronic device, the electronic device executes the above-mentioned related method steps to implement the focusing method in the above-mentioned embodiment.
[0153] This embodiment further provides a computer program product. When the computer program product is run on a computer, the computer is enabled to execute the above-mentioned related steps to implement the focusing method in the above-mentioned embodiment.
[0154] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and a memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory so that the chip executes the focusing method in the above-mentioned method embodiments.
[0155] Among them, the electronic device, computer storage medium, computer program product or chip provided in this embodiment is used to execute the corresponding method provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding method provided above and will not be repeated here.
[0156] Through the description of the above implementation methods, technical personnel in the relevant field can understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0157] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of modules or units is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0158] The units described as separate components may or may not be physically separated, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple different places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0159] In addition, each functional unit in each embodiment of the present application 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. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0160] Any content of each embodiment of the present application, as well as any content of the same embodiment, can be freely combined. Any combination of the above content is within the scope of the present application.
[0161] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read only memory (ROM), random access memory (RAM), disk or optical disk and other media that can store program code.
[0162] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
[0163] The steps of the method or algorithm described in conjunction with the disclosure of the embodiments of the present application can be implemented in a hardware manner, or can be implemented by a processor executing a software instruction. The software instruction can be composed of corresponding software modules, and the software module can be stored in a random access memory (Random Access Memory, RAM), a flash memory, a read-only memory (Read Only Memory, ROM), an erasable programmable read-only memory (Erasable Programmable ROM, EPROM), an electrically erasable programmable read-only memory (Electrically EPROM, EEPROM), a register, a hard disk, a mobile hard disk, a read-only compact disk (CD-ROM) or any other form of storage medium known in the art. An exemplary storage medium is coupled to a processor so that the processor can read information from the storage medium and can write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC.
[0164] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented with hardware, software, firmware, or any combination thereof. When implemented using software, these functions can be stored in a computer-readable medium or transmitted as one or more instructions or codes on a computer-readable medium. Computer-readable media include computer storage media and communication media, wherein the communication media include any media that facilitates the transmission of a computer program from one place to another. The storage medium can be any available medium that a general or special-purpose computer can access.
[0165] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of the present application, ordinary technicians in this field can also make many forms without departing from the purpose of the present application and the scope of protection of the claims, all of which are within the protection of the present application.
Claims
1. A focusing method, characterized in that: Applied to electronic equipment, the method comprises: Performing face detection on the first image frame; In the case where no human face is detected from the first image frame, detecting a focus frame state; If the focus frame state is a stable state, focusing in the first image frame according to a first stable focus frame in the stable state, wherein the first stable focus frame is determined according to a historical focus frame used by an image frame before the first image frame; The detecting of the focus frame state includes: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If yes, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to the face detection result of the image frame to be focused is greater than a first area; If so, determine that the focus frame state is a stable state, and set the count value equal to 0.
2. The method according to claim 1, characterized in that: Also includes: Performing face detection on the second image frame; In case a human face is detected from the second image frame, detecting a focus frame state; If the focus frame state is a stable state, focusing is performed in the second image frame according to the first stable focus frame in the stable state.
3. The method according to claim 1, characterized in that Also includes: Performing face detection on the third image frame; In case a human face is detected from the third image frame, detecting a focus frame state; If the focus frame state is an unstable state, focusing is performed in the third image frame according to a first target focus frame, where the first target focus frame is a focus frame issued according to a face detection result of the third image frame.
4. The method according to claim 3, characterized in that Also includes: Performing face detection on the fourth image frame; In case a human face is detected from the fourth image frame, detecting a focus frame state; If the focus frame state is a stable state, focusing is performed in the fourth image frame according to a second stable focus frame in the stable state.
5. The method according to claim 4, characterized in that The second stable focus frame is the focus frame issued for the face detection result of the fourth image frame; or, the second stable focus frame is determined based on the focus frame issued for the face detection result of each image frame in N consecutive image frames, and the fourth image frame is the last frame in the N consecutive image frames.
6. The method according to claim 4, characterized in that Also includes: Performing face detection on the fifth image frame; In the case where no human face is detected from the fifth image frame, detecting a focus frame state; If the focus frame state is a stable state, focusing is performed in the fifth image frame according to the second stable focus frame in the stable state.
7. The method according to claim 1, characterized in that Also includes: Performing face detection on the sixth image frame; In the case where no human face is detected from the sixth image frame, detecting a focus frame state; If the focus frame state is an unstable state, focusing is performed in the sixth image frame according to the focus frame determined in a preset manner.
8. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If yes, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to the face detection result of the image frame to be focused is greater than a first area; If not, determine whether the count value is greater than the first value; If not, it is determined that the focus frame state is a stable state, and the count value is increased by 1.
9. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If yes, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to the face detection result of the image frame to be focused is greater than a first area; If not, determine whether the count value is greater than the first value; If so, it is determined that the focus frame state is an unstable state.
10. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If not, determine whether the count value is greater than the first value; If not, it is determined that the focus frame state is a stable state, and the count value is increased by 1.
11. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If not, determine whether the count value is greater than the first value; If so, it is determined that the focus frame state is an unstable state.
12. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is an unstable state, obtaining data of N focus frames corresponding to N consecutive image frames before the image frame to be focused, where N is a natural number and N is greater than a second value; According to the data of the N focus frames, determining whether the distance between the center points of the N focus frames is less than a first length, and determining whether the overlapping area of the N focus frames is greater than a first area; If the distance between the center points of the N focus frames is less than the first length, and the overlapping area of the N focus frames is greater than the first area, it is determined that the focus frame state is a stable state, and the first focus frame in the stable state is updated to a second stable focus frame according to the N focus frames, and the count value is set equal to 0.
13. The method according to any one of claims 1 to 7, characterized in that: Detect the focus frame status, including: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is an unstable state, obtaining data of N focus frames corresponding to N consecutive image frames before the image frame to be focused, where N is a natural number and N is greater than a second value; According to the data of the N focus frames, determining whether the distance between the center points of the N focus frames is less than a first length, and determining whether the overlapping area of the N focus frames is greater than a first area; If the distance between the center points of the N focus frames is greater than or equal to the first length, or the overlapping area of the N focus frames is less than or equal to the first area, it is determined that the focus frame state is an unstable state.
14. The method according to claim 12, characterized in that The distance between the center points of the N focus frames is equal to the maximum value of the center point distances of the focus frames corresponding to all adjacent image frames in the N image frames; or, the distance between the center points of the N focus frames is equal to the average value of the center point distances of the focus frames corresponding to all adjacent image frames in the N image frames.
15. The method according to claim 12, characterized in that The overlapping area of the N focus frames is equal to the maximum value of the overlapping areas of the focus frames corresponding to all adjacent image frames in the N image frames; or, the overlapping area of the N focus frames is equal to the average value of the overlapping areas of the focus frames corresponding to all adjacent image frames in the N image frames.
16. The method according to claim 12, characterized in that Updating the first focus frame in a stable state to a second stable focus frame according to the N focus frames includes: Determine the focus frame that appears earliest among the N focus frames as the second stable focus frame in the stable state; Alternatively, determining the focus frame that appears the latest among the N focus frames as the second stable focus frame in the stable state; Alternatively, a first figure is formed by connecting the center points of the N focus frames as vertices, and a focus frame whose center point coincides with the center point of the first figure is determined as a second stable focus frame in a stable state.
17. The method according to claim 1, characterized in that The electronic device is a mobile phone or a tablet.
18. A focusing method, characterized in that: Applied to electronic equipment, the method comprises: Performing target detection on the first image frame; In the case where no target is detected from the first image frame, detecting a focus frame state; If the focus frame state is a stable state, focusing in the first image frame according to a first stable focus frame in the stable state; The detecting of the focus frame state includes: Acquire a first focus frame state corresponding to a target image frame, wherein the target image frame is an image frame preceding the image frame to be focused; If the first focus frame state is a stable state, determining whether a distance difference between a first center point and a second center point is less than a first length, the first center point being the center point of the first stable focus frame, and the second center point being the center point of the focus frame issued according to the face detection result of the image frame to be focused; If yes, determining whether an overlapping area between the first stable focus frame and the focus frame issued according to the face detection result of the image frame to be focused is greater than a first area; If so, determine that the focus frame state is a stable state, and set the count value equal to 0.
19. An electronic device, characterized in that: include: a memory and a processor, the memory being coupled to the processor; The memory stores program instructions, and when the program instructions are executed by the processor, the electronic device executes the focusing method as described in any one of claims 1 to 18.
20. A computer-readable storage medium comprising a computer program, characterized in that: When the computer program is executed on an electronic device, the electronic device executes the focusing method according to any one of claims 1 to 18.
