Face mask recognition method and device, electronic equipment and storage medium
By using image brightness and chromaticity information for statistical judgment in face mask recognition, the uncertainty and high computational cost of deep learning models in face mask recognition are solved, thus improving recognition efficiency and accuracy.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-25
- Publication Date
- 2026-04-07
AI Technical Summary
Existing face mask recognition algorithms are based on deep learning models, which suffer from uncertainty and high computational cost, leading to decreased recognition accuracy and low efficiency.
By using the brightness and chromaticity information of the image to be identified for statistical judgment, the mask area in the face image region can be identified, avoiding the use of deep learning models.
It improves the efficiency and accuracy of face mask recognition, reduces errors caused by factors such as mask shape, and reduces computational load and model training requirements.
Smart Images

Figure CN115984921B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, and in particular to a face mask recognition method and device, electronic device, and storage medium. Background Technology
[0002] Currently, for various application scenarios where users need to wear masks daily, electronic devices equipped with cameras can use their cameras to detect and identify whether users are wearing masks correctly. However, in practice, it has been found that existing facial mask recognition algorithms are often based on deep learning models, which have significant uncertainties in real-world applications. For example, they can easily miss masked areas on the face when the mask shape changes or the model is not sufficiently trained, leading to a decrease in recognition accuracy. Furthermore, such algorithms often require a large amount of computation, which also reduces the efficiency of facial mask recognition on electronic devices. Summary of the Invention
[0003] This application discloses a face mask recognition method and device, electronic device, and storage medium, which can improve the efficiency and accuracy of face mask recognition by electronic devices.
[0004] The first aspect of this application discloses a face mask recognition method, including:
[0005] From the image to be identified, determine the facial image region to be identified;
[0006] Obtain the facial brightness information and facial color information corresponding to the facial image region;
[0007] Based on the face brightness information and the face color information, the mask area in the face image region is identified, where the mask area is the image region in the image to be identified where a face is wearing a mask.
[0008] The second aspect of this application discloses a face mask recognition device, comprising:
[0009] The first recognition unit is used to determine the face image region to be recognized from the image to be recognized;
[0010] The information acquisition unit is used to acquire the face brightness information and face color information corresponding to the face image region;
[0011] The second recognition unit is used to recognize the mask area in the face image area based on the face brightness information and the face color information, wherein the mask area is the image area in the image to be recognized where a face is wearing a mask.
[0012] The third aspect of this application discloses an electronic device, including a memory and a processor. The memory stores a computer program, and when the computer program is executed by the processor, the processor performs all or part of the steps in any of the face mask recognition methods disclosed in the first aspect of this application.
[0013] The fourth aspect of this application discloses a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements all or part of the steps in any face mask recognition method disclosed in the first aspect of this application.
[0014] Compared with related technologies, the embodiments of this application have the following beneficial effects:
[0015] The face mask recognition method in this embodiment can be applied to an electronic device. This electronic device can determine the face image region to be recognized from the image to be recognized, and then obtain the face brightness information and color chromaticity information corresponding to that face image region. Based on this, the electronic device can recognize the mask region within the face image region according to the aforementioned face brightness information and color chromaticity information. The mask region is the image region in the image to be recognized where a face is wearing a mask. Therefore, by implementing this embodiment, the electronic device can utilize the image brightness and chromaticity information of the image to be recognized to identify the mask region within the face image region when a face is present, thereby determining whether the user is wearing a mask. This face mask recognition method not only achieves mask region recognition with less computation, but also, compared to recognition algorithms based on deep learning models, does not require extensive model training beforehand, thus improving the efficiency of face mask recognition by the electronic device. Furthermore, judging based on the brightness and chromaticity information of the face image itself can minimize errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by the electronic device. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram illustrating an application scenario of the face mask recognition method disclosed in the embodiments of this application;
[0018] Figure 2 This is a schematic flowchart of a face mask recognition method disclosed in an embodiment of this application;
[0019] Figure 3 This is a schematic diagram of determining a face image region from an image to be identified, as disclosed in an embodiment of this application;
[0020] Figure 4 This is a flowchart illustrating another face mask recognition method disclosed in an embodiment of this application;
[0021] Figure 5A This is a schematic diagram of an automatic exposure processing method for facial brightness information disclosed in an embodiment of this application;
[0022] Figure 5B This is a schematic diagram of an automatic white balance process for human facial color information disclosed in an embodiment of this application;
[0023] Figure 6 This is a flowchart illustrating another face mask recognition method disclosed in the embodiments of this application;
[0024] Figure 7 This is a schematic diagram of determining the corresponding mask area based on the brightness difference area and the chromaticity difference area disclosed in an embodiment of this application;
[0025] Figure 8 This is a modular schematic diagram of a face mask recognition device disclosed in an embodiment of this application;
[0026] Figure 9 This is a modular schematic diagram of an electronic device disclosed in an embodiment of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0028] It should be noted that the terms "comprising" and "having," and any variations thereof, in the embodiments of this application are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to these processes, methods, products, or devices. Unless otherwise specified, the embodiments, implementation methods, and related technical features in this application can be combined and substituted with each other, and the explanations in different embodiments and implementation methods can be applied interchangeably. "A plurality" in this application refers to two or more.
[0029] This application discloses a face mask recognition method and device, electronic device, and storage medium, which can improve the efficiency and accuracy of face mask recognition by electronic devices.
[0030] The following will be described in detail with reference to the accompanying drawings.
[0031] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of the face mask recognition method disclosed in this application, including an electronic device 10 and a user 20. The electronic device 10 may include an image acquisition device (e.g., a camera, etc.). Figure 1 (Not specifically shown in the text) User 20 can hold or set up the electronic device 10 and use its image acquisition device to collect facial images of User 20 or other users (hereinafter collectively referred to as User 20) to determine whether they have worn masks correctly.
[0032] The aforementioned electronic device 10 may include various devices or systems equipped with image acquisition devices, such as mobile phones, smart wearable devices, vehicle terminals, tablet computers, PCs (Personal Computers), PDAs (Personal Digital Assistants), turnstile systems, security inspection systems, health monitoring systems, etc., and is not specifically limited in this embodiment. It should be noted that... Figure 1 The electronic device 10 shown is a mobile phone. This is merely an example and should not be considered as a limitation on the device type of electronic device 10 in the embodiments of this application.
[0033] In some embodiments, the electronic device 10 may not include an image acquisition device, but instead acquire the image to be identified from other devices (such as mobile phones, computers, servers, etc.). For example, the electronic device 10 can establish a communication connection with other devices, thereby acquiring the image to be identified sent to the electronic device 10 by other devices, so that the electronic device 10 can perform face mask recognition on the image to be identified locally.
[0034] After acquiring an image to be recognized through its image acquisition device or other devices, the electronic device 10 can perform face detection and further mask region recognition on the image. In related technologies, the electronic device 10 often employs algorithms based on deep learning models for recognition; that is, the image to be recognized is taken as input, processed by a pre-trained model, and the mask region in the image is obtained as output. However, with the increasing diversity of mask styles in daily life, and the potential changes in mask shape and insufficient model training during practical applications, such face mask recognition algorithms still have significant uncertainties, easily leading to omissions or misidentifications of mask regions, resulting in decreased recognition accuracy. The large computational load also reduces the efficiency of the electronic device in face mask recognition.
[0035] To address the aforementioned issues, in this embodiment, the electronic device 10 can utilize color information (such as brightness and chromaticity information) in the image to be identified for statistical judgment, thereby avoiding potential recognition errors due to the "black box" nature of deep learning models. Taking the electronic device 10 acquiring the image to be identified through its built-in image acquisition device as an example... Figure 1 As shown, in order to identify whether user 20 is wearing a mask, electronic device 10 can capture an image of user 20 to be identified. Electronic device 10 can determine the facial image region to be identified from the image, and then obtain the facial brightness information and facial color information corresponding to that facial image region. Based on this, electronic device 10 can identify the mask region within the facial image region according to the aforementioned facial brightness information and facial color information; the mask region is the image region in the image to be identified where a face is wearing a mask.
[0036] As can be seen, by implementing the above-described face mask recognition method, the electronic device 10 can utilize the image brightness and chromaticity information of the image to be recognized to identify the mask area within the face image region when a face is present, thereby determining whether the user 20 is wearing a mask. This not only achieves mask area recognition with less computation but also, compared to recognition algorithms based on deep learning models, eliminates the need for extensive model training beforehand, thus improving the efficiency of face mask recognition by the electronic device 10. Furthermore, judging based on the brightness and chromaticity information of the face image itself can minimize errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by the electronic device 10.
[0037] Please see Figure 2 , Figure 2 This is a flowchart illustrating a face mask recognition method disclosed in an embodiment of this application. Figure 2As shown, the face mask recognition method may include the following steps:
[0038] 202. Identify the face image region to be identified from the image to be identified.
[0039] In this embodiment of the application, after acquiring the image to be identified, the electronic device can first perform face detection on the image to determine whether a face exists in it, and if a face exists, determine the corresponding face image region.
[0040] For example, please refer to Figure 3 , Figure 3 This is a schematic diagram illustrating how to determine a face image region from an image to be identified, as disclosed in an embodiment of this application. Figure 3 As shown, when a user holds or sets up an electronic device to capture images, the acquired image to be recognized often includes the user's upper body and a large area of background environment (such as...). Figure 3 (As shown in the area within the box on the left). To perform masked region recognition on faces in subsequent steps, the electronic device can directly employ various face detection algorithms to segment the face image region from the image to be recognized (e.g., Figure 3 (As shown in the inner frame on the right).
[0041] In some embodiments, if the image to be identified is a preview stream presented by the electronic device during the preview acquisition process, the electronic device can determine the face image region from the image to be identified in real time and dynamically based on the AF (Auto Focus) algorithm. For example, the electronic device can perform face detection on each frame of the image to be identified in the preview stream to determine the ROI (Region of Interest) in each frame, i.e., the region where a face exists. Based on this, the electronic device can calculate the depth information of the ROI and perform corresponding focusing processing based on the depth information to obtain a clearly focused ROI as the face image region corresponding to each frame of the image to be identified in the preview stream.
[0042] Optionally, the electronic device can also select an initial frame of the image to be recognized in the preview stream and perform face detection on that initial frame to determine the corresponding Region of Interest (ROI). Based on this, the electronic device can perform tracking and focusing (including motion tracking, depth information calculation for focusing, etc.) on the ROIs of each subsequent frame of the image to be recognized in the preview stream, thereby obtaining the clearly focused ROIs in each subsequent frame of the image to be recognized as the face image regions corresponding to each subsequent frame of the image to be recognized.
[0043] In other embodiments, if the image to be identified is a static image that has been acquired by the electronic device, the electronic device can directly perform face detection on the image to be identified and use the detected ROI as the face image region to be identified.
[0044] 204. Obtain the facial brightness information and facial color information corresponding to the facial image region.
[0045] In this embodiment of the application, after determining the face image region in the image to be identified, the electronic device can obtain the face brightness information and face color information corresponding to the face image region from the image data of the image to be identified. Then, in subsequent steps, it can determine whether there is a mask region in the face image region based on the face brightness information and face color information, thereby determining whether the corresponding detected user has worn a mask correctly.
[0046] The aforementioned face brightness information refers to the brightness data corresponding to each pixel in the face image region of the image to be recognized. This brightness data can be represented by grayscale values (for example, an 8-bit grayscale value can be represented by any integer in [0, 255]), or by the light intensity per unit area (the unit is candela per square meter, i.e., cd / m²). 2 The color information mentioned above refers to the color data corresponding to each pixel in the face image region of the image to be recognized. This color data may include hue and saturation. In some embodiments, it may also be represented by the proportion of primary colors corresponding to each color channel (e.g., the red R, green G, and blue B color channels in three-channel color). This application does not impose specific limitations on this embodiment.
[0047] In some embodiments, after determining a face image region, the electronic device can obtain the face brightness information and face color information corresponding to that face image region based on the image data corresponding to the face image region stored in its database. In other embodiments, the electronic device can also, during the process of acquiring the image to be recognized (e.g., acquiring the aforementioned preview stream, or a static image that has already been acquired), directly obtain the face brightness information and face color information corresponding to the face image region determined after face detection, based on the image metadata of the image to be recognized.
[0048] 206. Based on the above face brightness information and face color information, identify the mask area in the face image area. The mask area is the image area in the above image to be identified where a face is wearing a mask.
[0049] In this embodiment of the application, after the electronic device acquires the above-mentioned face brightness information and face color information, it can perform statistical analysis based on the face brightness information and face color information to determine whether there is a mask area (i.e., an image area where a face is wearing a mask) in the face image area, and if there is a mask area, determine the specific location of the mask area.
[0050] For example, since the brightness of other parts of the face is usually significantly different from that of the mask-wearing area (mainly the lower half of the user's face) when the user is wearing a mask, the electronic device can perform exposure processing on the above-mentioned face brightness information so that the first mask area (hereinafter referred to as the brightness difference area) with obvious brightness difference in the face image area can be distinguished.
[0051] For example, since the color of other parts of the face is usually significantly different from that of the mask-wearing area when the user is wearing a mask, the electronic device can perform white balance processing on the above-mentioned color information so that the second mask area (hereinafter referred to as the color difference area) with obvious color difference in the face image area can also be distinguished.
[0052] Based on this, the electronic device can determine, according to the results of the exposure processing and white balance processing, whether there exists a suitable image region in the brightness difference region and the color difference region that can indicate that the user has correctly worn a mask on their face. If such a region exists, the electronic device can identify it as the mask region in the image to be recognized; if not, the electronic device can determine that the user has not worn a mask correctly, and can then perform corresponding subsequent processing measures, such as outputting prompt information, etc., which are not specifically limited in this embodiment.
[0053] As can be seen, by implementing the face mask recognition method described in the above embodiments, the electronic device can utilize the image brightness and chromaticity information of the image to be recognized, and when a face is present, identify the mask area within the face image region, thereby determining whether the user is wearing a mask. This not only achieves mask area recognition with less computation, but also, compared to recognition algorithms based on deep learning models, does not require extensive model training beforehand, thus improving the efficiency of face mask recognition by the electronic device. Furthermore, judging based on the brightness and chromaticity information of the face image itself can minimize errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by the electronic device.
[0054] Please see Figure 4 , Figure 4 This is a flowchart illustrating another face mask recognition method disclosed in an embodiment of this application. Figure 4As shown, the face mask recognition method may include the following steps:
[0055] 402. Determine the face image region to be identified from the image to be identified.
[0056] 404. Obtain the facial brightness information and facial color information corresponding to the facial image region.
[0057] Steps 402 and 404 are similar to steps 202 and 204 above, and will not be described again here.
[0058] 406. Perform automatic exposure processing on the above face brightness information to identify areas of brightness difference in the face image area.
[0059] In this embodiment of the application, in order to determine whether the user's face in the face image area is wearing a mask correctly, the electronic device can process the face brightness information and the face color information respectively, and analyze and determine the mask area that is significantly different from the brightness and color of other parts of the face.
[0060] Specifically, regarding the aforementioned facial brightness information, the electronic device can use Automatic Exposure (AE) to identify brightness difference regions within the facial image area. These brightness difference regions can be used to determine the actual mask area in subsequent steps. For example, after performing automatic exposure processing on the facial brightness information, the electronic device can acquire brightness data corresponding to each pixel in the facial image area (e.g., represented by grayscale values or light intensity per unit area). Furthermore, based on the brightness data corresponding to each pixel, it can separate the brightness difference regions from the facial image area.
[0061] In some embodiments, the electronic device can first determine an initial brightness difference region based on the brightness data corresponding to each pixel in the face image region, and calculate the brightness data of a first region corresponding to the brightness difference region (e.g., brightness mean, brightness variance, brightness difference peak, etc., determined by the brightness data corresponding to each pixel in the brightness difference region), and the brightness data of a second region corresponding to other regions in the face image region besides the brightness difference region (e.g., brightness mean, brightness variance, brightness difference peak, etc., determined by the brightness data corresponding to each pixel in the other regions). Based on this, the electronic device can calculate the difference between the brightness data of the first region and the brightness data of the second region. If the difference exceeds a pre-specified first difference threshold, the brightness difference region can be confirmed; if the difference does not exceed the first difference threshold, the electronic device can adjust the initial brightness difference region until the difference between the brightness data of the first region and the brightness data of the second region corresponding to the new brightness difference region exceeds the first difference threshold.
[0062] For example, such as Figure 5A As shown, during the automatic exposure processing of the face image region, the AEFace Target mechanism can identify areas with significant brightness differences. These brightness difference areas, along with the corresponding brightness data of the first region, can then be used in subsequent steps to determine the mask area.
[0063] 408. Perform automatic white balance processing on the above facial color information to identify color difference areas in the facial image region.
[0064] In this embodiment, regarding the aforementioned facial color information, the electronic device can use Automatic White Balance (AWB) to identify color difference regions in the facial image area. These color difference regions can be used to determine the actual mask area in subsequent steps. For example, after performing automatic white balance processing on the aforementioned facial color information, the electronic device can obtain color data (including hue and saturation) corresponding to each pixel in the facial image area, and then separate the color difference regions from the aforementioned facial image area based on the color data corresponding to each pixel.
[0065] In some embodiments, the electronic device can first determine an initial chromaticity difference region based on the chromaticity data corresponding to each pixel in the face image region, and calculate the chromaticity data of a first region corresponding to the chromaticity difference region (e.g., chromaticity mean, chromaticity variance, chromaticity difference peak value, etc., determined by the chromaticity data corresponding to each pixel in the chromaticity difference region), and the chromaticity data of a second region corresponding to other regions in the face image region besides the chromaticity difference region (e.g., chromaticity mean, chromaticity variance, chromaticity difference peak value, etc., determined by the chromaticity data corresponding to each pixel in the other regions). Based on this, the electronic device can calculate the difference between the chromaticity data of the first region and the chromaticity data of the second region. If the difference exceeds a pre-specified second difference threshold, the chromaticity difference region can be confirmed; if the difference does not exceed the second difference threshold, the electronic device can adjust the initial chromaticity difference region until the difference between the chromaticity data of the first region and the chromaticity data of the second region corresponding to the new chromaticity difference region exceeds the second difference threshold.
[0066] For example, such as Figure 5BAs shown, during the automatic white balance processing of the face image region, the AWB Face Target mechanism can identify regions with significant chromaticity differences. These chromaticity difference regions, along with the corresponding chromaticity data of the first region, can be used in subsequent steps, together with the aforementioned brightness difference regions and their corresponding brightness data, to further determine the mask area.
[0067] 410. Based on the brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region, determine the mask region corresponding to the brightness difference region and the chromaticity difference region.
[0068] In this embodiment of the application, the electronic device can perform weighted summation on the brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region to obtain comprehensive color data, and determine whether there is a suitable image region in the face image region that can be used as a mask region indicating that the user has correctly worn a mask based on the comprehensive color data.
[0069] The brightness data of the first region can be determined by the brightness data corresponding to each pixel in the brightness difference region (e.g., the mean brightness, variance brightness, and peak brightness difference of the brightness difference region), or it can be determined by the brightness data corresponding to each pixel in the brightness difference region and other regions of the face image region (e.g., the peak brightness difference between the brightness difference region and other regions). Similarly, the chromaticity data of the first region can be determined by the chromaticity data corresponding to each pixel in the chromaticity difference region (e.g., the mean chromaticity, variance chromaticity, and peak chromaticity difference of the chromaticity difference region), or it can be determined by the chromaticity data corresponding to each pixel in the chromaticity difference region and other regions of the face image region (e.g., the peak chromaticity difference between the chromaticity difference region and other regions).
[0070] Based on this, the electronic device can assign the same or different weights to the brightness data and chromaticity data of the first region to obtain a weighted calculation of the comprehensive color data. For example, the process of calculating the comprehensive color data S can be shown in Formula 1 below:
[0071] Formula 1:
[0072] S=A*α+B*β
[0073] Where A represents the luminance data of the first region, α represents the weight of the luminance data of the first region (e.g., a value of 0.3); B represents the chromaticity data of the first region, and β represents the weight of the chromaticity data of the first region (e.g., a value of 0.7).
[0074] Furthermore, if the aforementioned comprehensive color data is greater than a predetermined target color threshold, it indicates that there is an image region that is significantly different from other areas of the face in the aforementioned brightness difference region and chromaticity difference region. Thus, the electronic device can determine the corresponding mask region based on the aforementioned brightness difference region and chromaticity difference region.
[0075] For example, when the comprehensive color data is greater than the target color threshold, the electronic device can determine the mask area in the image to be identified by the intersection of the brightness difference area and the chromaticity difference area; or, the electronic device can determine the mask area in the image to be identified by the union of the brightness difference area and the chromaticity difference area.
[0076] The target color threshold can be an empirical value or determined by pre-processing sample images; however, this embodiment does not specifically limit its application. In some embodiments, the electronic device can use a fixed single target color threshold to perform the comparison process with the comprehensive color data. In other embodiments, the electronic device can also use a variable target color threshold (e.g., in outdoor scenes, different target color thresholds can be used depending on time, ambient light, etc.) to achieve more accurate mask area recognition in different scenarios and improve the accuracy of face mask recognition by the electronic device. Optionally, the electronic device can also use multiple target color thresholds to form different color threshold ranges. This allows for different degrees of scaling processing of the mask area determined by the electronic device when the comprehensive color data falls within different color threshold ranges, further improving the accuracy of face mask recognition by the electronic device.
[0077] As can be seen, by implementing the face mask recognition method described in the above embodiments, the electronic device can utilize the image brightness and chromaticity information of the image to be recognized to identify the face mask area, thereby determining whether the user is wearing a mask correctly. This not only achieves mask area recognition with less computation, improving the efficiency of face mask recognition by the electronic device, but also minimizes errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by the electronic device. Furthermore, by analyzing the brightness and chromaticity information of the face, mask areas that are significantly different in brightness and chromaticity from other parts of the face can be accurately identified, which helps to improve the accuracy of face mask recognition by the electronic device.
[0078] Please see Figure 6 , Figure 6 This is a flowchart illustrating another face mask recognition method disclosed in an embodiment of this application. Figure 6 As shown, the face mask recognition method may include the following steps:
[0079] 602. For at least one sample image, determine the sample face region and sample mask region in each sample image respectively.
[0080] In this embodiment, to determine the mask region in a face image region in subsequent steps, a target color threshold required for the determination can be predetermined. This target color threshold can be determined using at least one sample image. For example, the electronic device can first acquire at least one (e.g., 10, 20, etc.) sample images of faces confirmed to be wearing masks, and based on AF, AE, and AWB methods, acquire sample face regions in each sample image, and further acquire their corresponding sample mask regions. In subsequent steps, the electronic device can calculate a general target color threshold for determining the presence of a mask region in a face image region based on the brightness and chromaticity differences between the sample face regions and the sample mask regions.
[0081] 604. Obtain the peak brightness difference and peak chromaticity difference between the face region of each sample and the corresponding mask region.
[0082] In this embodiment, for each sample image, the electronic device can acquire the brightness data (e.g., represented by grayscale values or light intensity per unit area) corresponding to each pixel in the sample face region, and further acquire the brightness data corresponding to each pixel in the corresponding sample mask region. Based on this, the electronic device can calculate the peak brightness difference between the sample face region and the corresponding sample mask region, that is, the maximum brightness difference between the sample mask region and other regions in the sample face region.
[0083] Similarly, for each sample image, the electronic device can acquire the chromaticity data (including hue and saturation) of each pixel in the sample face region, and further acquire the chromaticity data of each pixel in the corresponding sample mask region. Based on this, the electronic device can calculate the peak chromaticity difference between the sample face region and the corresponding sample mask region, that is, the maximum chromaticity difference between the sample mask region and other regions in the sample face region.
[0084] 606. Calculate the mean luminance difference of the peak luminance difference for each sample image and the mean chrominance difference of the peak chrominance difference for each sample image.
[0085] 608. Based on the average values of the brightness difference and the average values of the chromaticity difference mentioned above, determine the target color threshold.
[0086] In this embodiment, after acquiring the peak values of luminance difference and chromaticity difference corresponding to each of the sample images, the electronic device can further calculate the average value of each peak value of luminance difference, i.e., the average value of luminance difference; and calculate the average value of each peak value of chromaticity difference, i.e., the average value of chromaticity difference. Based on this, the electronic device can determine the target color threshold required for subsequent judgment of the mask area according to the average value of luminance difference and the average value of chromaticity difference.
[0087] For example, the electronic device can determine the target color threshold by using a weighted summation method. In some embodiments, the weights used by the electronic device can be the same as those used in the subsequent mask recognition process. That is, the average brightness difference can be multiplied by the weight α (the weight used for the brightness data of the first region, for example, a value of 0.3) in the above embodiment, and the average chromaticity difference can be multiplied by the weight β (the weight used for the chromaticity data of the first region, for example, a value of 0.7) in the above embodiment. The two weighted values are then added together to obtain the target color threshold. In other embodiments, the weights used by the electronic device may be different from those used in the subsequent mask recognition process. This application does not specifically limit the weights used in the embodiments.
[0088] 610. From the image to be identified, determine the face image region to be identified.
[0089] 612. Obtain the facial brightness information and facial color information corresponding to the facial image region.
[0090] Steps 610 and 612 are similar to steps 202 and 204 above, and will not be described again here.
[0091] 614. Perform automatic exposure processing on the above face brightness information to identify areas of brightness difference in the face image area.
[0092] 616. Perform automatic white balance processing on the above facial color information to identify color difference areas in the facial image region.
[0093] Steps 614 and 616 are similar to steps 406 and 408 above, and will not be described again here.
[0094] 618. The brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region are weighted and summed to obtain the comprehensive color data.
[0095] 620. If the above comprehensive color data is greater than the target color threshold, the corresponding mask area is determined based on the above brightness difference area and color difference area.
[0096] Steps 618 and 620 are similar to some specific implementations of step 410 described above. In some embodiments, if the comprehensive color data is greater than the target color threshold, the electronic device can determine the mask area in the image to be identified as the intersection of the brightness difference region and the chromaticity difference region, or it can determine the mask area in the image to be identified as the union of the brightness difference region and the chromaticity difference region. For example, the latter case can be as follows... Figure 7 As shown, the electronic device can compare the brightness difference region and the color difference region mentioned above, and take the region where the two overlap as the mask region in the face image region, that is, the mask region in the image to be identified.
[0097] As can be seen, by implementing the face mask recognition method described in the above embodiments, the electronic device can utilize the image brightness and chromaticity information of the image to be recognized to identify the face mask area, thereby determining whether the user is wearing a mask correctly. This not only achieves mask area recognition with less computation, improving the efficiency of face mask recognition by the electronic device, but also minimizes errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by the electronic device. Furthermore, pre-obtaining the target color threshold using sample images can further reduce the computational load in the actual recognition process, improving the efficiency of face mask recognition; simultaneously, the target color threshold obtained in this way has good versatility, effectively handling different scenarios and different mask shapes, which is beneficial to improving the flexibility of face mask recognition by the electronic device.
[0098] The methods in the embodiments of this application have been described in detail above. The apparatus in the embodiments of this application will be described below with reference to the accompanying drawings.
[0099] Please see Figure 8 , Figure 8 This is a modular schematic diagram of a face mask recognition device disclosed in an embodiment of this application. This face mask recognition device can be the aforementioned electronic device, or a device applied within the aforementioned electronic device. For example... Figure 8 As shown, the face mask recognition device may include a first recognition unit 801, an information acquisition unit 802, and a second recognition unit 803, wherein:
[0100] The first recognition unit 801 is used to determine the face image region to be recognized from the image to be recognized;
[0101] The information acquisition unit 802 is used to acquire the face brightness information and face color information corresponding to the face image region.
[0102] The second recognition unit 803 is used to recognize the mask area in the face image area based on the face brightness information and face color information. The mask area is the image area in the image to be recognized where a face is wearing a mask.
[0103] As can be seen, the face mask recognition device described in the above embodiments can utilize the image brightness and chromaticity information of the image to be recognized to identify the mask area within the face image region when a face is present, thereby determining whether the user is wearing a mask. This not only achieves mask area recognition with less computation, but also eliminates the need for extensive model training compared to recognition algorithms based on deep learning models, thus improving the efficiency of face mask recognition by electronic devices. Furthermore, judging based on the brightness and chromaticity information of the face image itself can minimize errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by electronic devices.
[0104] In one embodiment, the second identification unit 803 described above may include a luminance identification subunit (not shown), a chromaticity identification subunit, and a mask area determination subunit, wherein:
[0105] The brightness recognition subunit is used to perform automatic exposure processing on the above-mentioned face brightness information and identify brightness difference areas in the face image area;
[0106] The chromaticity recognition subunit is used to perform automatic white balance processing on the above-mentioned human chromaticity information and identify chromaticity difference areas in the human face image area.
[0107] The mask area determination subunit is used to determine the mask area corresponding to the brightness difference area and the color difference area based on the brightness data of the first area corresponding to the brightness difference area and the color data of the first area corresponding to the color difference area.
[0108] In one embodiment, the brightness recognition subunit described above can be specifically used for:
[0109] Automatic exposure processing is performed on the above face brightness information, and the brightness data corresponding to each pixel in the face image area after automatic exposure processing is obtained.
[0110] Based on the brightness data corresponding to each pixel, a brightness difference region is separated from the above-mentioned face image region. The difference between the brightness data of the first region corresponding to the brightness difference region and the brightness data of the second region corresponding to other regions in the face image region other than the brightness difference region exceeds the first difference threshold.
[0111] The brightness data of the first region is determined by the brightness data of each pixel in the brightness difference region, and the brightness data of the second region is determined by the brightness data of each pixel in other regions.
[0112] In one embodiment, the above-mentioned colorimetric recognition subunit can be specifically used for:
[0113] Automatic white balance processing is performed on the above facial color information, and the color data corresponding to each pixel in the facial image area after automatic white balance processing is obtained.
[0114] Based on the chromaticity data corresponding to each pixel, chromaticity difference regions are separated from the above-mentioned face image region. The difference between the chromaticity data of the first region corresponding to the chromaticity difference region and the chromaticity data of the second region corresponding to other regions in the face image region other than the chromaticity difference region exceeds the second difference threshold.
[0115] The chromaticity data of the first region is determined by the chromaticity data of each pixel in the chromaticity difference region, and the chromaticity data of the second region is determined by the chromaticity data of each pixel in other regions.
[0116] In one embodiment, the aforementioned mask area defining subunit can be specifically used for:
[0117] The brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region are weighted and summed to obtain the comprehensive color data.
[0118] If the overall color data exceeds the target color threshold, the corresponding mask area is determined based on the aforementioned brightness difference area and chromaticity difference area.
[0119] For example, the mask area determination subunit can, when the comprehensive color data is greater than the target color threshold, determine the intersection of the aforementioned brightness difference region and chromaticity difference region as the mask area in the image to be identified; or,
[0120] If the total color data is greater than the target color threshold, the union of the above-mentioned brightness difference region and color difference region is determined as the mask region in the image to be identified.
[0121] As an optional implementation, the aforementioned face mask recognition device may further include a threshold determination unit (not shown). This threshold determination unit can be used before the mask area determination subunit determines the corresponding mask area based on the brightness difference area and the chromaticity difference area, when the overall color data exceeds a target color threshold.
[0122] For at least one sample image, determine the sample face region and sample mask region in each sample image respectively;
[0123] The peak values of brightness difference and chromaticity difference between the face region of each sample and the corresponding mask region were obtained respectively.
[0124] Calculate the mean luminance difference of the peak luminance difference corresponding to each sample image, and the mean chrominance difference of the peak chrominance difference corresponding to each sample image;
[0125] Based on the average values of the brightness difference and the average values of the chromaticity difference, the target color threshold is determined.
[0126] As can be seen, the face mask recognition device described in the above embodiments can identify the face mask area using the image brightness and chromaticity information of the image to be recognized, thereby determining whether the user is wearing a mask correctly. This not only achieves mask area recognition with less computation, improving the efficiency of face mask recognition by electronic devices, but also minimizes errors caused by factors such as mask shape, effectively improving the accuracy of face mask recognition by electronic devices. Furthermore, by analyzing the brightness and chromaticity information of the face, mask areas that are significantly different in brightness and chromaticity from other parts of the face can be accurately identified, which helps improve the accuracy of face mask recognition by electronic devices. In addition, pre-obtaining the target color threshold using sample images can further reduce the computational load in the actual recognition process, improving the efficiency of face mask recognition; at the same time, the target color threshold obtained in this way has good versatility, effectively handling different scenarios and different mask shapes, which helps improve the flexibility of face mask recognition by electronic devices.
[0127] Please see Figure 9 , Figure 9 This is a modular schematic diagram of an electronic device disclosed in an embodiment of this application. For example... Figure 9 As shown, the electronic device may include:
[0128] Memory 901 storing executable program code;
[0129] Processor 902 coupled to memory 901;
[0130] The processor 902 can call the executable program code stored in the memory 901 to execute all or part of the steps in any of the face mask recognition methods described in the above embodiments.
[0131] Furthermore, embodiments of this application disclose a computer-readable storage medium storing a computer program for electronic data interchange, wherein the computer program enables a computer to execute all or part of the steps in any of the face mask recognition methods described in the above embodiments.
[0132] Furthermore, this application further discloses a computer program product that, when run on a computer, enables the computer to execute all or part of the steps in any of the face mask recognition methods described in the above embodiments.
[0133] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. This program can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-erasable programmable read-only memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.
[0134] The foregoing has provided a detailed description of a face mask recognition method, device, electronic device, and storage medium disclosed in the embodiments of this application. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for facial mask recognition, characterized in that, include: From the image to be identified, determine the facial image region to be identified; Obtain the facial brightness information and facial color information corresponding to the facial image region; Automatic exposure processing is performed on the facial brightness information to identify areas of brightness difference in the facial image region; Automatic white balance processing is performed on the facial color information to identify color difference areas in the facial image region; Based on the brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region, a mask region corresponding to the brightness difference region and the chromaticity difference region is determined. The mask region is the image region in the image to be identified where a face is wearing a mask.
2. The method according to claim 1, characterized in that, Automatic exposure processing is performed on the facial brightness information to identify areas of brightness difference in the facial image region, including: Automatic exposure processing is performed on the facial brightness information, and the brightness data corresponding to each pixel in the facial image area after automatic exposure processing is obtained. Based on the brightness data corresponding to each pixel, a brightness difference region is separated from the face image region. The difference between the brightness data of the first region corresponding to the brightness difference region and the brightness data of the second region corresponding to other regions in the face image region, excluding the brightness difference region, exceeds a first difference threshold. The brightness data of the first region is determined by the brightness data corresponding to each pixel in the brightness difference region, and the brightness data of the second region is determined by the brightness data corresponding to each pixel in the other regions.
3. The method according to claim 1, characterized in that, Automatic white balance processing is performed on the facial color information to identify color difference regions in the facial image area, including: Automatic white balance processing is performed on the facial color information, and color data corresponding to each pixel in the facial image area after automatic white balance processing is obtained. Based on the chromaticity data corresponding to each pixel, chromaticity difference regions are separated from the face image region. The difference between the chromaticity data of the first region corresponding to the chromaticity difference region and the chromaticity data of the second region corresponding to other regions in the face image region, excluding the chromaticity difference region, exceeds a second difference threshold. The chromaticity data of the first region is determined by the chromaticity data corresponding to each pixel in the chromaticity difference region, and the chromaticity data of the second region is determined by the chromaticity data corresponding to each pixel in the other regions.
4. The method according to claim 1, characterized in that, Based on the brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region, the mask region corresponding to the brightness difference region and the chromaticity difference region is determined, including: The brightness data of the first region corresponding to the brightness difference region and the chromaticity data of the first region corresponding to the chromaticity difference region are weighted and summed to obtain comprehensive color data. If the overall color data is greater than the target color threshold, the corresponding mask area is determined based on the brightness difference area and the chromaticity difference area.
5. The method according to claim 4, characterized in that, When the overall color data exceeds the target color threshold, the corresponding mask area is determined based on the brightness difference area and the chromaticity difference area, including: If the total color data exceeds the target color threshold, the intersection of the brightness difference region and the chromaticity difference region is determined as the mask region in the image to be identified; or, If the total color data is greater than the target color threshold, the union of the brightness difference region and the chromaticity difference region is determined as the mask region in the image to be identified.
6. The method according to claim 4, characterized in that, Before determining the corresponding mask area based on the brightness difference area and the chromaticity difference area when the overall color data is greater than the target color threshold, the method further includes: For at least one sample image, determine the sample face region and sample mask region in each of the sample images; The peak values of brightness difference and chromaticity difference between each sample face region and the corresponding sample mask region are obtained respectively; Calculate the mean luminance difference of the luminance difference peaks corresponding to each of the sample images, and the mean chromaticity difference of the chromaticity difference peaks corresponding to each of the sample images; The target color threshold is determined based on the average brightness difference and the average chromaticity difference.
7. A face mask recognition device, characterized in that, include: The first recognition unit is used to determine the face image region to be recognized from the image to be recognized; The information acquisition unit is used to acquire the face brightness information and face color information corresponding to the face image region; The second recognition unit includes a luminance recognition subunit, a chromaticity recognition subunit, and a mask area determination subunit; The brightness recognition subunit is used to perform automatic exposure processing on the face brightness information and identify brightness difference areas in the face image area; The colorimetric recognition subunit is used to perform automatic white balance processing on the human face colorimetric information and identify colorimetric difference regions in the face image area; The mask area determination subunit is used to determine the mask area corresponding to the brightness difference area and the color difference area based on the brightness data of the first area corresponding to the brightness difference area and the color data of the first area corresponding to the color difference area. The mask area is the image area in the image to be identified where a face is wearing a mask.
8. An electronic device, characterized in that, The system includes a memory and a processor, wherein the memory stores a computer program that, when executed by the processor, causes the processor to perform the method as described in any one of claims 1 to 6.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 6.
Citation Information
Patent Citations
Mask wearing recognition method, device and equipment and readable storage medium
CN111523473A