Face focusing method and device, electronic equipment and storage medium

By detecting and judging the environment type of the shooting scene, and using the face brightness difference to determine the focus area, it solves the problem of long focusing time in low brightness and backlight environments, and achieves fast and accurate focusing effects.

CN118748752APending Publication Date: 2024-10-08SHANGHAI WINGTECH INFORMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410792922.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-19
Publication Date
2024-10-08

AI Technical Summary

Technical Problem

In low-brightness and backlight environments, when photographing faces, the contrast focusing method results in long focusing times and common out-of-focus and virtual focus phenomena. It is difficult for existing technology to effectively solve this problem.

Method used

By detecting whether there is a face in the shooting scene and determining whether it is a dark environment or a backlit environment, the target face area is determined based on the difference between the background brightness of the face area and the face brightness, and is determined based on the ratio of the face area to the entire viewing area. Focus on the position of the focus point to achieve focus quickly.

Benefits of technology

In dark environments and backlight environments, the specific attributes of the human face are used to quickly determine the focus point position, avoiding the long focusing time and out-of-focus problems caused by the contrast focusing method, and achieving fast and accurate focusing effects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118748752A_ABST
    Figure CN118748752A_ABST
Patent Text Reader

Abstract

The invention relates to a face focusing method and device, electronic equipment and a storage medium. The method comprises the steps of detecting whether a face exists in a current shooting scene; if the face exists in the current shooting scene, detecting whether the current shooting scene is a dark environment or not, or detecting whether the current shooting scene is a backlight environment or not; if the current shooting scene is a dark environment or the current shooting scene is a backlight environment, determining a target face area based on a difference value between background brightness in a preset face area and face brightness; and determining the position of a focusing point according to the ratio of the target face area to the whole view finding area. The method effectively solves the problems of easy defocusing and false focusing in extreme face scenes such as a dark environment and a backlight environment.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of electronic equipment, and in particular to a face focusing method, device, electronic equipment and storage medium. Background Art

[0002] Camera is a very popular application in current smart terminals, and many application scenarios are derived from Camera. People often use Camera to take pictures of people. However, there are many extreme scenarios in face photography, which leads to unsatisfactory focusing effect and easy defocus and out-of-focus phenomenon. For example, when shooting faces under low brightness and backlight conditions, due to low brightness, flat faces and few details, the statistical autofocus data is unreliable, and out-of-focus and defocus phenomena will occur in such an environment.

[0003] In the related art, for the problem of face focusing in low-brightness and backlit environments, the region of interest frame selected for focus is usually enlarged to extend it to the clothes. Since the clothes and the face are on the same plane, as long as the details of the clothes are sufficient, the statistical autofocus information is relatively reliable. However, the reliability of this method depends on the number of details of the clothes. If the person being photographed is wearing pure white or pure black clothes, the effect of this solution will be greatly reduced. In addition, since the focusing effect of the phase focusing method is worse than that of the contrast focusing method in a low-brightness environment, the contrast focusing method is usually used in a low-brightness environment. However, the focusing process of the contrast focusing method is similar to a "hill climbing algorithm", that is, the motor searches from near focus to far focus, calculates all the differences in the process, obtains the largest difference, and then returns the motor to the place with the largest difference, which is the focus point. Its focusing time is longer and the focus stretching amplitude is larger.

[0004] Therefore, how to avoid using the contrast focusing method in extreme shooting scenes such as dark environments and backlit environments, which results in a long focusing time, is a problem that needs to be solved urgently. Summary of the invention

[0005] In order to solve the above technical problems or at least partially solve the above technical problems, the present application provides a face focusing method, device, electronic device and storage medium.

[0006] In a first aspect, the present application provides a face focusing method, the method comprising:

[0007] Detect whether there is a face in the current shooting scene;

[0008] If there is a human face in the current shooting scene, detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment;

[0009] If the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, determining the target face area based on the difference between the background brightness and the face brightness in the preset face area;

[0010] The focus point position is determined according to the ratio of the target face area to the entire framing area.

[0011] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment includes:

[0012] Determine whether the current environment brightness is less than the threshold brightness;

[0013] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0014] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a backlight environment includes:

[0015] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness;

[0016] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0017] As an optional implementation of the embodiment of the present invention, the determining of the target face area based on the difference between the background brightness and the face brightness in the preset face area includes:

[0018] Determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area;

[0019] In the preset face area, for each pixel point, determining whether the brightness difference between the background brightness and the face brightness is greater than a first preset brightness;

[0020] If the brightness difference between the background brightness of the target pixel and the brightness of the face is greater than the first preset brightness, the target pixel is determined to be a face pixel;

[0021] A target face area is determined according to a plurality of continuous face pixels.

[0022] As an optional implementation of the embodiment of the present invention, determining a preset face area based on the left eye position, the right eye position and the center point position of the mouth includes:

[0023] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0024] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0025] As an optional implementation manner of the embodiment of the present invention, determining the focus point position according to the ratio of the target face area to the entire framing area includes:

[0026] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0027] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0028] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment, or the detecting whether the current shooting scene is a backlit environment, further includes:

[0029] If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0030] In a second aspect, the present application provides a face focusing device, comprising:

[0031] A detection module, used to detect whether there is a face in the current shooting scene;

[0032] A judgment module, used for detecting whether the current shooting scene is a dark environment if there is a face in the current shooting scene, or detecting whether the current shooting scene is a backlit environment;

[0033] A determination module, configured to determine a target face area based on a difference between background brightness and face brightness in a preset face area if the current shooting scene is a dark environment or a backlit environment;

[0034] The matching module is used to determine the focus point position according to the ratio of the target face area to the entire framing area.

[0035] As an optional implementation of the embodiment of the present invention, the judgment module is specifically used to:

[0036] Determine whether the current environment brightness is less than the threshold brightness;

[0037] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0038] As an optional implementation of the embodiment of the present invention, the judgment module is further specifically used for:

[0039] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness;

[0040] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0041] As an optional implementation of the embodiment of the present invention, the determining module includes:

[0042] An acquisition unit, used to determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area;

[0043] A judging unit, configured to judge, for each pixel point in the preset face area, whether a brightness difference between background brightness and face brightness is greater than a first preset brightness;

[0044] a determination unit, configured to determine that the target pixel is a face pixel if the brightness difference between the background brightness of the target pixel and the face brightness is greater than the first preset brightness;

[0045] The processing unit is used to determine a target face area according to a plurality of continuous face pixels.

[0046] As an optional implementation manner of the embodiment of the present invention, the acquisition unit is specifically used to:

[0047] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0048] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0049] As an optional implementation of the embodiment of the present invention, the matching module is specifically used for:

[0050] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0051] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0052] As an optional implementation of the embodiment of the present invention, the judgment module is further specifically used for:

[0053] If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0054] In a third aspect, the present application provides an electronic device, comprising a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the steps of the method provided in the first aspect of the present application are implemented.

[0055] In a fourth aspect, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of the method provided in the first aspect of the present application are implemented.

[0056] Compared with the prior art, the technical solution provided by this application has the following advantages:

[0057] The present application provides a face focusing method, which detects whether there is a face in the current shooting scene; if there is a face in the current shooting scene, detects whether the current shooting scene is a dark environment, or detects whether the current shooting scene is a backlit environment; if the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is determined based on the difference between the background brightness and the face brightness in the preset face area; and the focus point position is determined according to the ratio of the target face area to the entire framing area. In a face shooting scene, when it is determined that the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is first determined based on the difference between the background brightness and the face brightness in the preset face area, and then the corresponding calibrated focus position is matched according to the ratio of the face size to the entire framing area, so that focusing can be achieved quickly. This method uses the specific attributes of the face as a focusing condition, which avoids the problem of long focusing time caused by using the contrast focusing method in extreme shooting scenes such as dark environments and backlit environments. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0059] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.

[0060] Figure 1 is an application scenario diagram of a face focusing method in one embodiment;

[0061] Figure 2 is a schematic flow chart of a face focusing method in one embodiment;

[0062] Figure 3 is a structural schematic diagram of a face focusing device in one embodiment;

[0063] Figure 4 FIG. 1 is a schematic diagram of the structure of an electronic device in an embodiment. DETAILED DESCRIPTION

[0064] In order to more clearly understand the above-mentioned purposes, features and advantages of the present application, the scheme of the present application will be further described below. It should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0065] In the following description, many specific details are set forth to facilitate a full understanding of the present application, but the present application may also be implemented in other ways different from those described herein; obviously, the embodiments in the specification are only part of the embodiments of the present application, rather than all of the embodiments.

[0066] Camera: Camera, also known as computer camera, computer eye, electronic eye, etc., is a video input device that is widely used in video conferencing, telemedicine and real-time monitoring. For example, a camera can be used to communicate with images and sounds on the Internet. In addition, it can also be used for various popular digital images, audio and video processing, etc.

[0067] AF: (auto focus) is an algorithm that automatically adjusts the position of the lens to make the camera focus to the clearest position. This algorithm is widely used in terminal communication devices such as mobile phones, notebooks, and cars. The focusing principle of AF is: by changing the DC current of the coil inside the motor, the position of the lens is adjusted to present a clear image. The focusing process of AF is: the AF algorithm selects an appropriate area of ​​interest based on the current scene, and detects hardware and software statistics to determine whether there is a scene change. If the algorithm detects a scene change, the algorithm triggers AF focus and pushes the lens to the clearest position through the motor.

[0068] CAF: Contrast Auto Focus, which is a contrast focus method that moves the lens to make the image in the focus area reach the clearest focus. When aimed at the object to be photographed, the focus motor of the camera module searches from near focus to far focus, and calculates all the contrast values ​​in the process to obtain the maximum contrast value, and then returns the focus motor to the place with the maximum contrast value, which is the focus position of CAF.

[0069] PDAF: Phase Detection Auto Focus, that is, phase focus, uses the phase difference information of different pixels to determine the distance between the current lens position and the phase focus clear state position, so as to obtain the vector that the lens should move, and then move to the phase focus clear state position, that is, the PDAF focus position.

[0070] As the application of cameras expands, people have higher and higher requirements for image effects. Among image effects, autofocus debugging is particularly important, which determines whether a clear image can be presented. If an image has a problem of blur or loss of focus, no matter how reasonable the brightness and color are, the effect of the entire image will be blurred, which will bring a poor experience to users.

[0071] The face focusing method provided by the present application can be applied to electronic devices with a camera function. For example, the electronic device can be, but is not limited to, a smart phone, a tablet, a smart camera, a smart watch, a smart bracelet, a smart glasses, and other electronic devices with a camera function. Among them, the operating systems of various electronic devices may include, but are not limited to, the Android operating system, the IOS operating system, the Symbian operating system, the Black Berry operating system, the Windows Phone 8 operating system, etc., which are not limited in the embodiments of the present invention. Figure 1 FIG. 1 is an application scenario diagram of a face focusing method in an embodiment. The electronic device side 100 detects whether there is a face in the current shooting scene; if there is a face in the current shooting scene, it detects whether the current shooting scene is a dark environment, or detects whether the current shooting scene is a backlit environment; if the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is determined based on the difference between the background brightness and the face brightness in the preset face area; the focus point position is determined according to the ratio of the target face area to the entire framing area.

[0072] In one embodiment, Figure 2 As shown, a face focusing method is provided. This embodiment of the application takes the method applied to an electronic device as an example to illustrate, and the method includes the following steps:

[0073] S21, detecting whether there is a face in the current shooting scene.

[0074] Specifically, the user of the electronic device turns on the camera to preview or take a photo. The face recognition detection module detects whether there is a face in the current shooting scene. If there is a face in the current shooting scene, steps S22-S24 are continued.

[0075] In some embodiments, if there is no human face in the current shooting scene, focusing is performed according to a preset focusing method.

[0076] Among them, the preset focusing method can be but not limited to PDAF (phase different auto focus) or CAF (contrast auto focus). Among them, PDAF is to reserve some regularly symmetrical masked pixels on the photosensitive chip, which are specially used for phase detection. The focus offset, that is, the phase difference (PD value), is determined by the distance and change between pixels to achieve fast focusing. CAF contrast focusing, its process is similar to the "hill climbing algorithm", that is, the motor searches from near focus to far focus, calculates all the differences in the process, obtains the largest difference, and then returns the motor to the place with the largest difference, which is the focus point. This focusing method believes that the clearest point of the image is also the point with the largest contrast. The camera will drive the lens to change the focus point along the axis pointing to the subject, and obtain an image at each focus point, obtain the pixel brightness value and calculate the sum of the brightness of all pixels, and subtract the sum of the brightness values ​​of each pixel of the image obtained at the next focus point to obtain the contrast value between the two focuses. By comparison, the largest contrast is selected, and the lens is driven to focus on the focus with the largest contrast value, that is, the correct focus is obtained, and whether the focus is achieved is determined based on the value with the largest contrast, that is, the focusing is completed.

[0077] S22: If there is a human face in the current shooting scene, detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment.

[0078] In some embodiments, if the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0079] The preset focusing method may be, but is not limited to, PDAF (phase different auto focus) or CAF (contrast auto focus).

[0080] In some embodiments, the above step S22 (detecting whether the current shooting scene is a dark environment) can be implemented as follows:

[0081] Determine whether the current environment brightness is less than the threshold brightness.

[0082] The threshold brightness can be set according to the actual application scenario and is not specifically limited here.

[0083] Specifically, the current environment brightness is obtained through a light sensor of the electronic device to determine whether the current environment brightness is less than a threshold brightness.

[0084] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0085] Specifically, if the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a low-brightness scene, that is, the current shooting scene is a dark environment.

[0086] In some embodiments, the above step S22 (detecting whether the current shooting scene is a backlit environment) can be implemented in the following manner:

[0087] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness.

[0088] Among them, the preset brightness can be set according to the actual application scenario and is not specifically limited here.

[0089] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0090] Specifically, determine whether the brightness of the face area is less than the preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness. If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than or equal to the preset brightness, then determine that the current shooting scene is a backlight environment.

[0091] S23: If the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, determine a target face area based on a difference between background brightness and face brightness in a preset face area.

[0092] In some embodiments, the above step S23 (determining the target face area based on the difference between the background brightness and the face brightness in the preset face area) can be implemented as follows:

[0093] A. Determine the preset face area based on the left eye position, right eye position and mouth center point position.

[0094] Wherein, the preset face area is smaller than the entire framing area.

[0095] Optionally, the above step A (determining the preset face area based on the left eye position, the right eye position and the mouth center point position) can be implemented as follows:

[0096] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0097] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0098] Among them, the preset value can be set according to the actual application scenario. It should be noted that the preset face area obtained by expanding the initial face area with the preset value as the expansion multiple is smaller than the entire framing area. For example, the preset value can be 2, 3, 5, etc.

[0099] For example, refer to Figure 1 As shown, Figure 1 A, B, and C represent the center points of a person's left eye, right eye, and mouth, respectively. The initial face area can be the circumscribed square of the smallest circle determined by the center points of the left eye, right eye, and mouth of the person. The intersection of the diagonals of the initial face area is taken as the center and expanded outward by 3 times to obtain the preset face area.

[0100] B. In the preset face area, for each pixel point, determine whether the brightness difference between the background brightness and the face brightness is greater than a first preset brightness.

[0101] The first preset brightness can be set according to the actual application scenario, and is not specifically limited here. For example, the first preset brightness can be set to 20, 25, etc.

[0102] C. If the brightness difference between the background brightness of the target pixel and the face brightness is greater than the first preset brightness, the target pixel is determined to be a face pixel.

[0103] D. Determine the target face area based on a plurality of continuous face pixel points.

[0104] Specifically, in the preset face area, for each pixel point, determine whether the brightness difference between the background brightness and the face brightness is greater than the first preset brightness; if the brightness difference between the background brightness and the face brightness of the target pixel point is greater than the first preset brightness, then the target pixel point is determined to be a face pixel point; based on multiple continuous face pixels, the target face area is determined.

[0105] Exemplarily, the brightness difference between the background brightness and the face brightness in the preset face area can be accurately counted to each pixel. When the brightness difference between the background brightness and the face brightness of the target pixel is greater than 20, the target pixel is determined to be a face pixel, and the target face area is determined based on multiple continuous face pixels.

[0106] S24: Determine a focus point position according to a ratio of the target face area to the entire framing area.

[0107] In some embodiments, the above step S24 (determining the focus point position according to the ratio of the target face area to the entire framing area) can be implemented as follows:

[0108] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0109] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0110] Specifically, according to the ratio of facesize / fov, the position of the lens is calibrated in segments, and linear interpolation is used between segments. Among them, facesize represents the size of the target face area, and fov represents the size of the entire framing area. When facesize / fov is calculated and the corresponding region segment is found, the motor can be directly pushed to the corresponding pos position to achieve focusing. It should be noted that in the initial stage of the focus point position calibration project, the corresponding pos is tested according to the faces in different positions, and the corresponding region is filled in for calibration and restriction.

[0111] Exemplarily, each time the facesize / fov value is calculated, the corresponding region segment is found according to the facesize / fov value, so as to quickly push the position to the corresponding calibrated pos position.

[0112] Since CAF is a hill-climbing focus, it is necessary to find the focus position step by step. The motor often runs back and forth, and the focusing is very slow. The focusing method provided by the embodiment of the present disclosure can be done in one step. When the facesize is determined, the quasi-focus position is determined, so the focusing can be completed quickly. It effectively solves the problem of easy defocus and out-of-focus in extreme face scenes such as low-light environments and backlit environments. In addition, since this focusing method matches the corresponding calibrated focus position according to the ratio of the face size to the FOV, the focusing method is very fast and can basically be done in one step, avoiding the problems of large stretching and long focusing time caused by CAF in low-light and backlit environments.

[0113] The present application provides a face focusing method, which detects whether there is a face in the current shooting scene; if there is a face in the current shooting scene, detects whether the current shooting scene is a dark environment, or detects whether the current shooting scene is a backlit environment; if the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is determined based on the difference between the background brightness and the face brightness in the preset face area; and the focus point position is determined according to the ratio of the target face area to the entire framing area. In a face shooting scene, when it is determined that the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is first determined based on the difference between the background brightness and the face brightness in the preset face area, and then the corresponding calibrated focus position is matched according to the ratio of the face size to the entire framing area, so that focusing can be achieved quickly. This method uses the specific attributes of the face as a focusing condition, which avoids the problem of long focusing time caused by using the contrast focusing method in extreme shooting scenes such as dark environments and backlit environments.

[0114] In one embodiment, Figure 3 As shown, a face focusing device 300 is provided, comprising:

[0115] A detection module 310 is used to detect whether there is a face in the current shooting scene;

[0116] The judgment module 320 is used to detect whether the current shooting scene is a dark environment if there is a face in the current shooting scene, or to detect whether the current shooting scene is a backlit environment;

[0117] A determination module 330 is used to determine a target face area based on a difference between background brightness and face brightness in a preset face area if the current shooting scene is a dark environment or a backlit environment;

[0118] The matching module 340 is used to determine the focus point position according to the ratio of the target face area to the entire framing area.

[0119] As an optional implementation of the embodiment of the present invention, the judgment module is specifically used to:

[0120] Determine whether the current environment brightness is less than the threshold brightness;

[0121] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0122] As an optional implementation of the embodiment of the present invention, the judgment module is further specifically used for:

[0123] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness;

[0124] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0125] As an optional implementation of the embodiment of the present invention, the determining module includes:

[0126] An acquisition unit, used to determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area;

[0127] A judging unit, configured to judge, for each pixel point in the preset face area, whether a brightness difference between background brightness and face brightness is greater than a first preset brightness;

[0128] a determination unit, configured to determine that the target pixel is a face pixel if the brightness difference between the background brightness of the target pixel and the face brightness is greater than the first preset brightness;

[0129] The processing unit is used to determine a target face area according to a plurality of continuous face pixels.

[0130] As an optional implementation manner of the embodiment of the present invention, the acquisition unit is specifically used to:

[0131] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0132] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0133] As an optional implementation of the embodiment of the present invention, the matching module is specifically used for:

[0134] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0135] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0136] As an optional implementation of the embodiment of the present invention, the judgment module is further specifically used for:

[0137] If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0138] The present application provides a face focusing device, which detects whether there is a face in the current shooting scene; if there is a face in the current shooting scene, it detects whether the current shooting scene is a dark environment, or detects whether the current shooting scene is a backlit environment; if the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is determined based on the difference between the background brightness and the face brightness in the preset face area; the focus point position is determined according to the ratio of the target face area to the entire framing area. In a face shooting scene, when it is determined that the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, the target face area is first determined based on the difference between the background brightness and the face brightness in the preset face area, and then the corresponding calibrated focus position is matched according to the ratio of the face size to the entire framing area, so that focusing can be achieved quickly. This method of using the specific attributes of the face as a focusing condition avoids the problem of long focusing time caused by using the contrast focusing method in extreme shooting scenes such as dark environments and backlit environments.

[0139] For the specific definition of the face focusing device, please refer to the definition of the face focusing method applied to electronic devices in the above text, which will not be repeated here. Each module in the above-mentioned face focusing device can be implemented in whole or in part by software, hardware and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the electronic device in the form of hardware, or can be stored in the memory in the electronic device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0140] In one embodiment, an electronic device is provided, whose internal structure diagram can be as follows: Figure 4 As shown. The electronic device includes a processor 41 and a memory 42 connected via a system bus. Among them, the processor 41 of the electronic device is used to provide computing and control capabilities. The memory 42 of the electronic device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. When the computer program is executed by the processor, a face focusing method is implemented. The display screen of the electronic device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the electronic device can be a touch layer covering the display screen, or a button, trackball or touchpad provided on the housing of the electronic device, or an external keyboard, touchpad or mouse, etc.

[0141] Those skilled in the art will understand that Figure 4 The structure shown in the figure is merely a block diagram of a partial structure related to the scheme of the present application, and does not constitute a limitation on the electronic device to which the scheme of the present application is applied. The specific electronic device may include more or fewer components than shown in the figure, or combine certain components, or have a different arrangement of components.

[0142] In one embodiment, the face focusing method provided by the present application can be implemented in the form of a computer program. The computer program can be Figure 4 The memory of the electronic device may store various program modules constituting the mobile terminal of the electronic device, for example, Figure 3 The detection module 310, judgment module 320, determination module 330 and matching module 340 are shown. The computer program composed of various program modules enables the processor to execute the steps of the face focusing method of the electronic device of each embodiment of the present application described in this specification.

[0143] For example, Figure 4 The electronic device shown can be Figure 3 The detection module 310 in the face focusing device shown in the figure performs step S21. The electronic device can perform step S22 through the judgment module 320. The electronic device can perform step S23 through the determination module 330. The electronic device can perform step S24 through the matching module 340.

[0144] In one embodiment, an electronic device is provided, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0145] Detect whether there is a face in the current shooting scene;

[0146] If there is a human face in the current shooting scene, detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment;

[0147] If the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, determining the target face area based on the difference between the background brightness and the face brightness in the preset face area;

[0148] The focus point position is determined according to the ratio of the target face area to the entire framing area.

[0149] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment includes:

[0150] Determine whether the current environment brightness is less than the threshold brightness;

[0151] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0152] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a backlight environment includes:

[0153] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness;

[0154] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0155] As an optional implementation of the embodiment of the present invention, the determining of the target face area based on the difference between the background brightness and the face brightness in the preset face area includes:

[0156] Determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area;

[0157] In the preset face area, for each pixel point, determining whether the brightness difference between the background brightness and the face brightness is greater than a first preset brightness;

[0158] If the brightness difference between the background brightness of the target pixel and the brightness of the face is greater than the first preset brightness, the target pixel is determined to be a face pixel;

[0159] A target face area is determined according to a plurality of continuous face pixels.

[0160] As an optional implementation of the embodiment of the present invention, determining a preset face area based on the left eye position, the right eye position and the center point position of the mouth includes:

[0161] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0162] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0163] As an optional implementation manner of the embodiment of the present invention, determining the focus point position according to the ratio of the target face area to the entire framing area includes:

[0164] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0165] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0166] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment, or the detecting whether the current shooting scene is a backlit environment, further includes:

[0167] If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0168] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the computer program is executed by a processor, the following steps are implemented:

[0169] Detect whether there is a face in the current shooting scene;

[0170] If there is a human face in the current shooting scene, detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment;

[0171] If the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, determining the target face area based on the difference between the background brightness and the face brightness in the preset face area;

[0172] The focus point position is determined according to the ratio of the target face area to the entire framing area.

[0173] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment includes:

[0174] Determine whether the current environment brightness is less than the threshold brightness;

[0175] If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

[0176] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a backlight environment includes:

[0177] Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness;

[0178] If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

[0179] As an optional implementation of the embodiment of the present invention, the determining of the target face area based on the difference between the background brightness and the face brightness in the preset face area includes:

[0180] Determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area;

[0181] In the preset face area, for each pixel point, determining whether the brightness difference between the background brightness and the face brightness is greater than a first preset brightness;

[0182] If the brightness difference between the background brightness of the target pixel and the brightness of the face is greater than the first preset brightness, the target pixel is determined to be a face pixel;

[0183] A target face area is determined according to a plurality of continuous face pixels.

[0184] As an optional implementation of the embodiment of the present invention, determining a preset face area based on the left eye position, the right eye position and the center point position of the mouth includes:

[0185] Determine the initial face region based on the left eye position, the right eye position and the mouth center point position;

[0186] The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

[0187] As an optional implementation manner of the embodiment of the present invention, determining the focus point position according to the ratio of the target face area to the entire framing area includes:

[0188] Determining a lens focus area according to a ratio of the target face area to the entire framing area;

[0189] According to the lens focus area, the corresponding calibrated focus point position is matched.

[0190] As an optional implementation manner of the embodiment of the present invention, the detecting whether the current shooting scene is a dark environment, or the detecting whether the current shooting scene is a backlit environment, further includes:

[0191] If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

[0192] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or device including the element.

[0193] Those of ordinary skill in the art can understand that the implementation of all or part of the process in the example method described above can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the process of the embodiments of the above methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory may include ROM (Read-Only Memory), tape, floppy disk, flash memory or optical storage, etc. Volatile memory may include RAM (Random Access Memory) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as SRAM (Static Random Access Memory) and DRAM (Dynamic Random Access Memory).

[0194] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0195] The above is only a specific implementation of the present application, so that those skilled in the art can understand or implement the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features applied for herein.

Claims

1. A face focusing method, characterized in that: The method comprises: Detect whether there is a face in the current shooting scene; If there is a human face in the current shooting scene, detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment; If the current shooting scene is a dark environment, or the current shooting scene is a backlit environment, determining the target face area based on the difference between the background brightness and the face brightness in the preset face area; The focus point position is determined according to the ratio of the target face area to the entire framing area.

2. The method according to claim 1, characterized in that The detecting whether the current shooting scene is a dark environment includes: Determine whether the current environment brightness is less than the threshold brightness; If the current environment brightness is less than the threshold brightness, it is determined that the current shooting scene is a dark environment.

3. The method according to claim 1, characterized in that The detecting whether the current shooting scene is a backlit environment includes: Determine whether the brightness of the face area is less than a preset brightness, and whether the brightness of the background area is greater than or equal to the preset brightness; If the brightness of the face area is less than the preset brightness, and the brightness of the background area is greater than the preset brightness, it is determined that the current shooting scene is a backlit environment.

4. The method according to claim 1, characterized in that: The step of determining the target face area based on the difference between the background brightness and the face brightness in the preset face area includes: Determine a preset face area based on the left eye position, the right eye position and the center point position of the mouth; the preset face area is smaller than the entire framing area; In the preset face area, for each pixel point, determining whether the brightness difference between the background brightness and the face brightness is greater than a first preset brightness; If the brightness difference between the background brightness of the target pixel and the brightness of the face is greater than the first preset brightness, the target pixel is determined to be a face pixel; A target face area is determined according to a plurality of continuous face pixels.

5. The method according to claim 4, characterized in that The step of determining a preset face area based on the left eye position, the right eye position and the center point position of the mouth includes: Determine the initial face region based on the left eye position, the right eye position and the mouth center point position; The initial face region is expanded with a preset value as an expansion multiple with the intersection of the diagonal lines of the initial face region as the center to obtain a preset face region.

6. The method according to claim 1, characterized in that Determining the focus point position according to the ratio of the target face area to the entire framing area includes: Determining a lens focus area according to a ratio of the target face area to the entire framing area; According to the lens focus area, the corresponding calibrated focus point position is matched.

7. The method according to claim 1, characterized in that The detecting whether the current shooting scene is a dark environment, or detecting whether the current shooting scene is a backlit environment, further includes: If the current shooting scene is not a dark environment, or the current shooting scene is not a backlit environment, focusing is performed according to a preset focusing method.

8. A face focusing device, characterized in that: include: A detection module, used to detect whether there is a face in the current shooting scene; A judgment module, used for detecting whether the current shooting scene is a dark environment if there is a face in the current shooting scene, or detecting whether the current shooting scene is a backlit environment; A determination module, configured to determine a target face area based on a difference between background brightness and face brightness in a preset face area if the current shooting scene is a dark environment or a backlit environment; The matching module is used to determine the focus point position according to the ratio of the target face area to the entire framing area.

9. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the face focusing method according to any one of claims 1 to 7 is implemented.

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