Skin color detection method, device, mobile terminal and storage medium
By combining the mapping functions of color values and brightness values, and combining face and head data for skin color detection, the problem of real-time and accuracy of skin color detection in mobile terminal devices is solved, and high accuracy and fast skin color detection effects are achieved.
Patent Information
- Application Number
- CN202011566266.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-12-25
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2040-12-25
AI Technical Summary
Existing skin color detection technology is difficult to take into account real-time and accuracy in mobile terminal devices. The color space-based methods are fast but have low accuracy. However, the machine learning and deep learning methods have a large performance bottleneck in real-time stream processing and are difficult to apply. .
Skin color detection is performed using a mapping function combining color value and brightness value. By detecting the head data matching the face data and head contour, the first and second mapping functions are generated, which are used to identify skin data based on color value and brightness value respectively. , and combined with both, the detection enriches the dimension of skin tone detection.
High-accurate skin tone detection is achieved in mobile terminal devices, simplifying calculation amount and time-consuming, ensuring real-time and accuracy, and suitable for real-time processing of video data.
Smart Images

Figure CN112686965B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the technical field of computer vision, and in particular to a skin color detection method, device, mobile terminal and storage medium. Background Art
[0002] With the rapid development of mobile Internet and mobile terminals, video data in mobile terminals have become a common information carrier in human activities, such as live broadcasts and video calls. They contain a lot of information about objects and have become one of the ways for people to obtain original information from the outside world.
[0003] For these video data, users usually choose beauty filtering. Skin color detection is the basis of beauty filtering, which determines whether beauty filtering can realize real-time processing of video data and also determines the quality of beauty filtering effect.
[0004] The existing mainstream skin color detection can be divided into skin color detection based on color space, skin color detection based on machine learning classification, and skin color detection based on deep learning image segmentation.
[0005] Among them, skin color detection based on color space is widely used in the field of real-time stream processing due to its fast and efficient characteristics, but its accuracy is low. Skin color detection based on machine learning classification and skin color detection based on deep learning image segmentation have higher accuracy, but performance often becomes a bottleneck in real-time stream processing, and it is difficult to apply to situations where devices are limited, such as mobile terminals. Summary of the invention
[0006] The embodiments of the present invention provide a skin color detection method, device, mobile terminal and storage medium to solve the problem of how to balance the real-time performance and accuracy of skin color detection under limited performance.
[0007] In a first aspect, an embodiment of the present invention provides a skin color detection method, comprising:
[0008] Detecting face data in the image data, and dividing head data matching the head contour with reference to the face data;
[0009] Substituting the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data;
[0010] generating a second mapping function with reference to the brightness value of the head data, wherein the second mapping function is used to identify the skin data based on the brightness value;
[0011] Substituting the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data;
[0012] Skin data is detected in the image data by combining the first target probability with the second target probability.
[0013] In a second aspect, an embodiment of the present invention further provides a skin color detection device, comprising:
[0014] An image data detection module, used to detect face data in the image data, and divide head data matching the head contour with reference to the face data;
[0015] A first target probability calculation module, used for substituting the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data;
[0016] A mapping function generating module, used to generate a second mapping function with reference to the brightness value of the head data, wherein the second mapping function is used to identify the skin data based on the brightness value;
[0017] A second target probability calculation module, used for substituting the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data;
[0018] A skin detection module is used to detect skin data in the image data by combining the first target probability and the second target probability.
[0019] In a third aspect, an embodiment of the present invention further provides a mobile terminal, the mobile terminal comprising:
[0020] one or more processors;
[0021] a memory for storing one or more programs,
[0022] When the one or more programs are executed by the one or more processors, the one or more processors implement the skin color detection method as described in the first aspect.
[0023] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the skin color detection method as described in the first aspect is implemented.
[0024] In this embodiment, face data is detected in the image data, head data matching the head contour is divided with reference to the face data, the color value of the image data is substituted into the first mapping function to calculate the first target probability that the image data belongs to the skin data, the second mapping function is generated with reference to the brightness value of the head data, the second mapping function is used to identify the skin data based on the brightness value, the brightness value of the image data is substituted into the second mapping function to calculate the second target probability that the image data belongs to the skin data, and the skin data is detected in the image data in combination with the first target probability and the second target probability. Face data can reflect the spatial position information of the user's head to a certain extent, and the head data is described based on face data to ensure the accuracy of the head data. As an anchor point, it can capture high-quality skin data and its close non-skin data, and can count relatively accurate brightness values for skin data in the current business scenario, so as to adaptively generate the second mapping function, which can ensure the accuracy of skin color detection by the second mapping function in the current business scenario. Moreover, skin color detection is combined in the two dimensions of color and brightness, which enriches the dimensions of skin color detection and thus improves the accuracy of skin color detection. In addition, operations such as face detection, drawing head data, counting color values and brightness values, generating the first mapping function and the second mapping function and their application are relatively simple, with less calculation, fast speed and short time. When the performance of devices such as mobile terminals is limited, real-time skin color detection can be achieved for video data. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] Figure 1 A flowchart of a skin color detection method provided in Embodiment 1 of the present invention;
[0026] Figure 2 This is an example diagram of header data provided in Embodiment 1 of the present invention;
[0027] Figure 3 is a schematic diagram of a first mapping function provided in Embodiment 1 of the present invention;
[0028] Figure 4 is a schematic diagram of a second mapping function provided in Embodiment 1 of the present invention;
[0029] Figure 5 A probability distribution diagram of skin color detection provided in the first embodiment of the present invention;
[0030] Figure 6 A schematic diagram of the structure of a skin color detection device provided in Embodiment 2 of the present invention;
[0031] Figure 7 A schematic diagram of the structure of a mobile terminal provided in Embodiment 3 of the present invention. DETAILED DESCRIPTION
[0032] The present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It should also be noted that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0033] Embodiment 1
[0034] Figure 1 This is a flow chart of a skin color detection method provided in Embodiment 1 of the present invention. This embodiment is applicable to the case where skin color detection is performed in combination with color value and brightness value. The method can be executed by a skin color detection device, which can be implemented by software and / or hardware and can be configured in a mobile terminal, such as a mobile phone, a tablet computer, a smart wearable device (such as a smart watch, smart glasses, etc.), etc., and specifically includes the following steps:
[0035] Step 101: Detect face data in image data, and divide head data matching the head contour with reference to the face data.
[0036] In this embodiment, the video data waiting for skin color detection generally refers to video data generated, transmitted or played in a real-time business scenario.
[0037] Generally speaking, skin color detection may be performed on the video data in a mobile terminal that generates the video data. At this time, a camera of the mobile terminal may be turned on to collect the video data.
[0038] Of course, in addition to performing skin color detection on the video data in the mobile terminal that generates the video data, skin color detection may also be performed on the video data in the mobile terminal that plays the video data, and this embodiment does not impose any limitation on this.
[0039] For example, in a live broadcast business scenario, the video data waiting for skin color detection may refer to the video data used to carry the live broadcast content. The mobile terminal logged in by the anchor user generates the video data, and the video data is distributed through the live broadcast platform to the devices logged in by each audience user for playback. At this time, skin color detection is usually performed on the mobile terminal logged in by the anchor user.
[0040] For another example, in a business scenario of a video call, the video data waiting for skin color detection may refer to the video data used to carry the content of the call. The mobile terminal logged in by the user initiating the call generates the video data, and the video data is sent to the devices logged in by each user invited to the call for playback. At this time, the mobile terminal logged in by the user initiating the call usually performs skin color detection on the video data.
[0041] For another example, in a business scenario of video conferencing, video data waiting for skin color detection may refer to video data used to carry conference content. The mobile terminal logged in by the user who is speaking generates the video data, and the video data is sent to the devices logged in by each user participating in the conference for playback. At this time, the mobile terminal logged in by the user who is speaking usually performs skin color detection on the video data.
[0042] Of course, the video data waiting for skin color detection may also refer to video data generated in business scenarios with lower real-time requirements, such as short videos, etc. This embodiment does not impose any restrictions on this.
[0043] In different business scenarios, video data is usually collected of users. Therefore, the multiple frames of image data in the video data usually contain the user's character image. The so-called character image may refer to the pixel points used to represent the character in the image data.
[0044] The character image at least includes facial data (pixels) for representing the face. In addition, it may also include hair data (pixels) for representing hair, body data (pixels) for representing the torso, limb data (pixels) for representing limbs, and so on. The embodiment of the present invention is not limited to this.
[0045] Among them, face data, body data, limb data, etc. may include skin data (pixel points) for representing the skin.
[0046] In this embodiment, face detection can be performed on multiple frames of image data respectively to identify the face data contained in the image data. The face data is used as a high-quality anchor point to capture high-quality skin data.
[0047] In some cases, facial data is represented by facial key points, that is, given facial data, the key areas of the face are located, including eyebrows, eyes, nose, mouth, facial contours, etc.
[0048] In other cases, a range of a specified shape may be generated based on facial key points, and the facial data may be represented by the range, wherein the shape includes a rectangle, an ellipse, etc. The rectangular range may also be referred to as a face frame.
[0049] In the specific implementation, the following method can be used to perform face detection on multi-frame image data:
[0050] 1. Use artificially extracted features, such as Haar features, use the features to train classifiers, and use the classifiers for face detection.
[0051] 2. Inherit face detection from general object detection algorithms, for example, using Faster R-CNN to detect faces.
[0052] 3. Use cascaded convolutional neural networks, for example, Cascade CNN (Cascaded Convolutional Neural Networks), MTCNN (Multi-task Cascaded Convolutional Networks).
[0053] These methods for implementing face detection can be integrated into the application module, and the application module can be directly called to perform face detection on image data. These methods for implementing face detection can also be integrated into the SDK (Software Development Kit). The SDK serves as the assembly data of the application. The application can request the SDK to perform face detection on multiple frames of image data. The SDK detects the face data in the image data and returns the face data to the application.
[0054] If the application is a system application supporting the camera, the system application usually provides an API (Application Program Interface) as a face detection interface for these methods of implementing face detection. For example, in the Android system, two face detection interfaces android.media.FaceDetector and android.media.FaceDetector.Face are provided. In the iOS system, two face detection interfaces AVCaptureMetadataOutput and CIDetector are provided.
[0055] In this case, the face detection interface provided by the camera can be called to request the detection of face data in the multiple frames of image data captured by the camera, and receive one or more face frames returned by the face detection interface. The face frame is a rectangular frame that can be used to frame the face data, that is, the face data is located in the face frame.
[0056] The face detection interface provided by the system application has hardware support, and the face frame is calibrated based on a few face key points (2 face key points). It has fast speed, low performance consumption, and the accuracy can meet the requirements.
[0057] Since facial data can reflect the spatial position information of the user's head to a certain extent, in this embodiment, the position, shape and other information of the facial data can be referred to, and the head data that matches the head contour can be divided out in the image data, thereby improving the accuracy of expressing the head, face and other parts.
[0058] As for the head contour, the facial data is different when facing the front and the side, and can show the hair, face shape, ears, nose, mouth and other parts. Correspondingly, the head data can reflect these parts in shape.
[0059] Furthermore, in order to reduce the complexity of fitting the head data, improve the speed of calculation, and reduce the time consumption of calculation, the shape of the head data can be simplified and fitted into a standard shape, for example, the shape of the head data can be fitted into an ellipse, a circle, etc.
[0060] In the first embodiment of the present invention, Figure 2 As shown, the head data includes face data 202 and hair data 203, wherein the face data 202 is similar to the face outline in the head outline and mainly includes the face, and the hair data 203 is similar to the hair outline in the head outline and mainly includes the hair.
[0061] On the one hand, if Figure 2 As shown, with reference to information such as the shape and position of the face data 201, face data 202 matching the face outline in the head outline is divided in the image data.
[0062] In one example, for face data returned by a camera, if the face data is framed by a face frame, the face data meets the following conditions:
[0063] The shape of the face data is an ellipse;
[0064] The focal point of the face data is the wide midpoint of the face frame;
[0065] The length of the short axis of the facial data is equal to the width in the face frame;
[0066] The length of the major axis of the facial data is equal to n (n is a positive number, such as 2) times the length of the target side. The target length is the hypotenuse corresponding to the first candidate side and the second candidate side when they are right-angled sides. The first candidate side is the specified first ratio of the width in the face frame, and the second candidate side is the specified second ratio of the width in the face frame.
[0067] In this example, the width of the face frame is , Gao Wei , the four foci are A(x1, y1), B(x2, y2), C(x3, y3), and D(x4, y4). The foci of the facial data are F1((x1+ x2) / 2, (y1+ y2) / 2,), F2((x3+ x4) / 2, (y3+y4) / 2,), and the length of the short axis of the facial data is , the length of the major axis of the face data is ,in, is the first ratio, which is a positive number less than or equal to 1, such as 0.5. is the first ratio, which is a positive number less than or equal to 1, such as 0.5.
[0068] On the other hand, Figure 2 As shown, with reference to information such as the shape and position of the face data 201, hair data 203 matching the hair contour in the head contour is divided in the image data.
[0069] It should be noted that, in the head data, the hair data surrounds the facial data, and the two are independent of each other and do not overlap.
[0070] In one example, for face data called back by a certain camera, if the face data is framed by a face frame, the hair data meets the following conditions:
[0071] The shape of the hair data is an ellipse;
[0072] The focal point of the hair data is the wide midpoint of the face frame;
[0073] The length of the short axis of the hair data is equal to m times the width of the face frame (m is a positive number, indicating that the hair data is magnified m times the face data);
[0074] The length of the major axis of the hair data is equal to n×m times the length of the target edge. The target length is the hypotenuse corresponding to the first candidate edge and the second candidate edge when they are right-angled edges. The first candidate edge is the specified first ratio of the width in the face frame, and the second candidate edge is the specified second ratio of the width in the face frame.
[0075] In this example, the width of the face frame is , Gao Wei , the four foci are A(x1, y1), B(x2, y2), C(x3, y3), and D(x4, y4). The foci of the facial data are F1((x1+ x2) / 2, (y1+ y2) / 2,), F2((x3+ x4) / 2, (y3+y4) / 2,), and the length of the short axis of the facial data is , the length of the major axis of the face data is ,in, is the first ratio, which is a positive number less than or equal to 1, such as 0.5. is the first ratio, which is a positive number less than or equal to 1, such as 0.5.
[0076] Furthermore, m can be a preset empirical value, which is a constant, or m can be an adaptive variable, which is positively correlated with the area of the facial data. That is, the larger the area of the facial data, the larger the area of the hair data. In this case, the larger the value of m is. Conversely, the smaller the area of the facial data, the smaller the area of the hair data. In this case, the smaller the value of m is.
[0077] Of course, the above-mentioned head data and its division method are only used as examples. The face data called back by cameras of different operating systems and different versions are different. When implementing the embodiment of the present invention, other head data and its division method can be set according to actual conditions, and the embodiment of the present invention does not limit this. In addition, in addition to the above-mentioned head data and its division method, those skilled in the art can also use other head data and its division method according to actual needs, and the embodiment of the present invention does not limit this.
[0078] Generally, facial data may include forehead, eyes, nose, mouth, cheeks, ears and other parts, and hair data may include hair and other parts. When simplifying facial data, facial data may include not only forehead, eyes, nose, mouth, cheeks, ears and other parts, but also partial hair, background and other data. Hair data may include not only hair and other parts, but also partial forehead, partial ears, partial chin, neck, background and other data.
[0079] In addition, if there are multiple face data in the image data, the areas of the multiple face data are counted respectively. If the face data is framed by a face frame, the width of the face frame is , Gao Wei , then the area of the face data .
[0080] The areas of each face data are compared, and the k (k is a positive integer, such as 3) face data with the largest areas are extracted. The head data that matches the head contour is divided with reference to the k face data with the largest areas. Due to the imaging characteristics of the camera and the method of recalling face data, the color description of face data with a larger area is more accurate. The k face data with the largest areas are selected to divide the head data that matches the head contour, which can reduce the amount of calculation and ensure the accuracy of the brightness value of the subsequent statistical skin data.
[0081] Of course, when there are multiple face data in the image data, all the face data may be divided into head data matching the head contour, and this embodiment does not impose any limitation on this.
[0082] Step 102: Substitute the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data.
[0083] In this embodiment, a first mapping function can be set by counting the color values of pixels in different samples such as skin data and non-skin data. The first mapping function can be used to identify skin data based on color values, that is, the input of the first mapping function is the color value, and the output is the probability of belonging to skin data. At this time, the probability that the pixels in different samples are skin data at a certain color value can be counted, so as to fit these color values and their probabilities into the first mapping function.
[0084] In order to maintain universality, the first mapping function may refer to skin data of users of different races, different age groups, and different skin colors, and may also refer to skin data under different lighting conditions. Therefore, the first mapping function is relatively broad and relatively accurate.
[0085] Generally, the probability of skin data in the first mapping function is a continuous value, such as [0-1]. In some cases, the probability of skin data in the first mapping function is a discrete value, such as 0 or 1, which is not limited in this embodiment.
[0086] In one example, if Figure 3 As shown, in the coordinate system where the first mapping function is located, the abscissa (horizontal axis) is the color value (X), and the ordinate (vertical axis) is the probability (P) of belonging to skin data.
[0087] The first mapping function includes a first color mapping segment (with a horizontal coordinate of [x0, x1]), a second color mapping segment (with a horizontal coordinate of [x1, x2]), and a third color mapping segment (with a horizontal coordinate of [x2, x3]), which are connected in sequence, wherein the probability of belonging to skin data in the first color mapping segment increases from 0 to 1, the probability of belonging to skin data in the second color mapping segment is 1, and the probability of belonging to skin data in the third color mapping segment decreases from 1 to 0.
[0088] Furthermore, the second color mapping segment is a line segment, and the first color mapping segment and the third color mapping segment are curves, which can be fitted by using a polynomial function or the like.
[0089] Of course, the above-mentioned first mapping function is only used as an example. When implementing the embodiment of the present invention, other first mapping functions can be set according to actual conditions. For example, the mapping function includes a first color mapping segment and a second color mapping segment connected in sequence, wherein the probability of belonging to skin data in the first color mapping segment increases from 0 to 1, and the probability of belonging to skin data in the second color mapping segment decreases from 1 to 0. At this time, the mapping function is expressed by a function such as a quadratic equation, etc., and the embodiment of the present invention does not limit this. In addition, in addition to the above-mentioned first mapping function, those skilled in the art can also adopt other first mapping functions according to actual needs, and the embodiment of the present invention does not limit this.
[0090] It should be noted that in different color spaces, color values have different chromaticity components, and a corresponding mapping function can be set for each color component. For example, in the RGB color space, there are red chromaticity components (R), blue chromaticity components (G), and green chromaticity components (B). Then, a mapping function can be set for the red chromaticity component (R), a mapping function can be set for the blue chromaticity component (G), and a mapping function can be set for the green chromaticity component (B). For another example, in the YCbCr color space, there are blue chromaticity components (Cb) and red chromaticity components (Cr). Then, a mapping function can be set for the blue chromaticity component (Cb), and a mapping function can be set for the red chromaticity component (Cr), and so on.
[0091] In this embodiment, the first mapping function may be applied to perform skin color detection on the image data, thereby detecting the degree to which each pixel in the image data represents the skin data in the dimension of color value.
[0092] Furthermore, the color value of each pixel of the image data can be marked on the horizontal axis in the coordinate system where the first mapping function is located. If the color value of the pixel in the image data is outside the first mapping function, the probability that the pixel belongs to the skin data is 0. If the color value of the pixel in the image data is within the first mapping function, the first mapping function can be used to find the probability corresponding to the color value on the vertical axis as the first target probability that the pixel belongs to the skin data.
[0093] In some cases, the horizontal axis of the mapping function is the color value and the vertical axis is the probability of belonging to the skin data. In different color spaces, the color value has different chromaticity components, and each color component has a corresponding mapping function. Different probabilities can be calculated for the same pixel.
[0094] In this case, the color value of each pixel in the image data can be queried, and the color value can be substituted into the corresponding first mapping function to map it into the candidate probability that the pixel belongs to skin data under the color value. Based on these candidate probabilities, the first target probability that the pixel belongs to skin data can be calculated by averaging, summing, multiplying, linear fusion (that is, summing after configuring weights), etc. These first target probabilities reflect the ROI (region of interest) area of the skin color under the dimension of color value.
[0095] In one example, for the YCbCr color space, the image data has a blue chrominance component Cb and a red chrominance component Cr.
[0096] On the one hand, the color value of the blue chromaticity component Cb is substituted into the first mapping function corresponding to the blue chromaticity component Cb to map the blue probability of the pixel belonging to the skin data under the blue chromaticity component Cb as the candidate probability .
[0097] On the other hand, the color value of the red chromaticity component Cr is substituted into the first mapping function corresponding to the red chromaticity component Cr to map the red probability of the pixel belonging to the skin data under the red chromaticity component Cr as the candidate probability .
[0098] At this point, the blue probability can be calculated With red probability The product between them is used as the first target probability that the pixel belongs to the skin data .
[0099] Step 103: Generate a second mapping function with reference to the brightness value of the header data.
[0100] If face data is detected in the image data, the face data can be corrected to obtain head data, and the brightness value can be counted within the range of the head data. The brightness value is the brightness value of the skin data with a high confidence level, and can be used to generate a second mapping function for the current user, thereby improving the accuracy of the second mapping function for the current user. That is, in this embodiment, the second mapping function can be set by the brightness value of the head data, and the second mapping function can be used to identify skin data based on the brightness value, that is, the input of the mapping function is the brightness value, and the output is the probability of belonging to the skin data. At this time, the probability that the pixel points of the head data are skin data at a certain brightness value can be counted, so as to fit these brightness values and their probabilities into the second mapping function.
[0101] Generally, the probability of skin data in the second mapping function is a continuous value, such as [0-1]. In some cases, the probability of skin data in the second mapping function is a discrete value, such as 0 or 1, which is not limited in this embodiment.
[0102] In one example, if Figure 4 As shown, in the coordinate system where the second mapping function is located, the abscissa (horizontal axis) is the brightness value (X), and the ordinate (vertical axis) is the probability (P) of belonging to skin data.
[0103] The second mapping function includes a first brightness mapping segment (with a horizontal coordinate of [x0, x1]) and a second brightness mapping segment (with a horizontal coordinate of [x1, x2]) connected in sequence, wherein the probability of belonging to skin data in the first brightness mapping segment increases from 0 to 1, and the probability of belonging to skin data in the second brightness mapping segment is 1.
[0104] Furthermore, the second brightness mapping segment is a line segment, and the first brightness mapping segment is a curve, which can be fitted by using a polynomial function or the like.
[0105] Of course, the above second mapping function is only used as an example. When implementing the embodiment of the present invention, other second mapping functions can be set according to actual conditions. For example, the second mapping function includes a first brightness mapping segment, a second brightness mapping segment, and a third brightness mapping segment connected in sequence, wherein the first brightness mapping segment refers to the pixel fitting in the hair data, and its probability of belonging to the skin data increases from 0 to 1, the second brightness mapping segment refers to the pixel fitting in the skin color range in the face data, and its probability of belonging to the skin data is 1, the third brightness mapping segment refers to the pixel fitting in the non-skin color range (such as glasses, teeth, eyebrows, etc.) in the face data, and its probability of belonging to the skin data decreases from 1 to 0, and so on. The embodiment of the present invention does not limit this. In addition, in addition to the above second mapping function, those skilled in the art can also adopt other second mapping functions according to actual needs, and the embodiment of the present invention does not limit this.
[0106] In a fitting manner, if the head data includes face data matching the face outline in the head outline and hair data matching the hair outline in the head outline, in the face data, the probability that the pixel belongs to the skin data is high, and in the hair data, the probability that the pixel belongs to the skin data is low. If the brightness value of the face data is greater than the brightness value of the hair data, then the brightness value can be used to suppress skin color detection.
[0107] On the one hand, the brightness value of the hair data is counted as the first reference brightness value. In the brightness value-probability coordinate system, the probability that the first reference brightness value belongs to the skin data is 0.
[0108] On the other hand, the brightness values of the face data and the hair data are counted as the second reference brightness value. In the brightness value-probability coordinate system, the probability that the second reference brightness value belongs to the skin data is 1.
[0109] At this time, in the first brightness mapping segment, a curve can be fitted with the first reference brightness value as the starting point and the second reference brightness value as the end point, and in the second brightness mapping segment, a straight line can be fitted with the second reference brightness value as the starting point, thereby generating a second mapping function.
[0110] In addition, when the facial data is an ellipse, the operation of performing statistical brightness values on the pixels in the ellipse is more complicated, while the facial data is mostly framed by a face frame, which is a rectangle. The operation of performing statistical brightness values on the pixels in the rectangle is relatively simple, and the difference between the two is small. Therefore, the facial data can be used to replace the face data, which can improve the ease of operation, increase the speed of calculation, and reduce the time spent on calculation while maintaining a certain degree of accuracy.
[0111] Specifically, on the one hand, the brightness value of the hair data is counted as the first reference brightness value, and in the brightness value-probability coordinate system, the probability that the first reference brightness value belongs to the skin data is 0. On the other hand, the brightness values of the face data and the hair data are counted as the second reference brightness value, and in the brightness value-probability coordinate system, the probability that the second reference brightness value belongs to the skin data is 1.
[0112] At this time, in the first brightness mapping segment, a curve can be fitted with the first reference brightness value as the starting point and the second reference brightness value as the end point, and in the second brightness mapping segment, a straight line can be fitted with the second reference brightness value as the starting point, thereby generating a second mapping function.
[0113] Step 104: Substitute the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data.
[0114] In this embodiment, the second mapping function may be applied to perform skin color detection on the image data, thereby detecting the degree to which each pixel in the image data represents skin data in the dimension of brightness value.
[0115] Furthermore, the brightness value of each pixel in the image data can be queried, and the brightness value can be substituted into the second mapping function to map it into the second target probability that the pixel belongs to the skin data. That is, the horizontal axis in the coordinate system where the second mapping function is located marks the brightness value of each pixel of the image data. If the brightness value of the pixel in the image data is outside the second mapping function, the probability that the pixel belongs to the skin data is 0. If the brightness value of the pixel in the image data is within the second mapping function, the second mapping function can be used to find the probability corresponding to the brightness value on the vertical axis as the second target probability that the pixel belongs to the skin data.
[0116] Step 105: Detect skin data in the image data by combining the first target probability and the second target probability.
[0117] For the same frame of image data, the first target probability in the dimension of color value and the second target probability in the dimension of brightness value can be combined by averaging, summing, multiplying, linear fusion (i.e., summing after configuring weights) to perform skin color detection on the target data, thereby detecting the degree to which pixels in the image data represent skin data.
[0118] In one example, it can be considered that both the color value and the brightness value are more important. At this time, for the same pixel in the image data, the product of the first target probability and the second target probability is calculated as the third target probability that the pixel belongs to the skin data. When the first target probability in the dimension of color value and the second target probability in the dimension of brightness value are both large, the value of the third target probability obtained by multiplying the two is large. When one of the first target probability in the dimension of color value and the second target probability in the dimension of brightness value is large and the other is small, the value of the third target probability obtained by multiplying the two is small.
[0119] In addition, if face data has not been detected in advance, skin data can be detected in the image data based on the color space. The method based on the color space is simple to calculate, so it is fast and time-saving. Statistical color values of multiple skin data can maintain a high degree of accuracy overall and meet the requirements of prior knowledge.
[0120] Since the color space of image data is different, for different color spaces, the method corresponding to the color space can be used to detect skin data in the face data, or the image data can be converted to a specified color space and the method corresponding to the specified color space can be used to detect skin data in the face data. This embodiment does not limit this.
[0121] In an example, for the RGB color space, when the color value of a pixel meets the following conditions, the pixel can be considered to be skin data (i.e., the probability that the pixel belongs to skin data is 1); otherwise, the pixel can be considered not to be skin data (i.e., the probability that the pixel belongs to skin data is 0):
[0122]
[0123]
[0124]
[0125] in, Indicates taking the maximum value, Indicates taking the minimum value, Indicates taking the absolute value.
[0126] In another example, for the YCbCr color space, when the color value of a pixel meets the following conditions, the pixel can be considered to be skin data (i.e., the probability that the pixel belongs to skin data is 1); otherwise, the pixel can be considered not to be skin data (i.e., the probability that the pixel belongs to skin data is 0):
[0127]
[0128]
[0129]
[0130] In order to enable those skilled in the art to better understand the embodiment of the present invention, the skin color detection method in the present embodiment is described below by using specific examples.
[0131] like Figure 5 As shown, for the same frame of image data, the left side is the probability distribution obtained by using skin color detection based on color space, and the right side is the probability distribution obtained by applying this embodiment to perform skin color detection, wherein the higher the grayscale of the pixel (the more white it is), the higher the probability that the pixel belongs to skin data, and the lower the grayscale (the more black it is), the lower the probability that the pixel belongs to skin data.
[0132] Because factors such as lighting, skin color, and hair color are mixed when collecting image data, the color values of the hair and non-skin-colored areas on the face are closer to the skin-colored areas, which makes it easier to misdetect in the color dimension. However, there are large differences in brightness values between the hair and non-skin-colored areas on the face and the skin-colored areas.
[0133] When skin color detection is performed based on color space, hair, non-skin color areas on the face (such as eyebrows, eyes, nose, mouth, etc.), and background (such as electric lights, etc.) are mostly considered to belong to skin data. However, this embodiment can effectively exclude hair, non-skin color areas on the face (such as eyebrows, eyes, nose, mouth, etc.), and background (such as electric lights, etc.), thereby greatly improving the accuracy of skin color detection. In subsequent beautification processing (such as skin resurfacing), hair, non-skin color areas on the face (such as eyebrows, eyes, nose, mouth, etc.), and background (such as electric lights, etc.) can be well protected.
[0134] In this embodiment, face data is detected in the image data, head data matching the head contour is divided with reference to the face data, the color value of the image data is substituted into the first mapping function to calculate the first target probability that the image data belongs to the skin data, the second mapping function is generated with reference to the brightness value of the head data, the second mapping function is used to identify the skin data based on the brightness value, the brightness value of the image data is substituted into the second mapping function to calculate the second target probability that the image data belongs to the skin data, and the skin data is detected in the image data in combination with the first target probability and the second target probability. Face data can reflect the spatial position information of the user's head to a certain extent, and the head data is described based on face data to ensure the accuracy of the head data. As an anchor point, it can capture high-quality skin data and its close non-skin data, and can count relatively accurate brightness values for skin data in the current business scenario, so as to adaptively generate the second mapping function, which can ensure the accuracy of skin color detection by the second mapping function in the current business scenario. Moreover, skin color detection is combined in the two dimensions of color and brightness, which enriches the dimensions of skin color detection and thus improves the accuracy of skin color detection. In addition, operations such as face detection, drawing head data, counting color values and brightness values, generating the first mapping function and the second mapping function and their application are relatively simple, with less calculation, fast speed and short time. When the performance of devices such as mobile terminals is limited, real-time skin color detection can be achieved for video data.
[0135] Furthermore, while improving the accuracy of skin color detection, some data with color values similar to skin data, such as hair, non-skin color areas of the face, background, etc., can be excluded, so that data with colors similar to skin data can be protected in subsequent beautification processing (such as skin resurfacing), and the situation in which the clarity of data similar to skin data is reduced due to beautification processing (such as skin resurfacing) can be slowed down or avoided, thereby ensuring the quality of the beautification processing.
[0136] It should be noted that, for the sake of simplicity, the method embodiments are described as a series of action combinations, but those skilled in the art should be aware that the embodiments of the present invention are not limited by the order of the actions described, because according to the embodiments of the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions involved are not necessarily required by the embodiments of the present invention.
[0137] Embodiment 2
[0138] Figure 6 This is a structural block diagram of a skin color detection device provided in Embodiment 2 of the present invention, which may specifically include the following modules:
[0139] An image data detection module 601 is used to detect face data in the image data and divide the head data matching the head contour with reference to the face data;
[0140] A first target probability calculation module 602, configured to substitute the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data;
[0141] A mapping function generating module 603, used to generate a second mapping function with reference to the brightness value of the head data, wherein the second mapping function is used to identify the skin data based on the brightness value;
[0142] A second target probability calculation module 604, configured to substitute the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data;
[0143] The skin detection module 605 is configured to detect skin data in the image data by combining the first target probability and the second target probability.
[0144] In one embodiment of the present invention, the image data detection module 601 includes:
[0145] A face detection interface calling module, used to call the face detection interface provided by the camera to request detection of face data in the image data collected by the camera;
[0146] The face frame receiving module is used to receive one or more face frames returned by the face detection interface, and the face frames are used to frame face data.
[0147] In one embodiment of the present invention, the head data includes face data and hair data; the image data detection module 601 includes:
[0148] A facial data division module, used for dividing facial data matching the facial contour in the head contour with reference to the human face data;
[0149] The face data division module is used to divide the hair data matching the hair contour in the head contour by referring to the face data, wherein the hair data surrounds the face data.
[0150] In an example of an embodiment of the present invention, if the face data is framed by a face frame, the face data meets the following conditions:
[0151] The shape of the facial data is an ellipse;
[0152] The focus of the facial data is the midpoint of the width of the face frame;
[0153] The length of the short axis of the facial data is equal to the width in the face frame;
[0154] The length of the major axis of the facial data is equal to n times the length of the target side, the target length is the hypotenuse corresponding to the first candidate side and the second candidate side when they are right-angled sides, the first candidate side is a specified first proportion of the width in the face frame, and the second candidate side is a specified second proportion of the width in the face frame.
[0155] In an example of an embodiment of the present invention, if the face data is framed by a face frame, the hair data meets the following conditions:
[0156] The shape of the hair data is an ellipse;
[0157] The focus of the hair data is the midpoint of the width of the face frame;
[0158] The length of the short axis of the hair data is equal to m times the width in the face frame, and m is positively correlated with the area of the face data;
[0159] The length of the major axis of the hair data is equal to n×m times the length of the target side, the target length is the hypotenuse corresponding to the first candidate side and the second candidate side when they are right-angled sides, the first candidate side is a specified first ratio of the width in the face frame, and the second candidate side is a specified second ratio of the width in the face frame.
[0160] In one embodiment of the present invention, the image data detection module 601 includes:
[0161] An area statistics module, for respectively counting the areas of a plurality of face data if there are a plurality of face data in the image data;
[0162] The area selection module is used to divide the head data matching the head contour by referring to the k face data with the largest areas.
[0163] In one embodiment of the present invention, the abscissa of the first mapping function is the color value, and the ordinate is the probability of belonging to skin data;
[0164] The first mapping function includes a first color mapping segment, a second color mapping segment, and a third color mapping segment connected in sequence, the probability of the first color mapping segment belonging to skin data increases from 0 to 1, the probability of the second color mapping segment belonging to skin data is 1, and the probability of the third color mapping segment belonging to skin data decreases from 1 to 0.
[0165] In one embodiment of the present invention, the first target probability calculation module 602 includes:
[0166] A color value query module, used to query the color value of each pixel in the image data;
[0167] A candidate probability mapping module, used for substituting the color value into the first mapping function to map it into a candidate probability that the pixel point belongs to skin data under the color value;
[0168] The target probability combining module is used to calculate the first target probability that the pixel point belongs to the skin data based on the candidate probability.
[0169] In one embodiment of the present invention, the candidate probability mapping module includes:
[0170] A blue probability mapping module, used for substituting the color value of the blue chromaticity component into the first mapping function corresponding to the blue chromaticity component, so as to map the blue probability of the pixel point belonging to the skin data under the blue chromaticity component as a candidate probability;
[0171] A red probability mapping module, used for substituting the color value of the red chromaticity component into the first mapping function corresponding to the red chromaticity component, so as to map the red probability of the pixel point belonging to the skin data under the red chromaticity component as a candidate probability;
[0172] The target probability combination module includes:
[0173] The first probability product calculation module is used to calculate the product between the blue probability and the red probability as the first target probability that the pixel point belongs to skin data.
[0174] In one embodiment of the present invention, the abscissa of the second mapping function is the brightness value, and the ordinate is the probability of belonging to skin data;
[0175] The second mapping function includes a first brightness mapping segment and a second brightness mapping segment connected in sequence, wherein the probability of belonging to skin data in the first brightness mapping segment increases from 0 to 1, and the probability of belonging to skin data in the second brightness mapping segment is 1.
[0176] In one embodiment of the present invention, the head data includes face data matching the face contour in the head contour, and hair data matching the hair contour in the head contour.
[0177] The mapping function generation module 603 includes:
[0178] A first reference brightness value statistics module, used for counting the brightness value of the hair data as a first reference brightness value, wherein the probability that the first reference brightness value belongs to the skin data is 0;
[0179] A second reference brightness value statistics module, used for counting the brightness values of the face data and the hair data as second reference brightness values, wherein the probability that the second reference brightness value belongs to skin data is 1;
[0180] a first brightness mapping segment fitting module, configured to fit a curve in the first brightness mapping segment by taking the first reference brightness value as a starting point and the second reference brightness value as an end point;
[0181] The second brightness mapping segment fitting module is used to fit a straight line in the second brightness mapping segment using the second reference brightness value as a starting point.
[0182] In one embodiment of the present invention, the skin detection module 605 includes:
[0183] The facial data replacement module is used to replace the facial data with the human facial data.
[0184] In one embodiment of the present invention, the second target probability calculation module 604 includes:
[0185] A brightness value statistics module is used to query the brightness value of each pixel in the image data;
[0186] The brightness value mapping module is used to substitute the brightness value into the second mapping function to map it into a second target probability that the pixel point belongs to skin data.
[0187] In one embodiment of the present invention, the skin detection module 605 includes:
[0188] The second probability product calculation module is used to calculate the product of the first target probability and the second target probability for the same pixel point in the image data as the third target probability that the pixel point belongs to the skin data.
[0189] The skin color detection device provided in the embodiment of the present invention can execute the skin color detection method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0190] Embodiment 3
[0191] Figure 7 A schematic diagram of the structure of a mobile terminal provided in Embodiment 3 of the present invention. Figure 7 A block diagram of an exemplary mobile terminal 12 suitable for use in implementing embodiments of the present invention is shown. Figure 7 The mobile terminal 12 shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present invention.
[0192] like Figure 7As shown, the mobile terminal 12 is in the form of a general purpose computing device. The components of the mobile terminal 12 may include, but are not limited to: one or more processors or processing units 16, a system memory 28, and a bus 18 that connects various system components (including the system memory 28 and the processing unit 16).
[0193] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor or a local bus using any of a variety of bus architectures. By way of example, these architectures include, but are not limited to, an Industry Standard Architecture (ISA) bus, a Micro Channel Architecture (MAC) bus, an Enhanced ISA bus, a Video Electronics Standards Association (VESA) local bus, and a Peripheral Component Interconnect (PCI) bus.
[0194] The mobile terminal 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the mobile terminal 12, including volatile and non-volatile media, removable and non-removable media.
[0195] The system memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The mobile terminal 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be used to read and write non-removable, non-volatile magnetic media ( Figure 7 not shown, usually called a "hard drive"). Although Figure 7 Not shown in the figure, a disk drive for reading and writing to a removable non-volatile disk (e.g., a "floppy disk"), and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a CD-ROM, a DVD-ROM, or other optical media) may be provided. In these cases, each drive may be connected to the bus 18 via one or more data medium interfaces. The memory 28 may include at least one program product having a set (e.g., at least one) of program modules that are configured to perform the functions of the various embodiments of the present invention.
[0196] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in the memory 28, such program modules 42 including but not limited to an operating system, one or more application programs, other program modules, and program data, each of which or some combination may include an implementation of a network environment. The program modules 42 generally perform the functions and / or methods of the embodiments described herein.
[0197] The mobile terminal 12 may also communicate with one or more external devices 14 (e.g., keyboards, pointing devices, displays 24, etc.), may communicate with one or more devices that enable a user to interact with the mobile terminal 12, and / or may communicate with any device that enables the mobile terminal 12 to communicate with one or more other computing devices (e.g., network cards, modems, etc.). Such communication may be performed via an input / output (I / O) interface 22. Furthermore, the mobile terminal 12 may also communicate with one or more networks (e.g., local area networks (LANs), wide area networks (WANs), and / or public networks, such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the mobile terminal 12 via a bus 18. It should be understood that, although not shown in the figure, other hardware and / or software modules may be used in conjunction with the mobile terminal 12, including but not limited to: microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.
[0198] The processing unit 16 executes various functional applications and data processing by running the programs stored in the system memory 28, such as implementing the skin color detection method provided in the embodiment of the present invention.
[0199] Embodiment 4
[0200] Embodiment 4 of the present invention further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the various processes of the above-mentioned skin color detection method are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.
[0201] Among them, computer-readable storage media may include, for example, but are not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive list) of computer-readable storage media include: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In this document, a computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or device.
[0202] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A skin color detection method, It is characterized in that include: Detecting face data in the image data, and dividing head data matching the head contour with reference to the face data; Substituting the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data; generating a second mapping function with reference to the brightness value of the head data, wherein the second mapping function is used to identify the skin data based on the brightness value; Substituting the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data; detecting skin data in the image data in combination with the first target probability and the second target probability; The horizontal coordinate of the second mapping function is the brightness value, and the vertical coordinate is the probability of belonging to skin data; The second mapping function includes a first brightness mapping segment and a second brightness mapping segment connected in sequence, the probability of belonging to skin data in the first brightness mapping segment increases from 0 to 1, and the probability of belonging to skin data in the second brightness mapping segment is 1; The head data includes face data matching the face contour in the head contour and hair data matching the hair contour in the head contour, and generating the second mapping function with reference to the brightness value of the head data includes: Counting the brightness value of the hair data as a first reference brightness value, wherein the probability that the first reference brightness value belongs to the skin data is 0; Counting the brightness values of the face data and the hair data as a second reference brightness value, wherein the probability that the second reference brightness value belongs to the skin data is 1; In the first brightness mapping segment, fitting a curve with the first reference brightness value as a starting point and the second reference brightness value as an end point; In the second brightness mapping segment, a straight line is fitted with the second reference brightness value as a starting point.
2. The method according to claim 1, It is characterized in that The detecting of face data in the image data and dividing the head data matching the head contour with reference to the face data comprises: Calling a face detection interface provided by the camera to request detection of face data in the image data collected by the camera; Receive one or more face frames returned by the face detection interface, where the face frames are used to frame face data.
3. The method according to claim 1, It is characterized in that The head data includes face data and hair data; the step of detecting face data in the image data and dividing the head data matching the head contour with reference to the face data includes: dividing the facial data matching the facial contour in the head contour with reference to the facial data; The hair data matching the hair contour in the head contour is divided with reference to the face data, the hair data surrounding the face data.
4. The method according to claim 3, It is characterized in that If the face data is framed by a face frame, the face data meets the following conditions: The shape of the facial data is an ellipse; The focus of the facial data is the midpoint of the width of the face frame; The length of the short axis of the facial data is equal to the width in the face frame; The length of the major axis of the facial data is equal to n times the length of the target side, the target side is the hypotenuse corresponding to the first candidate side and the second candidate side as right-angle sides, the first candidate side is a first specified ratio of the width in the face frame, and the second candidate side is a second specified ratio of the width in the face frame.
5. The method according to claim 3, It is characterized in that If the face data is framed by a face frame, the hair data meets the following conditions: The shape of the hair data is an ellipse; The focus of the hair data is the midpoint of the width of the face frame; The length of the short axis of the hair data is equal to m times the width in the face frame, and m is positively correlated with the area of the face data; The length of the major axis of the hair data is equal to n×m times the length of the target side, the target side is the hypotenuse corresponding to the first candidate side and the second candidate side as right-angle sides, the first candidate side is a first specified ratio of the width in the face frame, and the second candidate side is a second specified ratio of the width in the face frame.
6. The method according to claim 1, It is characterized in that The detecting of face data in the image data and dividing the head data matching the head contour with reference to the face data comprises: If there are multiple face data in the image data, counting the areas of the multiple face data respectively; The head data matching the head contour are divided with reference to the k face data with the largest areas.
7. The method according to claim 1, It is characterized in that The abscissa of the first mapping function is the color value, and the ordinate is the probability of belonging to skin data; The first mapping function includes a first color mapping segment, a second color mapping segment, and a third color mapping segment connected in sequence, the probability of the first color mapping segment belonging to skin data increases from 0 to 1, the probability of the second color mapping segment belonging to skin data is 1, and the probability of the third color mapping segment belonging to skin data decreases from 1 to 0.
8. The method according to any one of claims 1 to 7, It is characterized in that Substituting the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data includes: Querying the color value of each pixel in the image data; Substituting the color value into the first mapping function to map it into a candidate probability that the pixel point belongs to skin data under the color value; A first target probability that the pixel point belongs to skin data is calculated based on the candidate probability.
9. The method according to claim 8, It is characterized in that Substituting the color value into the first mapping function to map the color value into a candidate probability of the pixel belonging to skin data under the color value includes: Substituting the color value of the blue chromaticity component into the first mapping function corresponding to the blue chromaticity component to map the blue probability of the pixel point belonging to the skin data under the blue chromaticity component as the candidate probability; Substituting the color value of the red chromaticity component into the first mapping function corresponding to the red chromaticity component to map the red probability of the pixel point belonging to the skin data under the red chromaticity component as the candidate probability; The calculating, based on the candidate probability, a first target probability that the pixel point belongs to skin data includes: The product of the blue probability and the red probability is calculated as the first target probability that the pixel point belongs to skin data.
10. The method according to claim 1, It is characterized in that The generating a second mapping function with reference to the brightness value of the header data comprises: The facial data is replaced by the facial data.
11. The method according to any one of claims 1 to 7, 9 to 10, It is characterized in that Substituting the brightness value of the image data into the second mapping function to calculate the second target probability that the image data belongs to skin data includes: Querying the brightness value of each pixel in the image data; Substitute the brightness value into the second mapping function to map it into a second target probability that the pixel point belongs to skin data.
12. The method according to any one of claims 1 to 7, 9 to 10, It is characterized in that The detecting skin data in the image data by combining the first target probability with the second target probability includes: For the same pixel in the image data, the product of the first target probability and the second target probability is calculated as a third target probability that the pixel belongs to skin data.
13. A skin color detection device, It is characterized in that include: An image data detection module, used to detect face data in the image data, and divide head data matching the head contour with reference to the face data; A first target probability calculation module, used for substituting the color value of the image data into a first mapping function to calculate a first target probability that the image data belongs to skin data; A mapping function generating module, used to generate a second mapping function with reference to the brightness value of the head data, wherein the second mapping function is used to identify the skin data based on the brightness value; A second target probability calculation module, used for substituting the brightness value of the image data into the second mapping function to calculate a second target probability that the image data belongs to skin data; a skin detection module, configured to detect skin data in the image data by combining the first target probability and the second target probability; The second mapping function includes a first brightness mapping segment and a second brightness mapping segment connected in sequence, the probability of the first brightness mapping segment belonging to skin data increases from 0 to 1, and the probability of the second brightness mapping segment belonging to skin data is 1; The head data includes facial data matching the facial contour in the head contour and hair data matching the hair contour in the head contour, and the mapping function generating module includes: A first reference brightness value statistics module, used for counting the brightness value of the hair data as a first reference brightness value, wherein the probability that the first reference brightness value belongs to the skin data is 0; A second reference brightness value statistics module, used for counting the brightness values of the face data and the hair data as second reference brightness values, wherein the probability that the second reference brightness value belongs to skin data is 1; a first brightness mapping segment fitting module, configured to fit a curve in the first brightness mapping segment by taking the first reference brightness value as a starting point and the second reference brightness value as an end point; The second brightness mapping segment fitting module is used to fit a straight line in the second brightness mapping segment using the second reference brightness value as a starting point.
14. A mobile terminal, It is characterized in that The mobile terminal comprises: one or more processors; a memory for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the skin color detection method according to any one of claims 1 to 12.
15. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the skin color detection method according to any one of claims 1 to 12 is implemented.
