WO2022135574A1 - Skin color detection method and apparatus, and mobile terminal and storage medium - Google Patents

Skin color detection method and apparatus, and mobile terminal and storage medium Download PDF

Info

Publication number
WO2022135574A1
WO2022135574A1 PCT/CN2021/141248 CN2021141248W WO2022135574A1 WO 2022135574 A1 WO2022135574 A1 WO 2022135574A1 CN 2021141248 W CN2021141248 W CN 2021141248W WO 2022135574 A1 WO2022135574 A1 WO 2022135574A1
Authority
WO
WIPO (PCT)
Prior art keywords
data
color
skin
image data
face
Prior art date
Application number
PCT/CN2021/141248
Other languages
French (fr)
Chinese (zh)
Inventor
杨敏
Original Assignee
百果园技术(新加坡)有限公司
杨敏
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 百果园技术(新加坡)有限公司, 杨敏 filed Critical 百果园技术(新加坡)有限公司
Publication of WO2022135574A1 publication Critical patent/WO2022135574A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T7/00Image analysis
    • G06T7/90Determination of colour characteristics
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/08Learning methods
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/10Image acquisition modality
    • G06T2207/10016Video; Image sequence
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/20Special algorithmic details
    • G06T2207/20081Training; Learning
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T2207/00Indexing scheme for image analysis or image enhancement
    • G06T2207/30Subject of image; Context of image processing
    • G06T2207/30196Human being; Person
    • G06T2207/30201Face

Definitions

  • the embodiments of the present application relate to the technical field of computer vision, for example, to a skin color detection method, device, mobile terminal, and storage medium.
  • the 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.
  • skin color detection based on color space has a wide range of applications in the field of real-time stream processing due to its fast and efficient characteristics, but the accuracy is low.
  • Skin color detection based on machine learning classification and skin color detection based on deep learning image segmentation have higher
  • performance often becomes a bottleneck, which is difficult to apply to devices such as restricted mobile terminals.
  • the embodiments of the present application provide a method for detecting skin color, including:
  • the video data includes multiple frames of image data
  • the first target image data is image data collected at a first time point;
  • the embodiments of the present application also provide a skin color detection device, including:
  • a video data collection module configured to collect video data, the video data including multiple frames of image data
  • a face data detection module configured to detect face data in multiple frames of the image data respectively
  • the mapping function correction module is configured to modify the mapping function with the color value of the face data in the first target image data as a priori knowledge in response to detecting the face data in the first target image data, and the mapping function For identifying skin data based on color values, the first target image data is image data collected at a first time point;
  • a mapping detection module configured to substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data, the second target image data being collected at a second time point image data.
  • an embodiment of the present application further provides a mobile terminal, where the mobile terminal includes:
  • memory arranged to store at least one program
  • the at least one processor When the at least one program is executed by the at least one processor, the at least one processor implements the skin color detection method according to the first aspect.
  • an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the skin color detection according to the first party is implemented method.
  • FIG. 1 is a flowchart of a skin color detection method provided in Embodiment 1 of the present application.
  • FIG. 2 is an example diagram of a time axis of video data according to Embodiment 1 of the present application.
  • FIG. 3 is an example diagram of a mapping function provided in Embodiment 1 of the present application.
  • FIG. 4 is an example diagram of a modified mapping function provided by Embodiment 1 of the present application.
  • FIG. 5 is a grayscale distribution diagram corresponding to a probability distribution of skin color detection provided in Embodiment 1 of the present application;
  • FIG. 6 is a schematic structural diagram of a skin color detection device provided in Embodiment 2 of the present application.
  • FIG. 7 is a schematic structural diagram of a mobile terminal according to Embodiment 3 of the present application.
  • Embodiment 1 is a flowchart of a skin color detection method provided in Embodiment 1 of the present application.
  • color values of face data can be used as prior knowledge to perform skin color detection, and the method can be performed by a skin color detection device.
  • the apparatus can be implemented by software and/or hardware, and can be configured in a mobile terminal, for example, a mobile phone, a tablet computer, a smart wearable device (such as a smart watch, smart glasses, etc.), etc., and includes the following steps:
  • Step 101 Collect video data.
  • the video data waiting for skin color detection generally refers to video data generated, transmitted or played in a real-time service scenario.
  • skin color detection can be performed on the video data in the mobile terminal that generates the video data.
  • the camera of the mobile terminal can be turned on, and the camera can collect the video data.
  • skin color detection may also be performed on the video data on the mobile terminal that plays the video data, which is not limited in this embodiment.
  • 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
  • the video data is distributed to at least one The device logged in by the viewer user plays the video.
  • the video data is usually detected by skin color on the mobile terminal logged in by the host user.
  • the video data waiting for skin color detection may refer to the video data used to carry the content of the call, and the mobile terminal logged in by the user who initiates the call generates video data, and sends the video data to at least A device logged in by a user who is invited to a call is played.
  • skin color detection is usually performed on the video data on the mobile terminal logged in by the user who initiated the call.
  • the 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 video data
  • the video data is sent to at least A device logged in by a user participating in the conference plays the video.
  • the mobile terminal logged in by the user who is usually speaking performs skin color detection on the video data.
  • the video data waiting for skin color detection may also refer to video data generated in a service scenario with low real-time requirements, such as a short video, which is not limited in this embodiment.
  • Step 102 Detect face data in multiple frames of image data respectively.
  • the multi-frame image data of the video data usually contains the user's character image.
  • the so-called character image can refer to the pixels in the image data used to represent the character.
  • the character image includes at least face data (pixels) for representing a human face, and may also include hair data (pixels) for representing hair and body data (pixels) for representing a body , limb data (pixel points) used to represent limbs, etc., which are not limited in this embodiment of the present application.
  • skin data for representing skin may be included.
  • face detection can be performed on multiple frames of image data respectively, and face data included in the image data can be identified. Using the face data as a high-quality anchor point, high-quality skin data can be captured.
  • face data is represented by face key points, that is, given face data, key regions of the face are located, including eyebrows, eyes, nose, mouth, facial contours, and so on.
  • a range of a specified shape can be generated based on the key points of the face, and the range is used to represent the face data, wherein the shape includes a rectangle, an ellipse, etc., and the range of the rectangle can also be called a face frame.
  • the following methods can be used to perform face detection on multi-frame image data:
  • Use artificial extraction features such as haar features, use features to train classifiers, and use classifiers for face detection.
  • Convolutional neural network using cascade structure for example, Cascade CNN (Cascade Convolutional Neural Network), MTCNN (Multi-task Cascaded Convolutional Networks, multi-task convolutional neural network).
  • Cascade CNN Cascade Convolutional Neural Network
  • MTCNN Multi-task Cascaded Convolutional Networks, multi-task convolutional neural network.
  • These methods for implementing face detection can be integrated in the modules of the application, and the modules of the application are directly called to perform face detection on image data. These methods for implementing face detection can also be integrated in the SDK (Software Development Kit, software development kit). ), the SDK is used as the assembly data of the application, the application can request the SDK to perform face detection on multi-frame image data, the SDK detects the face data in the image data, and returns the face data to the application.
  • the SDK Software Development Kit, software development kit
  • the system application usually provides API (Application Program Interface, Application Program Interface) for these methods of implementing face detection, as a face detection interface, for example, in the Android (Android) system , provides two face detection interfaces android.media.FaceDetector and android.media.FaceDetector.Face, in iOS system, provides two face detection interfaces AVCaptureMetadataOutput and CIDetector.
  • API Application Program Interface
  • Application Program Interface Application Program Interface
  • the face frame is a rectangular frame , which can be used to frame the face data, that is, the face data is located in the face frame.
  • the face detection interface provided by the system application, there is hardware support, and the face frame is calibrated based on a few key points of the face (2 key points of the face), the speed is fast, the performance consumption is very low, and the accuracy can meet the requirements of the first knowledge requirements.
  • the video data includes multiple frames of image data, which are denoted as P 1 , P 2 , ..., P t-1 , P t , P t+1 , ... , P n in the order of generation, where t and n are positive Integer, t+1 ⁇ n, since the video data is generated in real time, n increases continuously with the generation of the video data until the generation of the video data is completed.
  • each frame of image data in the video data is sequentially traversed to perform skin color detection.
  • the image data collected at the first time point is called the first target image data
  • the image data collected at the second time point will be called the first target image data.
  • the image data is called the second target image data.
  • the second time point is located after the first time point.
  • the first time point is the closest time point to the second time point when face data is detected.
  • the second time point may be the same as the second time point.
  • the first time point is adjacent, that is, there is no other time point between the second time point and the first time point, and the second time point may not be adjacent to the first time point, that is, the second time point and the first time point other time points in between.
  • T represents the time axis
  • t 0 to t 11 represent time points.
  • time point t 2 is the first time point
  • time point t 3 -t 6 are the second time points
  • the time point t 7 is the first time point
  • the time points t 8 -t 11 are the second time points.
  • Step 103 in response to detecting the face data in the first target image data, correct the mapping function by using the color value of the face data as prior knowledge.
  • a mapping function can be set by counting the color values of pixels in different samples such as skin data and non-skin data, and the mapping function can be used to identify skin data based on the color value, that is, the input of the mapping function is The color value is output as the probability that the current data belongs to skin data. At this time, the probability that the pixels in different samples are skin data under a certain color value can be counted, so that these color values and their probabilities can be fitted as a mapping function.
  • the mapping function can refer to the skin data of users of different races, different ages, and different skin tones, and can also refer to the skin data under different lighting conditions. Therefore, the mapping function is relatively broad and the accuracy is relatively high, but , in the case of skin color detection for the current user, the accuracy is lacking.
  • the probability that the current data in the mapping function belongs to skin data is a continuous value, such as [0-1]. In some cases, the probability that the current data in the mapping function belongs to skin data is a discrete value, such as 0, 1, this The embodiment does not limit this.
  • the abscissa (horizontal axis) is the color value (X), and the ordinate (vertical axis) is the probability (P) that the current data belongs to skin data .
  • the mapping function includes a first color map segment (the abscissa is [x 0 , x 1 ]), a second color map segment (the abscissa is [x 1 , x 2 ]), and a third color map segment (the abscissa is [x 1 , x 2 ]), which are connected in sequence
  • the coordinates are [x 2 , x 3 ]), wherein the probability that the current data in the first color mapping segment belongs to skin data increases from 0 to 1, the probability that the current data in the second color mapping segment belongs to skin data is 1, and the third The probability that the current data in the colormap segment belongs to skin data decreases from 1 to 0.
  • the second color map segment belongs to a line segment
  • the first color map segment and the third color map segment belong to a curve, which can be fitted by using a polynomial function or the like.
  • mapping function includes a first color mapping segment and a second color mapping segment connected in sequence, wherein the first color The probability that the current data in the mapping segment belongs to skin data increases from 0 to 1, and the probability that the current data in the second color mapping segment belongs to skin data decreases from 1 to 0.
  • mapping function is expressed by functions such as a quadratic equation, etc. etc., which are not limited in the embodiments of the present application.
  • those skilled in the art may also adopt other mapping functions according to actual needs, which are not limited in the embodiments of the present application.
  • mapping functions can be set for the color components.
  • red chrominance components R
  • green chrominance components G
  • the mapping function may be set for the red chrominance component (R)
  • the mapping function may be set for the green chrominance component (G)
  • the mapping function may be set for the blue chrominance component (B)
  • the color value can be counted within the range of the face data, and the counted color value
  • the confidence of the color value of the skin data is high, which can be used as a priori knowledge to correct the mapping function for the current user and improve the accuracy of the mapping function for the current user.
  • step 103 may include the following steps:
  • Step 1031 Determine the mapping function.
  • the abscissa of the mapping function is the color value
  • the ordinate is the probability that the current data belongs to skin data
  • the mapping function includes a first color mapping segment, a second color mapping segment, and a third color mapping segment connected in sequence
  • the probability that the current data in the first color map segment belongs to skin data increases from 0 to 1
  • the probability that the current data in the second color map segment belongs to skin data is 1
  • the probability that the current data in the third color map segment belongs to skin data increases from 1 down to 0.
  • Step 1032 Detect skin data in the face data based on the color space.
  • the area of the multiple face data can be counted separately. If the face data is framed by a face frame, the width of the face frame is w and the height is w. is h, then the area of the face data
  • n is a positive integer, such as 3
  • the skin data to be detected the skin data to be detected
  • the color value of the statistical skin data due to the imaging characteristics of the camera
  • the data method can accurately describe the color of the face data with a larger area. Selecting the n face data with the largest area can ensure the accuracy of the color value of the subsequent statistical skin data under the condition of reducing the amount of calculation.
  • the n face data with the largest area may be the face data sorted according to the area from large to small, and the n face data may be the top n face data in the sorting.
  • skin data may also be detected in all the face data based on the color space, which is not limited in this embodiment.
  • the color space-based method can be used to detect the skin color in the face data, and the pixels representing the skin data can be detected.
  • the color space-based method is simple to calculate, so the calculation speed is fast and time-consuming. Counting the color values of multiple skin data can maintain a high accuracy as a whole, meeting the requirements of prior knowledge.
  • the method corresponding to the color space detects skin data in the face data, which is not limited in this embodiment.
  • the pixel is skin data (that is, the probability that the pixel belongs to skin data is 1), and the color value of the pixel does not meet the following conditions
  • the pixel is not skin data (that is, the probability that the pixel belongs to skin data is 0):
  • Max represents the maximum value
  • Min represents the minimum value
  • Abs represents the absolute value
  • R represents the red chrominance component
  • G represents the green chrominance component
  • B represents the blue chrominance component.
  • the pixel is skin data (that is, the probability that the pixel belongs to skin data is 1), and the color value of the pixel does not meet the following conditions. Under the following conditions, it can be considered that the pixel is not skin data (that is, the probability that the pixel belongs to skin data is 0):
  • Cb represents the blue chrominance component
  • Cr represents the red chrominance component
  • the face data may include non-skin data such as hair data and background data.
  • non-skin data such as hair data and background data.
  • Reduce the area of face data on the edge reduce the amount of non-skin data, and increase the proportion of skin data, so as to detect skin data in candidate area images based on color space, and improve the accuracy of skin data detection.
  • the center point P(x 0 , y 0 ) of the face frame can be determined, and on the condition that the center point P(x 0 , y 0 ) is maintained , reduce the width and height of the face frame as a candidate area image.
  • the candidate area image can be expressed as [x 0 ⁇ (a*w), y 0 ⁇ (b*h)[, where a is a coefficient less than 1, such as 0.4, b is a coefficient less than 1, such as 0.1.
  • Step 1033 count the color values of the skin data.
  • the average value of the color values among multiple pixel points can be counted as the color value of the entire skin data.
  • Step 1034 Mark the color value of the skin data on the horizontal axis of the coordinate system where the mapping function is located.
  • the color value C of the skin data can be marked on the horizontal axis of the coordinate system where the mapping function is located.
  • the color value C of the skin data is generally located in the second color mapping segment of the mapping function (the abscissa is [x 1 , x 2 ]).
  • Step 1035 under the condition that the first color map segment and the third color map segment are maintained, reduce the second color map segment with reference to the color value of the skin data.
  • the mapping function can be converged to the color value C of the skin data as a whole, the range of the mapping function can be reduced, and some regions with low probability can be excluded.
  • the shape of the first color mapping segment and the third color mapping segment are kept unchanged as a precondition, and the color value of the user's skin data in the current scene is used as a reference to reduce the size of the second color mapping segment. range, and adjust the range of the first color map segment and the third color map segment accordingly.
  • step 1035 includes the following steps:
  • Step 10351 Converging the second color map segment towards the color value of the skin data.
  • either end of the second color mapping segment may be converged, or both ends of the second color mapping segment may be converged at the same time, which is not limited in this embodiment.
  • the color value C of the skin data is marked on the horizontal axis, and the two ends of the second color mapping segment are converged toward the color value C of the skin data at the same time, and the abscissa of the second color mapping segment before convergence is [x 1 , x 2 ], the abscissa of the second color mapping segment after convergence is [x 1 ', x 2 '], where x 1 '>x 1 , x 2 ' ⁇ x 2 .
  • the target length L t can be determined. Assuming that the length of the second color map segment is L, the target length L t is less than the length L of the second color map segment, that is, L t ⁇ L. The color value C is used as the center point to reduce the second color map segment until the length L of the second color map segment is equal to the target length L t , thereby reducing the range of the second color map segment.
  • the target length L t x 2 ′-x 1 ′
  • the color value of the skin data is
  • the target length L t is a statistical value, which is a constant.
  • the target length L t is an adaptively adjusted value, which is a variable.
  • the reference length T may be determined, and the reference length T is a statistical value, which is a constant, and is smaller than the length L of the second color map segment, that is, T ⁇ L.
  • the time difference ⁇ t between the second time point and the first time point is mapped to the correction coefficient w t by the preset mapping method f(), and the correction coefficient w t is positively correlated with the time difference, that is, the larger the time difference, the greater the correction coefficient w t On the contrary, the smaller the time difference, the smaller the correction coefficient w t .
  • the second time point is closer to the first time point.
  • the farther away, the higher the probability of changes in lighting and other conditions in the scene, and the lower the reference value of the color value of the skin data counted at the first time point. point) is farther and farther away from the current time (second time point), then gradually relax the target length L t , so that the target length L t is getting closer and closer to the length L of the second color mapping segment, so as to ensure that the second Accuracy of colormap segments.
  • Step 10352 Shift the first color mapping segment in a direction close to the second color mapping segment until the first color mapping segment is connected to the second color mapping segment.
  • the first color mapping segment can be shifted to the right on the horizontal axis, so that the first color mapping segment moves toward the second color mapping segment until the first color mapping segment is reached.
  • the second color map segment is connected, that is, the first color map segment is connected to the second color map at the endpoint x 1 ', and the abscissa of the first color map segment before translation is [x 0 , x 1 ], after translation
  • Step 10353 Shift the third color mapping segment in a direction close to the second color mapping segment until the third color mapping segment is connected to the second color mapping segment.
  • the third color mapping segment can be shifted to the left on the horizontal axis, so that the third color mapping segment moves toward the second color mapping segment until the third color mapping segment is reached.
  • the second color map segment is connected, that is, the third color map segment is connected to the second color map at the endpoint x 2 '.
  • the abscissa of the third color map segment is [x 2 , x 3 ].
  • Step 104 Substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data.
  • the face data is detected at the first target image data corresponding to the first time point, and the color value of the face data in the face data is used as the prior knowledge to correct the mapping function.
  • the mapping function can be located after the first time point.
  • skin color detection is performed on the second target image data (that is, the second target image data is the image data collected at the second time point), so as to detect the degree to which the pixel points represent the skin data in the second target image data .
  • the color value of each pixel of the second target image data can be marked on the horizontal axis in the coordinate system where the mapping function is located. If the color value of the pixel in the second target image data is outside the mapping function, Then the probability that the pixel belongs to the skin data is 0. If the color value of the pixel in the second target image data is within the mapping function, the probability corresponding to the color value on the vertical axis can be found through the mapping function, as the pixel belongs to. Probability of skin data.
  • the abscissa of the mapping function is the color value
  • the ordinate is the probability that the pixel belongs to the skin data.
  • the color value has different chromaticity components, and each color component has a corresponding mapping function, For the same pixel, different probabilities can be calculated.
  • the color value of each pixel in the second target image data can be queried, and the color value can be substituted into the corresponding mapping function to map out the candidate probability that each pixel belongs to the skin data under the color value, based on
  • These candidate probabilities can be calculated by averaging, summing, multiplying, linear fusion (that is, summing after configuring weights) to calculate the target probability that the pixel belongs to the skin data.
  • These target probabilities reflect the ROI (region of interest, region of interest) area.
  • the second target image data has a blue chrominance component Cb, a red chrominance component Cr.
  • the color value of the blue chrominance component Cb is substituted into the mapping function corresponding to the blue chrominance component Cb, so as to map out the blue probability that the pixel belongs to the skin data under the blue chrominance component Cb, as the candidate probability
  • the color value of the red chrominance component Cr is substituted into the mapping function corresponding to the red chrominance component Cr, so as to map the red probability that the pixel belongs to the skin data under the red chrominance component Cr, as the candidate probability
  • the blue probability can be calculated with red probability
  • the product between as the target probability that the pixel belongs to the skin data
  • the skin data can be detected in the image data based on the color space.
  • operations such as beautifying processing (such as skin resurfacing) can be performed on the video data according to the needs of the user.
  • the left side is the grayscale distribution corresponding to the probability distribution obtained by using the color space-based skin color detection
  • the right side is the probability distribution corresponding to the skin color detection obtained by applying this embodiment.
  • Grayscale distribution in which, the higher the grayscale of a pixel (more white), the higher the probability that the pixel belongs to skin data, and the lower the grayscale (more black), the lower the probability that the pixel belongs to skin data. .
  • the skin color detection based on the color space considers clothes, hair, and backgrounds (such as electric lights, etc.) to belong to skin data, and this embodiment can well exclude clothes, hair, and backgrounds (such as electric lights, etc.). ), which greatly improves the accuracy of skin color detection, and can well protect clothes, hair, and backgrounds (such as lights, etc.) in subsequent beauty treatments (such as microdermabrasion).
  • video data is collected, and the video data includes multiple frames of image data, and face data is detected in the multiple frames of image data respectively. If face data is detected in the first target image data, the face data
  • the color value is used as a priori knowledge to correct the mapping function, the mapping function is used to identify skin data based on the color value, the first target image data is the image data collected at the first time point, and the color value of the second target image data is substituted into the mapping function , in order to detect skin data in the second target image data, the second target image data is the image data collected at the second time point, the video data has continuity, therefore, the content between multiple frames of image data has correlation, so that The previous image data can be used as the prior knowledge of the subsequent image data, and the face data can be used as the anchor to capture high-quality skin data.
  • This adaptive modification of the mapping function can improve the accuracy of skin color detection performed by the mapping function in the current business scenario, and operations such as face detection, statistics of the color value of the skin data, correction of the mapping function and its application are relatively simple. , the calculation amount is small, the speed is fast, and the time-consuming is short. In the case of limited performance of mobile terminals and other equipment, the skin color detection of video data can be realized in real time.
  • some data similar to skin data such as hair, clothes, background, etc.
  • FIG. 6 is a structural block diagram of a skin color detection device provided in Embodiment 2 of the present application, which may include the following modules:
  • the video data collection module 601 is configured to collect video data, and the video data includes multiple frames of image data;
  • a face data detection module 602 configured to detect face data in the multiple frames of the image data respectively;
  • the mapping function correction module 603 is configured to modify the mapping function with the color value of the face data in the first target image data as prior knowledge in response to detecting the face data in the first target image data, and the mapping function The function is used to identify skin data based on the color value, and the first target image data is the image data collected at the first time point;
  • the mapping detection module 604 is configured to substitute the color value of the second target image data into the mapping function, so as to detect skin data in the second target image data, the second target image data is at the second time point acquired image data.
  • the face data detection module 602 includes:
  • a face detection interface calling module configured to call the face detection interface provided by the camera, to request to detect the face data in the multiple frames of the image data collected by the camera;
  • the face frame receiving module is configured to receive at least one face frame returned by the face detection interface, where the face frame is used to frame face data.
  • mapping function correction module 603 includes:
  • the mapping function determination module is set to determine the mapping function, the abscissa of the mapping function is the color value, and the ordinate is the probability that the current data belongs to the skin data, and the mapping function includes the first color mapping segment and the second color that are connected in turn.
  • mapping section and third color mapping section the probability that the current data in the first color mapping section belongs to skin data increases from 0 to 1, the probability that the current data in the second color mapping section belongs to skin data is 1, and the The probability that the current data in the third color map segment belongs to skin data decreases from 1 to 0;
  • a face skin detection module configured to detect skin data in the face data in the first target image data based on the color space
  • a color value statistics module configured to count color values for the skin data
  • a color value marking module configured to mark the color value based on the statistics of the skin data on the horizontal axis of the coordinate system where the mapping function is located;
  • the color map segment correction module is configured to reduce the second color map segment with reference to the color value based on the statistics of the skin data under the condition of maintaining the first color map segment and the third color map segment.
  • mapping function correction module 603 further includes:
  • an area statistics module configured to count the areas of a plurality of the face data respectively in response to the existence of a plurality of face data in the first target image data
  • a face extraction module configured to extract the n pieces of face data with the largest area.
  • the face skin detection module includes:
  • a face data convergence module configured to converge the face data in the first target image data to obtain a candidate area image
  • a candidate detection module configured to detect skin data in the candidate region image based on the color space.
  • the face data convergence module includes:
  • a center point determination module configured to frame the face frame in response to the face data in the first target image data, and determine the center point of the face frame
  • the face frame reduction module is configured to set the center point of the face frame as the center point of the candidate area image, and reduce the width and height of the face frame as the width and height of the candidate area image.
  • the color map segment correction module includes:
  • a second color map segment convergence module configured to converge the second color map segment toward the color value based on the skin data statistics
  • a first color map segment translation module configured to translate the first color map segment in a direction close to the second color map segment, until the first color map segment is connected to the second color map segment;
  • a third color mapping segment translation module is configured to translate the third color mapping segment in a direction close to the second color mapping segment until the third color mapping segment is connected to the second color mapping segment.
  • the second color map segment convergence module includes:
  • a target length determination module configured to determine a target length, the target length being less than the length of the second color map segment
  • a color map segment reduction module configured to reduce the second color map segment with the color value based on the skin data statistics as a center point until the length of the second color map segment is equal to the target length.
  • the target length determination module includes:
  • a reference length determination module configured to determine a reference length, the reference length being less than the length of the second color mapping segment
  • An adjustable length calculation module configured to calculate the difference between the length of the second color map segment and the reference length as an adjustable length
  • a correction coefficient calculation module configured to map the time difference between the second time point and the first time point as a correction coefficient, and the correction coefficient is positively correlated with the time difference;
  • a correction length calculation module configured to calculate the product between the adjustable length and the correction coefficient as the correction length
  • the target length calculation module is configured to calculate the sum value between the reference length and the corrected length as the target length.
  • mapping detection module 604 includes:
  • a color value query module configured to query the color value of a pixel in the second target image data
  • a candidate probability mapping module configured to substitute the color value of the pixel into the mapping function to map the pixel as a candidate probability that the pixel belongs to skin data under the color value;
  • the target probability calculation module is configured to calculate the target probability that the pixel point belongs to the skin data based on the candidate probability.
  • the candidate probability mapping module includes:
  • the blue probability mapping module is configured to substitute the color value of the blue chrominance component into the mapping function corresponding to the blue chrominance component, so as to map the pixel points to the skin data under the blue chrominance component.
  • the blue probability as the candidate probability
  • a red probability mapping module configured to substitute the color value of the red chromaticity component into the mapping function corresponding to the red chromaticity component, so as to map the pixel to the red color of the skin data under the red chromaticity component probability, as a candidate probability;
  • the target probability calculation module includes:
  • the probability product calculation module is configured to calculate the product between the blue probability and the red probability as the target probability that the pixel belongs to the skin data.
  • An image detection module configured to detect skin data in the image data based on the color space in response to the previously undetected face data.
  • the skin color detection apparatus provided by the embodiment of the present application can execute the skin color detection method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
  • FIG. 7 is a schematic structural diagram of a mobile terminal according to Embodiment 3 of the present application.
  • FIG. 7 shows a block diagram of an exemplary mobile terminal 12 suitable for use in implementing embodiments of the present application.
  • the mobile terminal 12 shown in FIG. 7 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
  • the mobile terminal 12 takes the form of a general-purpose computing device.
  • Components of the mobile terminal 12 may include, but are not limited to, one or more processors or processing units 16, a system memory (also referred to as memory) 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16). .
  • Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures.
  • these architectures include, but are not limited to, Industry Standard Architecture (ISA, Industry Standard Architecture) bus, Micro Channel Architecture (MCA, Micro Channel Architecture) bus, enhanced ISA bus, Video Electronics Standards Association (VESA, Video Electronics Standards Association) local bus and Peripheral Component Interconnect (PCI, Peripheral Component Interconnect) bus.
  • ISA Industry Standard Architecture
  • MCA Micro Channel Architecture
  • VESA Video Electronics Standards Association
  • PCI Peripheral Component Interconnect
  • 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.
  • 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.
  • storage system 34 may be used to read and write to non-removable, non-volatile magnetic media (not shown in FIG. 7, commonly referred to as a "hard drive”).
  • a disk drive for reading and writing to removable non-volatile magnetic disks eg "floppy disks”
  • removable non-volatile optical disks eg CD-ROM, DVD-ROM
  • each drive may be connected to bus 18 through one or more data media interfaces.
  • Memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of various embodiments of the present application.
  • a program/utility 40 having a set (at least one) of program modules 42, which may be stored, for example, in 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 or some combination of these examples may include an implementation of a network environment.
  • Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
  • the mobile terminal 12 may also communicate with one or more external devices 14 (eg, a keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable a user to interact with the mobile terminal 12, and/or communicate with Any device (eg, network card, modem, etc.) that enables the mobile terminal 12 to communicate with one or more other computing devices. Such communication may take place through input/output (I/O) interface 22 .
  • the mobile terminal 12 can also communicate with one or more networks (such as a local area network (LAN, Local Area Network), a wide area network (WAN, Wide Area Network) and/or a public network, such as the Internet, through the network adapter 20. As shown in FIG.
  • the network adapter 20 communicates with other modules of the mobile terminal 12 via the bus 18 .
  • 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 (Redundant Arrays) of Independent Disks, disk array) systems, tape drives, and data backup storage systems.
  • 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 by the embodiments of the present application.
  • the fourth embodiment of the present application also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, each process of the above-mentioned skin color detection method can be achieved, and the same effect can be achieved, In order to avoid repetition, details are not repeated here.
  • the computer-readable storage medium may include, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. More specific examples (non-exhaustive list) of computer readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM, Read-Only Memory), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable of the above The combination.
  • a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
  • the embodiments of the present application propose a skin color detection method, device, mobile terminal, and storage medium, so as to solve the problem of how to take into account the real-time performance and accuracy of skin color detection under the condition of limited performance.
  • video data is collected, and the video data includes multiple frames of image data, and face data is detected in the multiple frames of image data respectively. If face data is detected in the first target image data, the face data
  • the color value is used as a priori knowledge to correct the mapping function, the mapping function is used to identify skin data based on the color value, the first target image data is the image data collected at the first time point, and the color value of the second target image data is substituted into the mapping function , in order to detect skin data in the second target image data, the second target image data is the image data collected at the second time point, and the video data has continuity, therefore, the content between multiple frames of image data has correlation, so that The previous image data can be used as the prior knowledge of the subsequent image data, and the face data can be used as an anchor to capture high-quality skin data.
  • This adaptive modification of the mapping function can improve the accuracy of skin color detection performed by the mapping function in the current business scenario, and operations such as face detection, statistics of the color value of the skin data, correction of the mapping function and its application are relatively simple. , the calculation amount is small, the speed is fast, and the time-consuming is short. In the case of limited performance of mobile terminals and other equipment, the skin color detection of video data can be realized in real time.
  • some data similar to skin data such as hair, clothes, background, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Computational Linguistics (AREA)
  • General Health & Medical Sciences (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • Artificial Intelligence (AREA)
  • Biomedical Technology (AREA)
  • Biophysics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Evolutionary Computation (AREA)
  • Health & Medical Sciences (AREA)
  • Molecular Biology (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Mathematical Physics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Image Analysis (AREA)
  • Image Processing (AREA)

Abstract

Provided in the embodiments of the present application are a skin color detection method and apparatus, and a mobile terminal and a storage medium. The method comprises: acquiring video data, wherein the video data comprises multiple frames of image data; respectively detecting facial data in the multiple frames of image data; in response to detecting facial data in first target image data, using a color value of the facial data as priori knowledge to correct a mapping function, wherein the mapping function is used for identifying skin data on the basis of the color value; and substituting a color value of second target image data into the mapping function, so as to detect skin data in the second target image data.

Description

肤色检测方法、装置、移动终端和存储介质Skin color detection method, device, mobile terminal and storage medium
本申请要求在2020年12月25日提交中国专利局、申请号为202011563923.X的中国专利申请的优先权,以上申请的全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application with application number 202011563923.X filed with the China Patent Office on December 25, 2020, the entire contents of the above application are incorporated into this application by reference.
技术领域technical field
本申请实施例涉及计算机视觉的技术领域,例如涉及一种肤色检测方法、装置、移动终端和存储介质。The embodiments of the present application relate to the technical field of computer vision, for example, to a skin color detection method, device, mobile terminal, and storage medium.
背景技术Background technique
随着移动互联网与移动终端的迅速发展,移动终端中的视频数据已成为人类活动中常用的信息载体,如直播、视频通话等,它们包含着物体的大量信息,成为人们获取外界原始信息的途径之一。With the rapid development of mobile Internet and mobile terminals, video data in mobile terminals has become a common information carrier in human activities, such as live broadcasts, video calls, etc. They contain a large amount of information about objects and become a way for people to obtain original information from the outside world. one.
针对这些视频数据,用户通常会选择美颜,肤色检测作为美颜的基础,决定了美颜能够实现对视频数据的实时处理,并且也影响了美颜的效果优劣。For these video data, users usually choose beauty, and skin color detection is the basis of beauty, which determines that beauty can realize real-time processing of video data, and also affects the effect of beauty.
主流的肤色检测可以分为基于颜色空间的肤色检测、基于机器学习分类的肤色检测以及基于深度学习图像分割的肤色检测。The 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.
其中,基于颜色空间的肤色检测由于具有快速高效的特性从而在实时流处理领域有着广泛的应用,但精确度较低,基于机器学习分类的肤色检测以及基于深度学习图像分割的肤色检测有较高的精确度,但在实时流处理的时候性能往往会成为瓶颈,难以应用于受限移动终端等设备的情况。Among them, skin color detection based on color space has a wide range of applications in the field of real-time stream processing due to its fast and efficient characteristics, but the accuracy is low. Skin color detection based on machine learning classification and skin color detection based on deep learning image segmentation have higher However, in real-time stream processing, performance often becomes a bottleneck, which is difficult to apply to devices such as restricted mobile terminals.
发明内容SUMMARY OF THE INVENTION
第一方面,本申请实施例提供了一种肤色检测方法,包括:In a first aspect, the embodiments of the present application provide a method for detecting skin color, including:
采集视频数据,所述视频数据包括多帧图像数据;collecting video data, the video data includes multiple frames of image data;
分别在多帧所述图像数据中检测人脸数据;respectively detecting face data in multiple frames of the image data;
响应于在第一目标图像数据中检测到人脸数据,以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,所述映射函数用于基于色彩值识别皮肤数据,所述第一目标图像数据为在第一时间点采集的图像数据;In response to detecting human face data in the first target image data, using the color value of the human face data in the first target image data as a priori knowledge, modifying a mapping function for identifying skin based on the color value data, the first target image data is image data collected at a first time point;
将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,所述第二目标图像数据为在第二时间点采集的图像数据。Substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data, where the second target image data is image data collected at a second time point.
第二方面,本申请实施例还提供了一种肤色检测装置,包括:In a second aspect, the embodiments of the present application also provide a skin color detection device, including:
视频数据采集模块,设置为采集视频数据,所述视频数据包括多帧图像数据;a video data collection module, configured to collect video data, the video data including multiple frames of image data;
人脸数据检测模块,设置为分别在多帧所述图像数据中检测人脸数据;a face data detection module, configured to detect face data in multiple frames of the image data respectively;
映射函数修正模块,设置为响应于在第一目标图像数据中检测到人脸数据,以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,所述映射函数用于基于色彩值识别皮肤数据,所述第一目标图像数据为在第一时间点采集的图像数据;The mapping function correction module is configured to modify the mapping function with the color value of the face data in the first target image data as a priori knowledge in response to detecting the face data in the first target image data, and the mapping function For identifying skin data based on color values, the first target image data is image data collected at a first time point;
映射检测模块,设置为将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,所述第二目标图像数据为在第二时间点采集的图像数据。A mapping detection module configured to substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data, the second target image data being collected at a second time point image data.
第三方面,本申请实施例还提供了一种移动终端,所述移动终端包括:In a third aspect, an embodiment of the present application further provides a mobile terminal, where the mobile terminal includes:
至少一个处理器;at least one processor;
存储器,设置为存储至少一个程序,memory, arranged to store at least one program,
当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如第一方面所述的肤色检测方法。When the at least one program is executed by the at least one processor, the at least one processor implements the skin color detection method according to the first aspect.
第四方面,本申请实施例还提供了一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如第一方所述的肤色检测方法。In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the skin color detection according to the first party is implemented method.
附图说明Description of drawings
图1为本申请实施例一提供的一种肤色检测方法的流程图;1 is a flowchart of a skin color detection method provided in Embodiment 1 of the present application;
图2为本申请实施例一提供的一种视频数据的时间轴的示例图;FIG. 2 is an example diagram of a time axis of video data according to Embodiment 1 of the present application;
图3为本申请实施例一提供的一种映射函数的示例图;FIG. 3 is an example diagram of a mapping function provided in Embodiment 1 of the present application;
图4为本申请实施例一提供的一种修正映射函数的示例图;FIG. 4 is an example diagram of a modified mapping function provided by Embodiment 1 of the present application;
图5为本申请实施例一提供的一种肤色检测的概率分布对应的灰度分布图;5 is a grayscale distribution diagram corresponding to a probability distribution of skin color detection provided in Embodiment 1 of the present application;
图6为本申请实施例二提供的一种肤色检测装置的结构示意图;6 is a schematic structural diagram of a skin color detection device provided in Embodiment 2 of the present application;
图7为本申请实施例三提供的一种移动终端的结构示意图。FIG. 7 is a schematic structural diagram of a mobile terminal according to Embodiment 3 of the present application.
具体实施方式Detailed ways
下面结合附图和实施例对本申请进行说明。可以理解的是,此处所描述的具体实施例仅仅用于解释本申请,而非对本申请的限定。另外还需要说明的是, 为了便于描述,附图中仅示出了与本申请相关的部分而非全部结构。The present application will be described below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. In addition, it should be noted that, for the convenience of description, the drawings only show some, but not all, structures related to the present application.
实施例一Example 1
图1为本申请实施例一提供的一种肤色检测方法的流程图,本实施例可以人脸数据的色彩值作为先验知识进行肤色检测,该方法可以由肤色检测装置来执行,该肤色检测装置可以由软件和/或硬件实现,可配置在移动终端中,例如,手机、平板电脑、智能穿戴设备(如智能手表、智能眼镜等),等等,包括如下步骤:1 is a flowchart of a skin color detection method provided in Embodiment 1 of the present application. In this embodiment, color values of face data can be used as prior knowledge to perform skin color detection, and the method can be performed by a skin color detection device. The apparatus can be implemented by software and/or hardware, and can be configured in a mobile terminal, for example, a mobile phone, a tablet computer, a smart wearable device (such as a smart watch, smart glasses, etc.), etc., and includes the following steps:
步骤101、采集视频数据。Step 101: Collect video data.
在本实施例中,等待肤色检测的视频数据一般指在具有实时性的业务场景中所生成、传输或播放的视频数据。In this embodiment, the video data waiting for skin color detection generally refers to video data generated, transmitted or played in a real-time service scenario.
一般而言,可在生成该视频数据的移动终端中对该视频数据进行肤色检测,此时,可开启移动终端的摄像头,摄像头采集视频数据。Generally speaking, skin color detection can be performed on the video data in the mobile terminal that generates the video data. At this time, the camera of the mobile terminal can be turned on, and the camera can collect the video data.
除了在生成该视频数据的移动终端中对该视频数据进行肤色检测之外,也可以在播放该视频数据的移动终端对该视频数据进行肤色检测,本实施例对此不加以限制。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 on the mobile terminal that plays the video data, which is not limited in this embodiment.
例如,在直播的业务场景中,等待肤色检测的视频数据可以指用于承载直播内容的视频数据,主播用户所登录的移动终端产生视频数据,以及,将该视频数据通过直播平台分发到至少一个观众用户所登录的设备进行播放,此时,通常在主播用户所登录的移动终端对该视频数据进行肤色检测。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 to at least one The device logged in by the viewer user plays the video. At this time, the video data is usually detected by skin color on the mobile terminal logged in by the host user.
又例如,在视频通话的业务场景中,等待肤色检测的视频数据可以指用于承载通话内容的视频数据,发起通话的用户所登录的移动终端产生视频数据,以及,将该视频数据发送到至少一个被邀请通话的用户所登录的设备进行播放,此时,通常在发起通话的用户所登录的移动终端对该视频数据进行肤色检测。For another example, in the 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, and the mobile terminal logged in by the user who initiates the call generates video data, and sends the video data to at least A device logged in by a user who is invited to a call is played. At this time, skin color detection is usually performed on the video data on the mobile terminal logged in by the user who initiated the call.
又例如,在视频会议的业务场景中,等待肤色检测的视频数据可以指用于承载会议内容的视频数据,正在发言的用户所登录的移动终端产生视频数据,以及,将该视频数据发送到至少一个参与该会议的用户所登录的设备进行播放,此时,通常正在发言的用户所登录的移动终端对该视频数据进行肤色检测。For another example, in a video conference business scenario, the 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 video data, and the video data is sent to at least A device logged in by a user participating in the conference plays the video. At this time, the mobile terminal logged in by the user who is usually speaking performs skin color detection on the video data.
等待肤色检测的视频数据也可以指在实时性要求较低的业务场景中所生成的视频数据,如短视频等,本实施例对此不加以限制。The video data waiting for skin color detection may also refer to video data generated in a service scenario with low real-time requirements, such as a short video, which is not limited in this embodiment.
步骤102、分别在多帧图像数据中检测人脸数据。Step 102: Detect face data in multiple frames of image data respectively.
在不同的业务场景中,通常是对用户采集视频数据,因此,在视频数据的多帧图像数据中通常具有用户的人物形象,所谓人物形象,可以指图像数据中 用于表示人物的像素点。In different business scenarios, video data is usually collected from users. Therefore, the multi-frame image data of the video data usually contains the user's character image. The so-called character image can refer to the pixels in the image data used to represent the character.
该人物形象至少包括用于表示人脸的人脸数据(像素点),除此之外,还可以包括用于表示头发的头发数据(像素点)、用于表示躯体的躯体数据(像素点)、用于表示四肢的四肢数据(像素点),等等,本申请实施例对此不加以限制。The character image includes at least face data (pixels) for representing a human face, and may also include hair data (pixels) for representing hair and body data (pixels) for representing a body , limb data (pixel points) used to represent limbs, etc., which are not limited in this embodiment of the present application.
其中,对于人脸数据、躯体数据、四肢数据等可以包括用于表示皮肤的皮肤数据(像素点)。Wherein, for face data, body data, limb data, etc., skin data (pixel points) for representing skin may be included.
在本实施例中,可对多帧图像数据分别进行人脸检测,识别该图像数据中包含的人脸数据,以人脸数据作为优质的锚点,可捕捉到质量较高的皮肤数据。In this embodiment, face detection can be performed on multiple frames of image data respectively, and face data included in the image data can be identified. Using the face data as a high-quality anchor point, high-quality skin data can be captured.
在一些情况中,人脸数据以人脸关键点表示,即给定人脸数据,定位出人脸面部的关键区域位置,包括眉毛、眼睛、鼻子、嘴巴、脸部轮廓等等。In some cases, face data is represented by face key points, that is, given face data, key regions of the face are located, including eyebrows, eyes, nose, mouth, facial contours, and so on.
在另一些情况中,可以基于人脸关键点生成指定形状的范围,用该范围表示人脸数据,其中,该形状包括矩形、椭圆形等,对于矩形的范围,又可称之为人脸框。In other cases, a range of a specified shape can be generated based on the key points of the face, and the range is used to represent the face data, wherein the shape includes a rectangle, an ellipse, etc., and the range of the rectangle can also be called a face frame.
在具体实现中,可以使用如下方法对多帧图像数据进行人脸检测:In a specific implementation, the following methods can be used to perform face detection on multi-frame image data:
1、利用人工提取特征,如haar特征,使用特征训练分类器,使用分类器进行人脸检测。1. Use artificial extraction features, such as haar features, use features to train classifiers, and use classifiers for face detection.
2、从通用的目标检测算法中继承人脸检测,例如,利用Faster R-CNN来检测人脸。2. Inherit face detection from general object detection algorithms, for example, use Faster R-CNN to detect faces.
3、使用级联结构的卷积神经网络,例如,Cascade CNN(级联卷积神经网络),MTCNN(Multi-task Cascaded Convolutional Networks,多任务卷积神经网络)。3. Convolutional neural network using cascade structure, for example, Cascade CNN (Cascade Convolutional Neural Network), MTCNN (Multi-task Cascaded Convolutional Networks, multi-task convolutional neural network).
这些实现人脸检测的方法可以集成在应用的模块中,直接调用该应用的模块对图像数据进行人脸检测,这些实现人脸检测的方法也可以集成在SDK(Software Development Kit,软件开发工具包),该SDK作为应用的组装数据,应用可请求SDK对多帧图像数据进行人脸检测,SDK检测到图像数据中的人脸数据,并将人脸数据返回应用。These methods for implementing face detection can be integrated in the modules of the application, and the modules of the application are directly called to perform face detection on image data. These methods for implementing face detection can also be integrated in the SDK (Software Development Kit, software development kit). ), the SDK is used as the assembly data of the application, the application can request the SDK to perform face detection on multi-frame image data, the SDK detects the face data in the image data, and returns the face data to the application.
若该应用为与摄像头配套的系统应用,该系统应用通常为这些实现人脸检测的方法提供API(应用程序编程接口,Application Program Interface)、作为人脸检测接口,例如,在Android(安卓)系统中,提供了两个人脸检测接口android.media.FaceDetector和android.media.FaceDetector.Face,在iOS系统中,提供了两个人脸检测接口AVCaptureMetadataOutput和CIDetector。If the application is a system application supporting the camera, the system application usually provides API (Application Program Interface, Application Program Interface) for these methods of implementing face detection, as a face detection interface, for example, in the Android (Android) system , provides two face detection interfaces android.media.FaceDetector and android.media.FaceDetector.Face, in iOS system, provides two face detection interfaces AVCaptureMetadataOutput and CIDetector.
针对此情况,可调用摄像头提供的人脸检测接口,以请求在摄像头采集的多帧图像数据中检测人脸数据,接收人脸检测接口返回的一个或多个人脸框,人脸框为矩形框,可用于框定人脸数据,即人脸数据位于人脸框中。In response to this situation, you can call the face detection interface provided by the camera to request to detect the face data in the multi-frame image data collected by the camera, and receive one or more face frames returned by the face detection interface. The face frame is a rectangular frame , which can be used to frame the face data, that is, the face data is located in the face frame.
对于系统应用提供的人脸检测接口,有硬件支持,以及,基于少数人脸关键点(2个人脸关键点)标定人脸框,速度快,性能消耗很低,并且,精确度可满足作为先验知识的要求。For the face detection interface provided by the system application, there is hardware support, and the face frame is calibrated based on a few key points of the face (2 key points of the face), the speed is fast, the performance consumption is very low, and the accuracy can meet the requirements of the first knowledge requirements.
视频数据包括多帧图像数据,按照生成的顺序依次记为P 1、P 2、……、P t-1、P t、P t+1、……、P n,其中,t、n为正整数,t+1<n,由于视频数据实时生成,因此,n随着视频数据的生成而不断增大,直至视频数据生成完毕。 The video data includes multiple frames of image data, which are denoted as P 1 , P 2 , ..., P t-1 , P t , P t+1 , ... , P n in the order of generation, where t and n are positive Integer, t+1<n, since the video data is generated in real time, n increases continuously with the generation of the video data until the generation of the video data is completed.
在本实施例中,依次遍历视频数据中的每帧图像数据进行肤色检测,为了便于描述,将在第一时间点采集的图像数据称之为第一目标图像数据,将在第二时间点采集的图像数据称之为第二目标图像数据。In this embodiment, each frame of image data in the video data is sequentially traversed to perform skin color detection. For the convenience of description, the image data collected at the first time point is called the first target image data, and the image data collected at the second time point will be called the first target image data. The image data is called the second target image data.
其中,第二时间点位于第一时间点之后,一般情况下,第一时间点为与第二时间点最近的、检测到人脸数据的时间点,在时间轴上,第二时间点可以与第一时间点相邻,即第二时间点与第一时间点之间未间隔其他时间点,第二时间点也可以与第一时间点不相邻,即第二时间点与第一时间点之间间隔其他时间点。The second time point is located after the first time point. In general, the first time point is the closest time point to the second time point when face data is detected. On the time axis, the second time point may be the same as the second time point. The first time point is adjacent, that is, there is no other time point between the second time point and the first time point, and the second time point may not be adjacent to the first time point, that is, the second time point and the first time point other time points in between.
如图2所示,T表示时间轴,t 0至t 11表示时间点。 As shown in FIG. 2, T represents the time axis, and t 0 to t 11 represent time points.
例如,如图2所示,分别在时间点t 2、t 7对应的图像数据中检测到人脸数据,则对于时间点t 2-t 6,时间点t 2为第一时间点,时间点t 3-t 6为第二时间点,对于时间点t 7-t 11,时间点t 7为第一时间点,时间点t 8-t 11为第二时间点。 For example, as shown in FIG. 2 , face data is detected in the image data corresponding to time points t 2 and t 7 respectively, then for time points t 2 -t 6 , time point t 2 is the first time point, and the time point t 3 -t 6 are the second time points, for the time points t 7 -t 11 , the time point t 7 is the first time point, and the time points t 8 -t 11 are the second time points.
步骤103、响应于在第一目标图像数据中检测到人脸数据,以人脸数据的色彩值作为先验知识修正映射函数。 Step 103 , in response to detecting the face data in the first target image data, correct the mapping function by using the color value of the face data as prior knowledge.
在本实施例中,可以通过对皮肤数据、非皮肤数据等不同样本中的像素点统计色彩值的方式设置映射函数,该映射函数可用于基于色彩值识别皮肤数据,即该映射函数的输入为色彩值,输出为当前数据属于皮肤数据的概率,此时,可统计不同样本中的像素点在某一色彩值下为皮肤数据的概率,从而将这些色彩值及其概率拟合为映射函数。In this embodiment, a mapping function can be set by counting the color values of pixels in different samples such as skin data and non-skin data, and the mapping function can be used to identify skin data based on the color value, that is, the input of the mapping function is The color value is output as the probability that the current data belongs to skin data. At this time, the probability that the pixels in different samples are skin data under a certain color value can be counted, so that these color values and their probabilities can be fitted as a mapping function.
为了保持通用性,映射函数可以参照不同种族、不同年龄段、不同肤色的用户的皮肤数据,也可以参照在不同光照情况下的皮肤数据,因此,映射函数较为宽泛,精确度相对较高,但是,针对当前用户进行肤色检测的情况下,精确度有所欠缺。In order to maintain generality, the mapping function can refer to the skin data of users of different races, different ages, and different skin tones, and can also refer to the skin data under different lighting conditions. Therefore, the mapping function is relatively broad and the accuracy is relatively high, but , in the case of skin color detection for the current user, the accuracy is lacking.
一般情况下,映射函数中当前数据属于皮肤数据的概率为连续值,如[0-1],在部分情况下,映射函数中当前数据属于皮肤数据的概率为离散值,如0、1,本实施例对此不加以限制。In general, the probability that the current data in the mapping function belongs to skin data is a continuous value, such as [0-1]. In some cases, the probability that the current data in the mapping function belongs to skin data is a discrete value, such as 0, 1, this The embodiment does not limit this.
在一个示例中,如图3所示,在映射函数所处坐标系中,横坐标(横轴)为色彩值(X)、纵坐标(纵轴)为当前数据属于皮肤数据的概率(P)。In an example, as shown in FIG. 3 , in the coordinate system where the mapping function is located, the abscissa (horizontal axis) is the color value (X), and the ordinate (vertical axis) is the probability (P) that the current data belongs to skin data .
该映射函数包括依次连接的第一色彩映射段(横坐标为[x 0,x 1])、第二色彩映射段(横坐标为[x 1,x 2])、第三色彩映射段(横坐标为[x 2,x 3]),其中,第一色彩映射段中当前数据属于皮肤数据的概率从0上升至1,第二色彩映射段中当前数据属于皮肤数据的概率为1,第三色彩映射段中当前数据属于皮肤数据的概率从1下降至0。 The mapping function includes a first color map segment (the abscissa is [x 0 , x 1 ]), a second color map segment (the abscissa is [x 1 , x 2 ]), and a third color map segment (the abscissa is [x 1 , x 2 ]), which are connected in sequence The coordinates are [x 2 , x 3 ]), wherein the probability that the current data in the first color mapping segment belongs to skin data increases from 0 to 1, the probability that the current data in the second color mapping segment belongs to skin data is 1, and the third The probability that the current data in the colormap segment belongs to skin data decreases from 1 to 0.
在一个示例中,第二色彩映射段属于线段,第一色彩映射段、第三色彩映射段属于曲线,可以通过使用多项式函数等方式进行拟合。In an example, the second color map segment belongs to a line segment, and the first color map segment and the third color map segment belong to a curve, which can be fitted by using a polynomial function or the like.
上述映射函数只是作为示例,在实施本申请实施例时,可以根据实际情况设置其它映射函数,例如,该映射函数包括依次连接的第一色彩映射段、第二色彩映射段,其中,第一色彩映射段中当前数据属于皮肤数据的概率从0上升至1,第二色彩映射段中当前数据属于皮肤数据的概率从1下降至0,此时,映射函数以一元二次方程等函数表达,等等,本申请实施例对此不加以限制。另外,除了上述映射函数外,本领域技术人员还可以根据实际需要采用其它映射函数,本申请实施例对此也不加以限制。The above mapping function is only an example. When implementing the embodiments of the present application, other mapping functions may 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 first color The probability that the current data in the mapping segment belongs to skin data increases from 0 to 1, and the probability that the current data in the second color mapping segment belongs to skin data decreases from 1 to 0. At this time, the mapping function is expressed by functions such as a quadratic equation, etc. etc., which are not limited in the embodiments of the present application. In addition, in addition to the above mapping function, those skilled in the art may also adopt other mapping functions according to actual needs, which are not limited in the embodiments of the present application.
在不同颜色空间中,色彩值具有不同的色度分量,可针对色彩分量设置相应的映射函数,例如,在RGB颜色空间中,具有红色色度分量(R)、绿色色度分量(G)、蓝色色度分量(B),则可以针对红色色度分量(R)设置映射函数、针对绿色色度分量(G)设置映射函数、针对蓝色色度分量(B)设置映射函数,又例如,在YCbCr颜色空间中,具有蓝色色度分量(Cb)、红色色度分量(Cr),则可以针对蓝色色度分量(Cb)设置映射函数、针对红色色度分量(Cr)设置映射函数,等等。In different color spaces, color values have different chrominance components, and corresponding mapping functions can be set for the color components. For example, in the RGB color space, there are red chrominance components (R), green chrominance components (G), For the blue chrominance component (B), the mapping function may be set for the red chrominance component (R), the mapping function may be set for the green chrominance component (G), and the mapping function may be set for the blue chrominance component (B), and for example, in In the YCbCr color space, with blue chrominance components (Cb) and red chrominance components (Cr), you can set the mapping function for the blue chrominance component (Cb), set the mapping function for the red chrominance component (Cr), etc. .
如果在第一目标图像数据(即第一目标图像数据为在第一时间点采集的图像数据)中检测到人脸数据,则可以在人脸数据的范围内统计色彩值,该统计的色彩值为皮肤数据的色彩值的置信度较高,可作为先验知识、针对当前用户修正映射函数,提高映射函数对于当前用户的精确度。If face data is detected in the first target image data (that is, the first target image data is the image data collected at the first time point), the color value can be counted within the range of the face data, and the counted color value The confidence of the color value of the skin data is high, which can be used as a priori knowledge to correct the mapping function for the current user and improve the accuracy of the mapping function for the current user.
在本申请的一个实施例中,步骤103可以包括如下步骤:In an embodiment of the present application, step 103 may include the following steps:
步骤1031、确定映射函数。Step 1031: Determine the mapping function.
在本实施例中,映射函数的横坐标为色彩值、纵坐标为当前数据属于皮肤数据的概率,映射函数包括依次连接的第一色彩映射段、第二色彩映射段、第三色彩映射段,第一色彩映射段中当前数据属于皮肤数据的概率从0上升至1,第二色彩映射段中当前数据属于皮肤数据的概率为1,第三色彩映射段中当前数据属于皮肤数据的概率从1下降至0。In this embodiment, the abscissa of the mapping function is the color value, and the ordinate is the probability that the current data belongs to skin data, and the mapping function includes a first color mapping segment, a second color mapping segment, and a third color mapping segment connected in sequence, The probability that the current data in the first color map segment belongs to skin data increases from 0 to 1, the probability that the current data in the second color map segment belongs to skin data is 1, and the probability that the current data in the third color map segment belongs to skin data increases from 1 down to 0.
步骤1032、基于颜色空间在人脸数据中检测皮肤数据。Step 1032: Detect skin data in the face data based on the color space.
在本实施例中,若第一目标图像数据中存在多个人脸数据,则可以分别统计多个人脸数据的面积,若人脸数据以人脸框框定,该人脸框的宽为w,高为h,则该人脸数据的面积In this embodiment, if there are multiple face data in the first target image data, the area of the multiple face data can be counted separately. If the face data is framed by a face frame, the width of the face frame is w and the height is w. is h, then the area of the face data
S=w×h。S=w×h.
将多个个人脸数据的面积进行比较,提取面积最大的n(n为正整数,如3)个人脸数据,待检测皮肤数据、统计皮肤数据的颜色值,由于摄像头的成像特性、回调人脸数据的方法,其对面积较大的人脸数据的颜色描述较为准确,选择面积最大的n个人脸数据可以在降低计算量的情况下、保证后续统计皮肤数据的颜色值的精确度。Compare the areas of multiple personal face data, extract the face data with the largest area n (n is a positive integer, such as 3), the skin data to be detected, and the color value of the statistical skin data, due to the imaging characteristics of the camera, the callback face The data method can accurately describe the color of the face data with a larger area. Selecting the n face data with the largest area can ensure the accuracy of the color value of the subsequent statistical skin data under the condition of reducing the amount of calculation.
例如,面积最大的n个人脸数据,可为,按照面积从大至小对人脸数据进行排序,n个人脸数据可为此排序中的前n个人脸数据。但不限制于此类基于面积大小选取人脸数据的选取方式。For example, the n face data with the largest area may be the face data sorted according to the area from large to small, and the n face data may be the top n face data in the sorting. However, it is not limited to such a selection method of selecting face data based on the size of the area.
在第一目标图像数据中存在多个人脸数据的情况下,也可以基于颜色空间在全部人脸数据中检测皮肤数据,本实施例对此不加以限制。In the case where there are multiple face data in the first target image data, skin data may also be detected in all the face data based on the color space, which is not limited in this embodiment.
针对已检测到的人脸数据,可使用基于颜色空间的方法在该人脸数据中进行肤色检测,检测表示皮肤数据的像素点,基于颜色空间的方法计算简单,因此,计算速度快,耗时少,统计多个皮肤数据的颜色值可以在整体上保持较高的精确度,满足先验知识的要求。For the detected face data, the color space-based method can be used to detect the skin color in the face data, and the pixels representing the skin data can be detected. The color space-based method is simple to calculate, so the calculation speed is fast and time-consuming. Counting the color values of multiple skin data can maintain a high accuracy as a whole, meeting the requirements of prior knowledge.
由于图像数据的颜色空间有所不同,针对不同的颜色空间,可使用与该颜色空间相应的方法在人脸数据中检测皮肤数据,或者,将图像数据转换至指定的颜色空间中,使用与指定的颜色空间相应的方法在人脸数据中检测皮肤数据,本实施例对此不加以限制。Since the color space of the image data is different, for different color spaces, you can use the method corresponding to the color space to detect the skin data in the face data, or convert the image data to the specified color space, use and specify The method corresponding to the color space of 1 detects skin data in the face data, which is not limited in this embodiment.
在一个示例中,针对RGB颜色空间,像素点的色彩值符合如下条件时,可以认为该像素点是皮肤数据(即该像素点属于皮肤数据的概率为1),像素点的色彩值不符合如下条件时,可以认为该像素点不是皮肤数据(即该像素点属于 皮肤数据的概率为0):In an example, for the RGB color space, when the color value of a pixel meets the following conditions, it can be considered that the pixel is skin data (that is, the probability that the pixel belongs to skin data is 1), and the color value of the pixel does not meet the following conditions When the conditions are met, it can be considered that the pixel is not skin data (that is, the probability that the pixel belongs to skin data is 0):
R>95,G>40,B>20,R>G,R>BR>95, G>40, B>20, R>G, R>B
(Max(R,G,B)-Min(R,G,B))>15(Max(R,G,B)-Min(R,G,B))>15
Abs(R-G)>5Abs(R-G)>5
其中,Max表示取最大值,Min表示取最小值,Abs表示取绝对值。Among them, Max represents the maximum value, Min represents the minimum value, and Abs represents the absolute value.
其中,R表示红色色度分量,G表示绿色色度分量,B表示蓝色色度分量。Among them, R represents the red chrominance component, G represents the green chrominance component, and B represents the blue chrominance component.
在另一个示例中,针对YCbCr颜色空间,像素点的色彩值符合如下条件时,可以认为该像素点是皮肤数据(即该像素点属于皮肤数据的概率为1),像素点的色彩值不符合如下条件时,可以认为该像素点不是皮肤数据(即该像素点属于皮肤数据的概率为0):In another example, for the YCbCr color space, when the color value of a pixel meets the following conditions, it can be considered that the pixel is skin data (that is, the probability that the pixel belongs to skin data is 1), and the color value of the pixel does not meet the following conditions. Under the following conditions, it can be considered that the pixel is not skin data (that is, the probability that the pixel belongs to skin data is 0):
Figure PCTCN2021141248-appb-000001
Figure PCTCN2021141248-appb-000001
Figure PCTCN2021141248-appb-000002
Figure PCTCN2021141248-appb-000002
Figure PCTCN2021141248-appb-000003
Figure PCTCN2021141248-appb-000003
其中,Cb表示蓝色色度分量,Cr表示红色色度分量。Among them, Cb represents the blue chrominance component, and Cr represents the red chrominance component.
对于调用摄像头提供的人脸检测接口进行人脸检测的情况,人脸数据可能包含头发数据、背景数据等非皮肤数据,此时,可往中心对人脸数据进行收敛,获得候选区域图像,从而减少人脸数据的在边缘的区域,减少非皮肤数据的数量,提高皮肤数据的占比,从而基于颜色空间在候选区域图像中检测皮肤数据,提高检测皮肤数据的准确度。For the case of calling the face detection interface provided by the camera for face detection, the face data may include non-skin data such as hair data and background data. Reduce the area of face data on the edge, reduce the amount of non-skin data, and increase the proportion of skin data, so as to detect skin data in candidate area images based on color space, and improve the accuracy of skin data detection.
在一个收敛的示例中,若人脸数据以人脸框框定,则可以确定人脸框的中心点P(x 0,y 0),在维持中心点P(x 0,y 0)的条件下,缩小人脸框的宽与高,作为候选区域图像。将人脸框的中心点P(x 0,y 0)设置为候选区域图像的中心点P(x 0,y 0),即保持中心点P(x 0,y 0)不变,在此条件下,缩小人脸框的宽与高,作为候选区域图像的宽与高。 In a convergent example, if the face data is framed by a face frame, the center point P(x 0 , y 0 ) of the face frame can be determined, and on the condition that the center point P(x 0 , y 0 ) is maintained , reduce the width and height of the face frame as a candidate area image. Set the center point P(x 0 , y 0 ) of the face frame as the center point P(x 0 , y 0 ) of the candidate region image, that is, keep the center point P(x 0 , y 0 ) unchanged, under this condition Next, reduce the width and height of the face frame as the width and height of the candidate area image.
设人脸框的宽为w,高为h,则候选区域图像可表示为[x 0±(a*w),y 0±(b*h)[,其中,a为小于1的系数,如0.4,b为小于1的系数,如0.1。 Let the width of the face frame be w and the height be h, the candidate area image can be expressed as [x 0 ±(a*w), y 0 ±(b*h)[, where a is a coefficient less than 1, such as 0.4, b is a coefficient less than 1, such as 0.1.
步骤1033、对皮肤数据统计色彩值。Step 1033 , count the color values of the skin data.
对于属于皮肤数据的像素点,可统计多个像素点之间的色彩值的平均值,作为皮肤数据整体的色彩值。For the pixel points belonging to the skin data, the average value of the color values among multiple pixel points can be counted as the color value of the entire skin data.
步骤1034、在映射函数所处坐标系的横轴上标记皮肤数据的色彩值。Step 1034: Mark the color value of the skin data on the horizontal axis of the coordinate system where the mapping function is located.
如图4所示,若统计皮肤数据的色彩值C,则可以将皮肤数据的色彩值C标记在映射函数所处坐标系的横轴上。As shown in FIG. 4 , if the color value C of the skin data is counted, the color value C of the skin data can be marked on the horizontal axis of the coordinate system where the mapping function is located.
由于皮肤数据的色彩值C的精确度较高,皮肤数据的色彩值C一般位于映射函数的第二色彩映射段(横坐标为[x 1,x 2])中。 Due to the high precision of the color value C of the skin data, the color value C of the skin data is generally located in the second color mapping segment of the mapping function (the abscissa is [x 1 , x 2 ]).
步骤1035、在维持第一色彩映射段、第三色彩映射段的条件下,参考皮肤数据的色彩值缩小第二色彩映射段。Step 1035 , under the condition that the first color map segment and the third color map segment are maintained, reduce the second color map segment with reference to the color value of the skin data.
在具体实现中,可以将映射函数整体性地向皮肤数据的色彩值C进行收敛,减少映射函数的范围,排除一些概率较低的区域。In a specific implementation, the mapping function can be converged to the color value C of the skin data as a whole, the range of the mapping function can be reduced, and some regions with low probability can be excluded.
在收敛映射函数的过程中,以维持第一色彩映射段、第三色彩映射段的形状不变作为前提条件,以当前场景中用户的皮肤数据的色彩值作为参考,缩小第二色彩映射段的范围,以及,相应调整第一色彩映射段、第三色彩映射段的范围。In the process of converging the mapping function, the shape of the first color mapping segment and the third color mapping segment are kept unchanged as a precondition, and the color value of the user's skin data in the current scene is used as a reference to reduce the size of the second color mapping segment. range, and adjust the range of the first color map segment and the third color map segment accordingly.
在本申请的一个实施例中,步骤1035包括如下步骤:In an embodiment of the present application, step 1035 includes the following steps:
步骤10351、朝皮肤数据的色彩值收敛第二色彩映射段。Step 10351: Converging the second color map segment towards the color value of the skin data.
以皮肤数据的色彩值作为指定的位置,如中点、分位点等,在横坐标上朝该皮肤数据的色彩值的所在位置收敛第二色彩映射段,从而缩小第二色彩映射段的范围。Taking the color value of the skin data as the specified position, such as the midpoint, the quantile point, etc., converge the second color map segment on the abscissa toward the location of the color value of the skin data, thereby narrowing the range of the second color map segment .
收敛第二色彩映射段时,可收敛第二色彩映射段的任意一端,也可以同时收敛第二色彩映射段的两端,本实施例对此不加以限制。When converging the second color mapping segment, either end of the second color mapping segment may be converged, or both ends of the second color mapping segment may be converged at the same time, which is not limited in this embodiment.
如图4所示,在横轴上标记皮肤数据的色彩值C,朝皮肤数据的色彩值C同时收敛第二色彩映射段的两端,收敛之前第二色彩映射段的横坐标为[x 1,x 2],收敛之后第二色彩映射段的横坐标为[x 1',x 2'],其中,x 1'>x 1,x 2'<x 2As shown in FIG. 4 , the color value C of the skin data is marked on the horizontal axis, and the two ends of the second color mapping segment are converged toward the color value C of the skin data at the same time, and the abscissa of the second color mapping segment before convergence is [x 1 , x 2 ], the abscissa of the second color mapping segment after convergence is [x 1 ', x 2 '], where x 1 '>x 1 , x 2 '<x 2 .
在一种收敛的方式中,可确定目标长度L t,假设第二色彩映射段的长度为L,目标长度L t小于第二色彩映射段的长度L,即L t<L,以皮肤数据的色彩值C作为中心点缩小第二色彩映射段,直至第二色彩映射段的长度L与目标长度L t相等,从而缩小第二色彩映射段的范围。 In a convergent manner, the target length L t can be determined. Assuming that the length of the second color map segment is L, the target length L t is less than the length L of the second color map segment, that is, L t <L. The color value C is used as the center point to reduce the second color map segment until the length L of the second color map segment is equal to the target length L t , thereby reducing the range of the second color map segment.
如图4所示,第二色彩映射段的长度为L=x 2-x 1,目标长度L t=x 2′-x 1′,皮肤数据的色彩值
Figure PCTCN2021141248-appb-000004
As shown in FIG. 4 , the length of the second color map segment is L=x 2 -x 1 , the target length L t =x 2 ′-x 1 ′, and the color value of the skin data is
Figure PCTCN2021141248-appb-000004
在一些情况下,目标长度L t为统计值,属于常数。 In some cases, the target length L t is a statistical value, which is a constant.
在另一些情况下,目标长度L t为自适应的调整的数值,属于变量。 In other cases, the target length L t is an adaptively adjusted value, which is a variable.
例如,可确定基准长度T,基准长度T为统计值,属于常数,其小于第二色彩映射段的长度L,即T<L。For example, the reference length T may be determined, and the reference length T is a statistical value, which is a constant, and is smaller than the length L of the second color map segment, that is, T<L.
计算第二色彩映射段的长度L与基准长度T之间的差值,作为可调长度;Calculate the difference between the length L of the second color map segment and the reference length T as an adjustable length;
通过预设的映射方式f()将第二时间点与第一时间点之间的时间差Δt映射为修正系数w t,修正系数w t与时间差正相关,即时间差越大,修正系数w t越大,反之,时间差越小,修正系数w t越小。 The time difference Δt between the second time point and the first time point is mapped to the correction coefficient w t by the preset mapping method f(), and the correction coefficient w t is positively correlated with the time difference, that is, the larger the time difference, the greater the correction coefficient w t On the contrary, the smaller the time difference, the smaller the correction coefficient w t .
计算可调长度与修正系数w t之间的乘积,作为修正长度,计算基准长度T与修正长度之间的和值,作为目标长度L tCalculate the product between the adjustable length and the correction coefficient w t as the correction length, and calculate the sum between the reference length T and the correction length as the target length L t .
此时,目标长度L t的计算过程可如下表示: At this time, the calculation process of the target length L t can be expressed as follows:
L t=T+(L-T)*w t L t =T+(LT)*w t
w t=f(Δt) w t =f(Δt)
第二时间点距离第一时间点越近,场景中光照等条件变化的概率较低,在第一时间点中统计的皮肤数据的色彩值参考价值越高,第二时间点距离第一时间点越远,场景中光照等条件变化的概率较高,在第一时间点中统计的皮肤数据的色彩值的参考价值越低,因此,随着检测到人脸数据的图像数据(即第一时间点)离当前时间(第二时间点)越来越远,那么,逐渐放宽目标长度L t,使得目标长度L t越来越接近第二色彩映射段的长度L,从而保证修正之后的第二色彩映射段的准确性。 The closer the second time point is to the first time point, the lower the probability of changes in lighting and other conditions in the scene, and the higher the reference value of the color value of the skin data counted in the first time point. The second time point is closer to the first time point. The farther away, the higher the probability of changes in lighting and other conditions in the scene, and the lower the reference value of the color value of the skin data counted at the first time point. point) is farther and farther away from the current time (second time point), then gradually relax the target length L t , so that the target length L t is getting closer and closer to the length L of the second color mapping segment, so as to ensure that the second Accuracy of colormap segments.
步骤10352、向靠近第二色彩映射段的方向平移第一色彩映射段,直至第一色彩映射段接驳第二色彩映射段。Step 10352: Shift the first color mapping segment in a direction close to the second color mapping segment until the first color mapping segment is connected to the second color mapping segment.
如图4所示,若完成收敛第二色彩映射段,则可以在横轴上向右平移第一色彩映射段,使得第一色彩映射段朝第二色彩映射段移动,直至第一色彩映射段接驳第二色彩映射段,即第一色彩映射段接驳第二色彩映在端点x 1'处相接,平移之前第一色彩映射段的横坐标为[x 0,x 1],平移之后第一色彩映射段的横坐标为[x 0',x 1'],其中,x 0'>x 0,x 1'>x 1,并且,x 1-x 0=x 1'-x 0'。 As shown in FIG. 4 , if the convergence of the second color mapping segment is completed, the first color mapping segment can be shifted to the right on the horizontal axis, so that the first color mapping segment moves toward the second color mapping segment until the first color mapping segment is reached. The second color map segment is connected, that is, the first color map segment is connected to the second color map at the endpoint x 1 ', and the abscissa of the first color map segment before translation is [x 0 , x 1 ], after translation The abscissa of the first color map segment is [x 0 ', x 1 '], where x 0 '>x 0 , x 1 '>x 1 , and x 1 -x 0 =x 1 '-x 0 ' .
步骤10353、向靠近第二色彩映射段的方向平移第三色彩映射段,直至第三色彩映射段接驳第二色彩映射段。Step 10353: Shift the third color mapping segment in a direction close to the second color mapping segment until the third color mapping segment is connected to the second color mapping segment.
如图4所示,若完成收敛第二色彩映射段,则可以在横轴上向左平移第三色彩映射段,使得第三色彩映射段朝第二色彩映射段移动,直至第三色彩映射 段接驳第二色彩映射段,即第三色彩映射段接驳第二色彩映在端点x 2'处相接,平移之前第三色彩映射段的横坐标为[x 2,x 3],平移之后第二色彩映射段的横坐标为[x 2',x 3'],其中,x 2'<x 2,x 3'<x 3,并且,x 3-x 2=x 3'-x 2'。 As shown in FIG. 4 , if the convergence of the second color mapping segment is completed, the third color mapping segment can be shifted to the left on the horizontal axis, so that the third color mapping segment moves toward the second color mapping segment until the third color mapping segment is reached. The second color map segment is connected, that is, the third color map segment is connected to the second color map at the endpoint x 2 '. Before the translation, the abscissa of the third color map segment is [x 2 , x 3 ]. After the translation The abscissa of the second color map segment is [x 2 ', x 3 '], where x 2 '<x 2 , x 3 '<x 3 , and x 3 -x 2 =x 3 '-x 2 ' .
步骤104、将第二目标图像数据的色彩值代入映射函数中,以在第二目标图像数据中检测皮肤数据。Step 104: Substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data.
在第一时间点对应的第一目标图像数据检测到人脸数据,并以该人脸数据中人脸数据的色彩值作为先验知识修正映射函数,该映射函数可以在位于第一时间点之后的第二时间点,对第二目标图像数据(即第二目标图像数据为在第二时间点采集的图像数据)进行肤色检测,从而在第二目标图像数据中检测像素点表征皮肤数据的程度。The face data is detected at the first target image data corresponding to the first time point, and the color value of the face data in the face data is used as the prior knowledge to correct the mapping function. The mapping function can be located after the first time point. At the second time point, skin color detection is performed on the second target image data (that is, the second target image data is the image data collected at the second time point), so as to detect the degree to which the pixel points represent the skin data in the second target image data .
在一实施例中,可在映射函数所处的坐标系中的横轴标记第二目标图像数据每个像素点的色彩值,若第二目标图像数据中像素点的色彩值在映射函数外,则该像素点属于皮肤数据的概率为0,若第二目标图像数据中像素点的色彩值在映射函数内,则可通过映射函数查找该色彩值在纵轴对应的概率,作为该像素点属于皮肤数据的概率。In one embodiment, the color value of each pixel of the second target image data can be marked on the horizontal axis in the coordinate system where the mapping function is located. If the color value of the pixel in the second target image data is outside the mapping function, Then the probability that the pixel belongs to the skin data is 0. If the color value of the pixel in the second target image data is within the mapping function, the probability corresponding to the color value on the vertical axis can be found through the mapping function, as the pixel belongs to. Probability of skin data.
在一些情况中,映射函数的横坐标为色彩值、纵坐标为像素点属于皮肤数据的概率,在不同颜色空间中,色彩值具有不同的色度分量,每个色彩分量具有相应的映射函数,针对同一个像素点,可计算出不同的概率。In some cases, the abscissa of the mapping function is the color value, and the ordinate is the probability that the pixel belongs to the skin data. In different color spaces, the color value has different chromaticity components, and each color component has a corresponding mapping function, For the same pixel, different probabilities can be calculated.
针对此情况,可查询第二目标图像数据中每个像素点的色彩值,将色彩值代入相应的映射函数中,以映射出每个像素点在该色彩值下属于皮肤数据的候选概率,基于这些候选概率,可使用求平均值、求和、乘积、线性融合(即配置权重之后求和)等方式计算像素点属于皮肤数据的目标概率,这些目标概率体现了肤色的ROI(region of interest,感兴趣区域)区域。In view of this situation, the color value of each pixel in the second target image data can be queried, and the color value can be substituted into the corresponding mapping function to map out the candidate probability that each pixel belongs to the skin data under the color value, based on These candidate probabilities can be calculated by averaging, summing, multiplying, linear fusion (that is, summing after configuring weights) to calculate the target probability that the pixel belongs to the skin data. These target probabilities reflect the ROI (region of interest, region of interest) area.
在一个示例中,针对YCbCr颜色空间,第二目标图像数据具有蓝色色度分量Cb、红色色度分量Cr。In one example, for the YCbCr color space, the second target image data has a blue chrominance component Cb, a red chrominance component Cr.
一方面,将蓝色色度分量Cb的色彩值代入蓝色色度分量Cb对应的映射函数中,以映射出像素点在蓝色色度分量Cb下属于皮肤数据的蓝色概率,作为候选概率
Figure PCTCN2021141248-appb-000005
On the one hand, the color value of the blue chrominance component Cb is substituted into the mapping function corresponding to the blue chrominance component Cb, so as to map out the blue probability that the pixel belongs to the skin data under the blue chrominance component Cb, as the candidate probability
Figure PCTCN2021141248-appb-000005
另一方面,将红色色度分量Cr的色彩值代入红色色度分量Cr对应的映射函数中,以映射出像素点在红色色度分量Cr下属于皮肤数据的红色概率,作为 候选概率
Figure PCTCN2021141248-appb-000006
On the other hand, the color value of the red chrominance component Cr is substituted into the mapping function corresponding to the red chrominance component Cr, so as to map the red probability that the pixel belongs to the skin data under the red chrominance component Cr, as the candidate probability
Figure PCTCN2021141248-appb-000006
此时,可计算蓝色概率
Figure PCTCN2021141248-appb-000007
与红色概率
Figure PCTCN2021141248-appb-000008
之间的乘积,作为像素点属于皮肤数据的目标概率
Figure PCTCN2021141248-appb-000009
At this point, the blue probability can be calculated
Figure PCTCN2021141248-appb-000007
with red probability
Figure PCTCN2021141248-appb-000008
The product between , as the target probability that the pixel belongs to the skin data
Figure PCTCN2021141248-appb-000009
此外,若在先未检测到人脸数据,缺少较为优质的锚点,较难捕捉到质量较高的皮肤数据,则可以基于颜色空间在图像数据中检测皮肤数据。In addition, if the face data is not detected before, there is a lack of relatively high-quality anchor points, and it is difficult to capture high-quality skin data, the skin data can be detected in the image data based on the color space.
例如,如图2所示,若在时间点t 0、t 1之前的图像数据中未检测到人脸数据,则可以基于颜色空间的方法在t 0、t 1对应的图像数据中检测皮肤数据。 For example, as shown in FIG. 2 , if no face data is detected in the image data before time points t 0 and t 1 , skin data can be detected in the image data corresponding to t 0 and t 1 based on the color space method. .
在肤色检测之后,可以按照用户的需求,对视频数据进行美颜处理(如磨皮处理)等操作。After the skin color is detected, operations such as beautifying processing (such as skin resurfacing) can be performed on the video data according to the needs of the user.
为使本领域技术人员更好地理解本申请实施例,以下通过具体的示例来说明本实施例中的肤色检测方法。In order for those skilled in the art to better understand the embodiments of the present application, the following specific examples are used to describe the skin color detection method in this embodiment.
如图5所示,针对同一帧图像数据,左侧为使用基于颜色空间进行肤色检测所得到的概率分布对应的灰度分布,右侧为应用本实施例进行肤色检测所得到的概率分布对应的灰度分布,其中,像素点的灰度越高(越偏白色)表示该像素点属于皮肤数据的概率越高,灰度越低(越偏黑色)表示该像素点属于皮肤数据的概率越低。As shown in Figure 5, for the same frame of image data, the left side is the grayscale distribution corresponding to the probability distribution obtained by using the color space-based skin color detection, and the right side is the probability distribution corresponding to the skin color detection obtained by applying this embodiment. Grayscale distribution, in which, the higher the grayscale of a pixel (more white), the higher the probability that the pixel belongs to skin data, and the lower the grayscale (more black), the lower the probability that the pixel belongs to skin data. .
两者对比而言,基于颜色空间进行肤色检测将衣服、头发、背景(如电灯等)均较多地认为属于皮肤数据,而本实施例可以很好地排除衣服、头发、背景(如电灯等),大大提高了肤色检测的准确率,在后续的美颜处理(如磨皮)中可以很好地保护衣服、头发、背景(如电灯等)。In contrast, the skin color detection based on the color space considers clothes, hair, and backgrounds (such as electric lights, etc.) to belong to skin data, and this embodiment can well exclude clothes, hair, and backgrounds (such as electric lights, etc.). ), which greatly improves the accuracy of skin color detection, and can well protect clothes, hair, and backgrounds (such as lights, etc.) in subsequent beauty treatments (such as microdermabrasion).
在本实施例中,采集视频数据,视频数据包括多帧图像数据,分别在多帧图像数据中检测人脸数据,若在第一目标图像数据中检测到人脸数据,则以人脸数据的色彩值作为先验知识修正映射函数,映射函数用于基于色彩值识别皮肤数据,第一目标图像数据为在第一时间点采集的图像数据,将第二目标图像数据的色彩值代入映射函数中,以在第二目标图像数据中检测皮肤数据,第二目标图像数据为在第二时间点采集的图像数据,视频数据具有连续性,因此,多帧图像数据之间的内容具有相关性,使得在先的图像数据可以作为在后的图像数据的先验知识,以人脸数据作为锚点可以捕捉到优质的皮肤数据,可以在当前的业务场景中对皮肤数据统计出较为准确的色彩值,以此自适应修正映射 函数,可以提高映射函数在当前的业务场景中进行肤色检测的准确性,并且,人脸检测、统计皮肤数据的颜色值、映射函数的修正及其应用等操作均较为简单,计算量少、速度快、耗时短,在移动终端等设备性能受限的情况下,可实现实时对视频数据进行肤色检测。In this embodiment, video data is collected, and the video data includes multiple frames of image data, and face data is detected in the multiple frames of image data respectively. If face data is detected in the first target image data, the face data The color value is used as a priori knowledge to correct the mapping function, the mapping function is used to identify skin data based on the color value, the first target image data is the image data collected at the first time point, and the color value of the second target image data is substituted into the mapping function , in order to detect skin data in the second target image data, the second target image data is the image data collected at the second time point, the video data has continuity, therefore, the content between multiple frames of image data has correlation, so that The previous image data can be used as the prior knowledge of the subsequent image data, and the face data can be used as the anchor to capture high-quality skin data. This adaptive modification of the mapping function can improve the accuracy of skin color detection performed by the mapping function in the current business scenario, and operations such as face detection, statistics of the color value of the skin data, correction of the mapping function and its application are relatively simple. , the calculation amount is small, the speed is fast, and the time-consuming is short. In the case of limited performance of mobile terminals and other equipment, the skin color detection of video data can be realized in real time.
在一实施例中,在提高肤色检测的准确性的情况下,可以在色彩的维度下排除一些与皮肤数据相似的数据,如头发、衣服、背景等,使得在后续美颜处理(如磨皮处理)中保护与皮肤数据相似的数据,减缓或避免与皮肤数据相似的数据因美颜处理(如磨皮处理)而导致清晰度下降的情况,从而保证美颜处理的质量。In one embodiment, under the condition of improving the accuracy of skin color detection, some data similar to skin data, such as hair, clothes, background, etc., can be excluded in the dimension of color, so that in the subsequent beauty processing (such as microdermabrasion) Protect the data similar to the skin data in the processing), slow down or avoid the reduction of the clarity of the data similar to the skin data due to the beauty treatment (such as microdermabrasion), so as to ensure the quality of the beauty treatment.
对于方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本申请实施例并不受所描述的动作顺序的限制,因为依据本申请实施例,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所描述的实施例所涉及的动作并不一定是本申请实施例所必须的。The method embodiments are described as a series of action combinations for the sake of simple description, but those skilled in the art should know that the embodiments of the present application are not limited by the described sequence of actions, because according to the embodiments of the present application , certain steps may be performed in other orders or simultaneously. Secondly, those skilled in the art should also know that the actions involved in the embodiments described in the specification are not necessarily required by the embodiments of the present application.
实施例二Embodiment 2
图6为本申请实施例二提供的一种肤色检测装置的结构框图,可以包括如下模块:6 is a structural block diagram of a skin color detection device provided in Embodiment 2 of the present application, which may include the following modules:
视频数据采集模块601,设置为采集视频数据,所述视频数据包括多帧图像数据;The video data collection module 601 is configured to collect video data, and the video data includes multiple frames of image data;
人脸数据检测模块602,设置为分别在多帧所述图像数据中检测人脸数据;A face data detection module 602, configured to detect face data in the multiple frames of the image data respectively;
映射函数修正模块603,设置为响应于在第一目标图像数据中检测到人脸数据,以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,所述映射函数用于基于色彩值识别皮肤数据,所述第一目标图像数据为在第一时间点采集的图像数据;The mapping function correction module 603 is configured to modify the mapping function with the color value of the face data in the first target image data as prior knowledge in response to detecting the face data in the first target image data, and the mapping function The function is used to identify skin data based on the color value, and the first target image data is the image data collected at the first time point;
映射检测模块604,设置为将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,所述第二目标图像数据为在第二时间点采集的图像数据。The mapping detection module 604 is configured to substitute the color value of the second target image data into the mapping function, so as to detect skin data in the second target image data, the second target image data is at the second time point acquired image data.
在本申请的一个实施例中,所述人脸数据检测模块602包括:In an embodiment of the present application, the face data detection module 602 includes:
人脸检测接口调用模块,设置为调用摄像头提供的人脸检测接口,以请求在所述摄像头采集的多帧所述图像数据中检测人脸数据;a face detection interface calling module, configured to call the face detection interface provided by the camera, to request to detect the face data in the multiple frames of the image data collected by the camera;
人脸框接收模块,设置为接收所述人脸检测接口返回的至少一个人脸框,所述人脸框用于框定人脸数据。The face frame receiving module is configured to receive at least one face frame returned by the face detection interface, where the face frame is used to frame face data.
在本申请的一个实施例中,所述映射函数修正模块603包括:In an embodiment of the present application, the mapping function correction module 603 includes:
映射函数确定模块,设置为确定映射函数,所述映射函数的横坐标为色彩值、纵坐标为当前数据属于皮肤数据的概率,所述映射函数包括依次连接的第一色彩映射段、第二色彩映射段、第三色彩映射段,所述第一色彩映射段中当前数据属于皮肤数据的概率从0上升至1,所述第二色彩映射段中当前数据属于皮肤数据的概率为1,所述第三色彩映射段中当前数据属于皮肤数据的概率从1下降至0;The mapping function determination module is set to determine the mapping function, the abscissa of the mapping function is the color value, and the ordinate is the probability that the current data belongs to the skin data, and the mapping function includes the first color mapping segment and the second color that are connected in turn. mapping section and third color mapping section, the probability that the current data in the first color mapping section belongs to skin data increases from 0 to 1, the probability that the current data in the second color mapping section belongs to skin data is 1, and the The probability that the current data in the third color map segment belongs to skin data decreases from 1 to 0;
人脸皮肤检测模块,设置为基于颜色空间在所述第一目标图像数据中的人脸数据中检测皮肤数据;a face skin detection module, configured to detect skin data in the face data in the first target image data based on the color space;
色彩值统计模块,设置为对所述皮肤数据统计色彩值;a color value statistics module, configured to count color values for the skin data;
色彩值标记模块,设置为在所述映射函数所处坐标系的横轴上标记基于所述皮肤数据统计的所述色彩值;A color value marking module, configured to mark the color value based on the statistics of the skin data on the horizontal axis of the coordinate system where the mapping function is located;
色彩映射段修正模块,设置为在维持所述第一色彩映射段、所述第三色彩映射段的条件下,参考基于所述皮肤数据统计的所述色彩值缩小所述第二色彩映射段。The color map segment correction module is configured to reduce the second color map segment with reference to the color value based on the statistics of the skin data under the condition of maintaining the first color map segment and the third color map segment.
在本申请的一个实施例中,所述映射函数修正模块603还包括:In an embodiment of the present application, the mapping function correction module 603 further includes:
面积统计模块,设置为响应于所述第一目标图像数据中存在多个人脸数据,分别统计多个所述人脸数据的面积;an area statistics module, configured to count the areas of a plurality of the face data respectively in response to the existence of a plurality of face data in the first target image data;
人脸提取模块,设置为提取所述面积最大的n个所述人脸数据。A face extraction module, configured to extract the n pieces of face data with the largest area.
在本申请的一个实施例中,所述人脸皮肤检测模块包括:In an embodiment of the present application, the face skin detection module includes:
人脸数据收敛模块,设置为对所述第一目标图像数据中的人脸数据进行收敛,获得候选区域图像;a face data convergence module, configured to converge the face data in the first target image data to obtain a candidate area image;
候选检测模块,设置为基于颜色空间在所述候选区域图像中检测皮肤数据。A candidate detection module, configured to detect skin data in the candidate region image based on the color space.
在本申请的一个实施例中,所述人脸数据收敛模块包括:In an embodiment of the present application, the face data convergence module includes:
中心点确定模块,设置为响应于所述第一目标图像数据中的人脸数据以人脸框框定,确定所述人脸框的中心点;a center point determination module, configured to frame the face frame in response to the face data in the first target image data, and determine the center point of the face frame;
人脸框缩小模块,设置为将所述人脸框的中心点设置为候选区域图像的中心点,缩小所述人脸框的宽与高,作为候选区域图像的宽与高。The face frame reduction module is configured to set the center point of the face frame as the center point of the candidate area image, and reduce the width and height of the face frame as the width and height of the candidate area image.
在本申请的一个实施例中,所述色彩映射段修正模块包括:In an embodiment of the present application, the color map segment correction module includes:
第二色彩映射段收敛模块,设置为朝基于所述皮肤数据统计的所述色彩值收敛所述第二色彩映射段;A second color map segment convergence module configured to converge the second color map segment toward the color value based on the skin data statistics;
第一色彩映射段平移模块,设置为向靠近所述第二色彩映射段的方向平移 所述第一色彩映射段,直至所述第一色彩映射段接驳所述第二色彩映射段;a first color map segment translation module, configured to translate the first color map segment in a direction close to the second color map segment, until the first color map segment is connected to the second color map segment;
第三色彩映射段平移模块,设置为向靠近所述第二色彩映射段的方向平移所述第三色彩映射段,直至所述第三色彩映射段接驳所述第二色彩映射段。A third color mapping segment translation module is configured to translate the third color mapping segment in a direction close to the second color mapping segment until the third color mapping segment is connected to the second color mapping segment.
在本申请的一个实施例中,所述第二色彩映射段收敛模块包括:In an embodiment of the present application, the second color map segment convergence module includes:
目标长度确定模块,设置为确定目标长度,所述目标长度的小于所述第二色彩映射段的长度;a target length determination module, configured to determine a target length, the target length being less than the length of the second color map segment;
色彩映射段缩小模块,设置为以基于所述皮肤数据统计的所述色彩值作为中心点缩小所述第二色彩映射段,直至所述第二色彩映射段的长度与所述目标长度相等。A color map segment reduction module, configured to reduce the second color map segment with the color value based on the skin data statistics as a center point until the length of the second color map segment is equal to the target length.
在本申请的一个实施例中,所述目标长度确定模块包括:In an embodiment of the present application, the target length determination module includes:
基准长度确定模块,设置为确定基准长度,所述基准长度小于所述第二色彩映射段的长度;a reference length determination module, configured to determine a reference length, the reference length being less than the length of the second color mapping segment;
可调长度计算模块,设置为计算所述第二色彩映射段的长度与所述基准长度之间的差值,作为可调长度;An adjustable length calculation module, configured to calculate the difference between the length of the second color map segment and the reference length as an adjustable length;
修正系数计算模块,设置为将所述第二时间点与所述第一时间点之间的时间差映射为修正系数,所述修正系数与所述时间差正相关;a correction coefficient calculation module, configured to map the time difference between the second time point and the first time point as a correction coefficient, and the correction coefficient is positively correlated with the time difference;
修正长度计算模块,设置为计算所述可调长度与所述修正系数之间的乘积,作为修正长度;A correction length calculation module, configured to calculate the product between the adjustable length and the correction coefficient as the correction length;
目标长度计算模块,设置为计算所述基准长度与所述修正长度之间的和值,作为目标长度。The target length calculation module is configured to calculate the sum value between the reference length and the corrected length as the target length.
在本申请的一个实施例中,所述映射检测模块604包括:In an embodiment of the present application, the mapping detection module 604 includes:
色彩值查询模块,设置为查询所述第二目标图像数据中像素点的色彩值;a color value query module, configured to query the color value of a pixel in the second target image data;
候选概率映射模块,设置为将所述像素点的色彩值代入所述映射函数中,以映射为所述像素点在所述色彩值下属于皮肤数据的候选概率;A candidate probability mapping module, configured to substitute the color value of the pixel into the mapping function to map the pixel as a candidate probability that the pixel belongs to skin data under the color value;
目标概率计算模块,设置为基于所述候选概率计算所述像素点属于皮肤数据的目标概率。The target probability calculation module is configured to calculate the target probability that the pixel point belongs to the skin data based on the candidate probability.
在本申请的一个实施例中,所述候选概率映射模块包括:In an embodiment of the present application, the candidate probability mapping module includes:
蓝色概率映射模块,设置为将蓝色色度分量的色彩值代入所述蓝色色度分量对应的所述映射函数中,以映射为所述像素点在所述蓝色色度分量下属于皮肤数据的蓝色概率,作为候选概率;The blue probability mapping module is configured to substitute the color value of the blue chrominance component into the mapping function corresponding to the blue chrominance component, so as to map the pixel points to the skin data under the blue chrominance component. The blue probability, as the candidate probability;
红色概率映射模块,设置为将红色色度分量的色彩值代入所述红色色度分量对应的所述映射函数中,以映射为所述像素点在所述红色色度分量下属于皮 肤数据的红色概率,作为候选概率;A red probability mapping module, configured to substitute the color value of the red chromaticity component into the mapping function corresponding to the red chromaticity component, so as to map the pixel to the red color of the skin data under the red chromaticity component probability, as a candidate probability;
所述目标概率计算模块包括:The target probability calculation module includes:
概率乘积计算模块,设置为计算所述蓝色概率与所述红色概率之间的乘积,作为所述像素点属于皮肤数据的目标概率。The probability product calculation module is configured to calculate the product between the blue probability and the red probability as the target probability that the pixel belongs to the skin data.
在本申请的一个实施例中,还包括:In an embodiment of the present application, it also includes:
图像检测模块,设置为响应于在先未检测到人脸数据,基于颜色空间在图像数据中检测皮肤数据。An image detection module configured to detect skin data in the image data based on the color space in response to the previously undetected face data.
本申请实施例所提供的肤色检测装置可执行本申请任意实施例所提供的肤色检测方法,具备执行方法相应的功能模块和有益效果。The skin color detection apparatus provided by the embodiment of the present application can execute the skin color detection method provided by any embodiment of the present application, and has functional modules and beneficial effects corresponding to the execution method.
实施例三Embodiment 3
图7为本申请实施例三提供的一种移动终端的结构示意图。图7示出了适于用来实现本申请实施方式的示例性移动终端12的框图。图7显示的移动终端12仅仅是一个示例,不应对本申请实施例的功能和使用范围带来任何限制。FIG. 7 is a schematic structural diagram of a mobile terminal according to Embodiment 3 of the present application. FIG. 7 shows a block diagram of an exemplary mobile terminal 12 suitable for use in implementing embodiments of the present application. The mobile terminal 12 shown in FIG. 7 is only an example, and should not impose any limitations on the functions and scope of use of the embodiments of the present application.
如图7所示,移动终端12以通用计算设备的形式表现。移动终端12的组件可以包括但不限于:一个或者多个处理器或者处理单元16,系统存储器(也可记为内存)28,连接不同系统组件(包括系统存储器28和处理单元16)的总线18。As shown in FIG. 7, the mobile terminal 12 takes the form of a general-purpose computing device. Components of the mobile terminal 12 may include, but are not limited to, one or more processors or processing units 16, a system memory (also referred to as memory) 28, and a bus 18 connecting different system components (including the system memory 28 and the processing unit 16). .
总线18表示几类总线结构中的一种或多种,包括存储器总线或者存储器控制器,外围总线,图形加速端口,处理器或者使用多种总线结构中的任意总线结构的局域总线。举例来说,这些体系结构包括但不限于工业标准体系结构(ISA,Industry Standard Architecture)总线,微通道体系结构(MCA,Micro Channel Architecture)总线,增强型ISA总线、视频电子标准协会(VESA,Video Electronics Standards Association)局域总线以及外围组件互连(PCI,Peripheral Component Interconnect)总线。 Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, a graphics acceleration port, a processor, or a local bus using any of a variety of bus structures. For example, these architectures include, but are not limited to, Industry Standard Architecture (ISA, Industry Standard Architecture) bus, Micro Channel Architecture (MCA, Micro Channel Architecture) bus, enhanced ISA bus, Video Electronics Standards Association (VESA, Video Electronics Standards Association) local bus and Peripheral Component Interconnect (PCI, Peripheral Component Interconnect) bus.
移动终端12典型地包括多种计算机系统可读介质。这些介质可以是任何能够被移动终端12访问的可用介质,包括易失性和非易失性介质,可移动的和不可移动的介质。 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.
系统存储器28可以包括易失性存储器形式的计算机系统可读介质,例如随机存取存储器(RAM)30和/或高速缓存存储器32。移动终端12可以进一步包括其它可移动/不可移动的、易失性/非易失性计算机系统存储介质。仅作为举例,存储系统34可以用于读写不可移动的、非易失性磁介质(图7未显示,通常称为“硬盘驱动器”)。尽管图7中未示出,可以提供用于对可移动非易失性磁 盘(例如“软盘”)读写的磁盘驱动器,以及对可移动非易失性光盘(例如CD-ROM,DVD-ROM或者其它光介质)读写的光盘驱动器。在这些情况下,每个驱动器可以通过一个或者多个数据介质接口与总线18相连。存储器28可以包括至少一个程序产品,该程序产品具有一组(例如至少一个)程序模块,这些程序模块被配置以执行本申请各实施例的功能。 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. For example only, storage system 34 may be used to read and write to non-removable, non-volatile magnetic media (not shown in FIG. 7, commonly referred to as a "hard drive"). Although not shown in Figure 7, a disk drive for reading and writing to removable non-volatile magnetic disks (eg "floppy disks") and removable non-volatile optical disks (eg CD-ROM, DVD-ROM) may be provided or other optical media) to read and write optical drives. In these cases, each drive may be connected to bus 18 through one or more data media interfaces. Memory 28 may include at least one program product having a set (eg, at least one) of program modules configured to perform the functions of various embodiments of the present application.
具有一组(至少一个)程序模块42的程序/实用工具40,可以存储在例如存储器28中,这样的程序模块42包括但不限于操作系统、一个或者多个应用程序、其它程序模块以及程序数据,这些示例中的每一个或某种组合中可能包括网络环境的实现。程序模块42通常执行本申请所描述的实施例中的功能和/或方法。A program/utility 40 having a set (at least one) of program modules 42, which may be stored, for example, in 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 or some combination of these examples may include an implementation of a network environment. Program modules 42 generally perform the functions and/or methods of the embodiments described herein.
移动终端12也可以与一个或多个外部设备14(例如键盘、指向设备、显示器24等)通信,还可与一个或者多个使得用户能与该移动终端12交互的设备通信,和/或与使得该移动终端12能与一个或多个其它计算设备进行通信的任何设备(例如网卡,调制解调器等等)通信。这种通信可以通过输入/输出(I/O)接口22进行。并且,移动终端12还可以通过网络适配器20与一个或者多个网络(例如局域网(LAN,Local Area Network),广域网(WAN,Wide Area Network)和/或公共网络,例如因特网)通信。如图7所示,网络适配器20通过总线18与移动终端12的其它模块通信。应当明白,尽管图7中未示出,可以结合移动终端12使用其它硬件和/或软件模块,包括但不限于:微代码、设备驱动器、冗余处理单元、外部磁盘驱动阵列、RAID(Redundant Arrays of Independent Disks,磁盘阵列)系统、磁带驱动器以及数据备份存储系统等。The mobile terminal 12 may also communicate with one or more external devices 14 (eg, a keyboard, pointing device, display 24, etc.), may also communicate with one or more devices that enable a user to interact with the mobile terminal 12, and/or communicate with Any device (eg, network card, modem, etc.) that enables the mobile terminal 12 to communicate with one or more other computing devices. Such communication may take place through input/output (I/O) interface 22 . Moreover, the mobile terminal 12 can also communicate with one or more networks (such as a local area network (LAN, Local Area Network), a wide area network (WAN, Wide Area Network) and/or a public network, such as the Internet, through the network adapter 20. As shown in FIG. 7 , the network adapter 20 communicates with other modules of the mobile terminal 12 via the bus 18 . It should be understood that, although not shown in FIG. 7, 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 (Redundant Arrays) of Independent Disks, disk array) systems, tape drives, and data backup storage systems.
处理单元16通过运行存储在系统存储器28中的程序,从而执行各种功能应用以及数据处理,例如实现本申请实施例所提供的肤色检测方法。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 by the embodiments of the present application.
实施例四Embodiment 4
本申请实施例四还提供一种计算机可读存储介质,计算机可读存储介质上存储有计算机程序,该计算机程序被处理器执行时实现上述肤色检测方法的各个过程,且能达到相同的效果,为避免重复,这里不再赘述。The fourth embodiment of the present application also provides a computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, each process of the above-mentioned skin color detection method can be achieved, and the same effect can be achieved, In order to avoid repetition, details are not repeated here.
其中,计算机可读存储介质例如可以包括但不限于电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。计算机可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式计算机磁盘、硬盘、随机存取存储器(RAM,Random Access Memory)、只读存储器(ROM,Read-Only Memory)、可擦式可编程只读存储器(EPROM 或闪存)、光纤、便携式紧凑磁盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。在本文件中,计算机可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被指令执行系统、装置或者器件使用或者与其结合使用。Wherein, the computer-readable storage medium may include, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus or device, or any combination of the above. More specific examples (non-exhaustive list) of computer readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read only memory (ROM, Read-Only Memory), erasable programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable of the above The combination. In this document, a computer-readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
本申请实施例提出了一种肤色检测方法、装置、移动终端和存储介质,以解决如何在性能受限的情况下,兼顾肤色检测的实时性与精确度的问题。The embodiments of the present application propose a skin color detection method, device, mobile terminal, and storage medium, so as to solve the problem of how to take into account the real-time performance and accuracy of skin color detection under the condition of limited performance.
在本实施例中,采集视频数据,视频数据包括多帧图像数据,分别在多帧图像数据中检测人脸数据,若在第一目标图像数据中检测到人脸数据,则以人脸数据的色彩值作为先验知识修正映射函数,映射函数用于基于色彩值识别皮肤数据,第一目标图像数据为在第一时间点采集的图像数据,将第二目标图像数据的色彩值代入映射函数中,以在第二目标图像数据中检测皮肤数据,第二目标图像数据为在第二时间点采集的图像数据,视频数据具有连续性,因此,多帧图像数据之间的内容具有相关性,使得在先的图像数据可以作为在后的图像数据的先验知识,以人脸数据作为锚点可以捕捉到优质的皮肤数据,可以在当前的业务场景中对皮肤数据统计出较为准确的色彩值,以此自适应修正映射函数,可以提高映射函数在当前的业务场景中进行肤色检测的准确性,并且,人脸检测、统计皮肤数据的颜色值、映射函数的修正及其应用等操作均较为简单,计算量少、速度快、耗时短,在移动终端等设备性能受限的情况下,可实现实时对视频数据进行肤色检测。In this embodiment, video data is collected, and the video data includes multiple frames of image data, and face data is detected in the multiple frames of image data respectively. If face data is detected in the first target image data, the face data The color value is used as a priori knowledge to correct the mapping function, the mapping function is used to identify skin data based on the color value, the first target image data is the image data collected at the first time point, and the color value of the second target image data is substituted into the mapping function , in order to detect skin data in the second target image data, the second target image data is the image data collected at the second time point, and the video data has continuity, therefore, the content between multiple frames of image data has correlation, so that The previous image data can be used as the prior knowledge of the subsequent image data, and the face data can be used as an anchor to capture high-quality skin data. This adaptive modification of the mapping function can improve the accuracy of skin color detection performed by the mapping function in the current business scenario, and operations such as face detection, statistics of the color value of the skin data, correction of the mapping function and its application are relatively simple. , the calculation amount is small, the speed is fast, and the time-consuming is short. In the case of limited performance of mobile terminals and other equipment, the skin color detection of video data can be realized in real time.
在一实施例中,在提高肤色检测的准确性的情况下,可以排除一些与皮肤数据相似的数据,如头发、衣服、背景等,使得在后续美颜处理(如磨皮处理)中保护与皮肤数据相似的数据,减缓或避免与皮肤数据相似的数据因美颜处理(如磨皮处理)而导致清晰度下降的情况,从而保证美颜处理的质量。In one embodiment, under the condition of improving the accuracy of skin color detection, some data similar to skin data, such as hair, clothes, background, etc., can be excluded, so that in the subsequent beauty treatment (such as microdermabrasion), the The data similar to the skin data can slow down or avoid the situation that the data similar to the skin data will reduce the clarity caused by the beauty treatment (such as microdermabrasion), so as to ensure the quality of the beauty treatment.
本领域技术人员会理解,本申请不限于这里所述的特定实施例,对本领域技术人员来说能够进行各种变化、重新调整和替代而不会脱离本申请的保护范围。因此,虽然通过以上实施例对本申请进行了说明,但是本申请不仅仅限于以上实施例,在不脱离本发明构思的情况下,还可以包括更多其他等效实施例,而本申请的范围由所附的权利要求范围决定。Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and various changes, readjustments and substitutions can be made by those skilled in the art without departing from the protection scope of the present application. Therefore, although the present application has been described by the above embodiments, the present application is not limited to the above embodiments, and can also include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present application is defined by The appended claims determine the scope.

Claims (15)

  1. 一种肤色检测方法,包括:A skin color detection method, comprising:
    采集视频数据,所述视频数据包括多帧图像数据;collecting video data, the video data includes multiple frames of image data;
    分别在多帧所述图像数据中检测人脸数据;respectively detecting face data in multiple frames of the image data;
    响应于在第一目标图像数据中检测到人脸数据,以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,所述映射函数用于基于色彩值识别皮肤数据,所述第一目标图像数据为在第一时间点采集的图像数据;In response to detecting human face data in the first target image data, using the color value of the human face data in the first target image data as a priori knowledge, modifying a mapping function for identifying skin based on the color value data, the first target image data is image data collected at a first time point;
    将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,所述第二目标图像数据为在第二时间点采集的图像数据。Substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data, where the second target image data is image data collected at a second time point.
  2. 根据权利要求1所述的方法,其中,所述分别在多帧所述图像数据中检测人脸数据,包括:The method according to claim 1, wherein said detecting face data in multiple frames of said image data respectively comprises:
    调用摄像头提供的人脸检测接口,以请求在所述摄像头采集的多帧所述图像数据中检测人脸数据;calling the face detection interface provided by the camera to request to detect face data in the multiple frames of the image data collected by the camera;
    接收所述人脸检测接口返回的至少一个人脸框,所述人脸框用于框定人脸数据。At least one face frame returned by the face detection interface is received, and the face frame is used to frame face data.
  3. 根据权利要求1所述的方法,其中,所述以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,包括:The method according to claim 1, wherein the modifying the mapping function using the color value of the face data in the first target image data as a priori knowledge, comprises:
    确定映射函数,所述映射函数的横坐标为色彩值、纵坐标为当前数据属于皮肤数据的概率,所述映射函数包括依次连接的第一色彩映射段、第二色彩映射段、第三色彩映射段,所述第一色彩映射段中当前数据属于皮肤数据的概率从0上升至1,所述第二色彩映射段中当前数据属于皮肤数据的概率为1,所述第三色彩映射段中当前数据属于皮肤数据的概率从1下降至0;Determine a mapping function, the abscissa of the mapping function is the color value, and the ordinate is the probability that the current data belongs to the skin data, and the mapping function includes a first color map segment, a second color map segment, and a third color map connected in sequence segment, the probability that the current data in the first color mapping segment belongs to skin data increases from 0 to 1, the probability that the current data in the second color mapping segment belongs to skin data is 1, and the current data in the third color mapping segment The probability that the data belongs to skin data decreased from 1 to 0;
    基于颜色空间在所述第一目标图像数据中的人脸数据中检测皮肤数据;Detecting skin data in the face data in the first target image data based on the color space;
    对所述皮肤数据统计色彩值;Counting color values on the skin data;
    在所述映射函数所处坐标系的横轴上标记基于所述皮肤数据统计的所述色彩值;Marking the color value based on the skin data statistics on the horizontal axis of the coordinate system where the mapping function is located;
    在维持所述第一色彩映射段、所述第三色彩映射段的条件下,参考基于所述皮肤数据统计的所述色彩值缩小所述第二色彩映射段。On the condition that the first color map segment and the third color map segment are maintained, the second color map segment is reduced with reference to the color value based on the statistics of the skin data.
  4. 根据权利要求3所述的方法,其中,所述以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,还包括:The method according to claim 3, wherein the modifying the mapping function using the color value of the face data in the first target image data as a priori knowledge, further comprises:
    响应于所述第一目标图像数据中存在多个人脸数据,分别统计多个所述人脸数据的面积;In response to the existence of a plurality of face data in the first target image data, count the areas of the plurality of face data respectively;
    提取所述面积最大的n个所述人脸数据。Extracting the n pieces of the face data with the largest area.
  5. 根据权利要求3所述的方法,其中,所述基于颜色空间在所述第一目标图像数据中的人脸数据中检测皮肤数据,包括:The method according to claim 3, wherein the detecting skin data in the face data in the first target image data based on the color space comprises:
    对所述第一目标图像数据中的人脸数据进行收敛,获得候选区域图像;Converging the face data in the first target image data to obtain a candidate area image;
    基于颜色空间在所述候选区域图像中检测皮肤数据。Skin data is detected in the candidate region image based on a color space.
  6. 根据权利要求5所述的方法,其中,所述对所述第一目标图像数据中的人脸数据进行收敛,获得候选区域图像,包括:The method according to claim 5, wherein the converging the face data in the first target image data to obtain the candidate region image comprises:
    响应于所述第一目标图像数据中的人脸数据以人脸框框定,确定所述人脸框的中心点;In response to the face data in the first target image data being framed by a face frame, determining the center point of the face frame;
    将所述人脸框的中心点设置为候选区域图像的中心点,缩小所述人脸框的宽与高,作为候选区域图像的宽与高。The center point of the face frame is set as the center point of the candidate area image, and the width and height of the face frame are reduced as the width and height of the candidate area image.
  7. 根据权利要求3所述的方法,其中,所述在维持所述第一色彩映射段、所述第三色彩映射段的条件下,参考基于所述皮肤数据统计的所述色彩值缩小所述第二色彩映射段,包括:The method of claim 3 , wherein the first color map segment and the third color map segment are maintained, and the first color map segment is reduced with reference to the color value based on the skin data statistics. Two colormap segments, including:
    朝基于所述皮肤数据统计的所述色彩值收敛所述第二色彩映射段;Converging the second color map segment toward the color value based on the skin data statistics;
    向靠近所述第二色彩映射段的方向平移所述第一色彩映射段,直至所述第一色彩映射段接驳所述第二色彩映射段;Translating the first color map segment in a direction close to the second color map segment until the first color map segment joins the second color map segment;
    向靠近所述第二色彩映射段的方向平移所述第三色彩映射段,直至所述第三色彩映射段接驳所述第二色彩映射段。Translating the third color map segment in a direction close to the second color map segment until the third color map segment joins the second color map segment.
  8. 根据权利要求7所述的方法,其中,所述朝基于所述皮肤数据统计的所述色彩值收敛所述第二色彩映射段,包括:8. The method of claim 7, wherein the converging the second color map segment toward the color values based on the skin data statistics comprises:
    确定目标长度,所述目标长度的小于所述第二色彩映射段的长度;determining a target length, the target length being less than the length of the second color map segment;
    以基于所述皮肤数据统计的所述色彩值作为中心点缩小所述第二色彩映射段,直至所述第二色彩映射段的长度与所述目标长度相等。The second color map segment is reduced with the color value based on the skin data statistics as a center point until the length of the second color map segment is equal to the target length.
  9. 根据权利要求8所述的方法,其中,所述确定目标长度,包括:The method of claim 8, wherein the determining the target length comprises:
    确定基准长度,所述基准长度小于所述第二色彩映射段的长度;determining a reference length, the reference length being less than the length of the second color map segment;
    计算所述第二色彩映射段的长度与所述基准长度之间的差值,作为可调长度;Calculate the difference between the length of the second color map segment and the reference length as an adjustable length;
    将所述第二时间点与所述第一时间点之间的时间差映射为修正系数,所述修正系数与所述时间差正相关;mapping the time difference between the second time point and the first time point as a correction coefficient, and the correction coefficient is positively correlated with the time difference;
    计算所述可调长度与所述修正系数之间的乘积,作为修正长度;Calculate the product between the adjustable length and the correction coefficient as the correction length;
    计算所述基准长度与所述修正长度之间的和值,作为目标长度。The sum of the reference length and the correction length is calculated as the target length.
  10. 根据权利要求1-9任一项所述的方法,其中,所述将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,包括:The method according to any one of claims 1-9, wherein the substituting the color value of the second target image data into the mapping function to detect skin data in the second target image data comprises:
    查询所述第二目标图像数据中像素点的色彩值;query the color value of the pixel in the second target image data;
    将所述像素点的色彩值代入所述映射函数中,以映射出所述像素点在所述色彩值下属于皮肤数据的候选概率;Substitute the color value of the pixel into the mapping function to map out the candidate probability that the pixel belongs to skin data under the color value;
    基于所述候选概率计算所述像素点属于皮肤数据的目标概率。The target probability that the pixel point belongs to skin data is calculated based on the candidate probability.
  11. 根据权利要求10所述的方法,其中,所述将所述像素点的色彩值代入所述映射函数中,以映射出所述像素点在所述色彩值下属于皮肤数据的候选概率,包括:The method according to claim 10, wherein said substituting the color value of the pixel point into the mapping function to map out the candidate probability of the pixel point belonging to skin data under the color value, comprising:
    将蓝色色度分量的色彩值代入所述蓝色色度分量对应的所述映射函数中,以映射为所述像素点在所述蓝色色度分量下属于皮肤数据的蓝色概率,作为候选概率;Substitute the color value of the blue chromaticity component into the mapping function corresponding to the blue chromaticity component, so as to map the blue probability that the pixel belongs to the skin data under the blue chromaticity component, as a candidate probability;
    将红色色度分量的色彩值代入所述红色色度分量对应的所述映射函数中,以映射为所述像素点在所述红色色度分量下属于皮肤数据的红色概率,作为候选概率;Substitute the color value of the red chrominance component into the mapping function corresponding to the red chrominance component, so as to map to the red probability that the pixel point belongs to the skin data under the red chrominance component, as a candidate probability;
    所述基于所述候选概率计算所述像素点属于皮肤数据的目标概率,包括:The calculating, based on the candidate probability, the target probability that the pixel belongs to the skin data, including:
    计算所述蓝色概率与所述红色概率之间的乘积,作为所述像素点属于皮肤数据的目标概率。The product between the blue probability and the red probability is calculated as the target probability that the pixel belongs to the skin data.
  12. 根据权利要求1-9任一项所述的方法,还包括:The method according to any one of claims 1-9, further comprising:
    响应于在先未检测到人脸数据,基于颜色空间在图像数据中检测皮肤数据。Skin data is detected in the image data based on the color space in response to no prior detection of face data.
  13. 一种肤色检测装置,包括:A skin color detection device, comprising:
    视频数据采集模块,设置为采集视频数据,所述视频数据包括多帧图像数据;a video data acquisition module, configured to collect video data, the video data including multiple frames of image data;
    人脸数据检测模块,设置为分别在多帧所述图像数据中检测人脸数据;a face data detection module, configured to detect face data in multiple frames of the image data respectively;
    映射函数修正模块,设置为响应于在第一目标图像数据中检测到人脸数据,以所述第一目标图像数据中的人脸数据的色彩值作为先验知识修正映射函数,所述映射函数用于基于色彩值识别皮肤数据,所述第一目标图像数据为在第一时间点采集的图像数据;The mapping function correction module is configured to modify the mapping function with the color value of the face data in the first target image data as a priori knowledge in response to detecting the face data in the first target image data, and the mapping function For identifying skin data based on color values, the first target image data is image data collected at a first time point;
    映射检测模块,设置为将第二目标图像数据的色彩值代入所述映射函数中,以在所述第二目标图像数据中检测皮肤数据,所述第二目标图像数据为在第二时间点采集的图像数据。A mapping detection module, configured to substitute the color value of the second target image data into the mapping function to detect skin data in the second target image data, the second target image data being collected at a second time point image data.
  14. 一种移动终端,所述移动终端包括:A mobile terminal, the mobile terminal includes:
    至少一个处理器;at least one processor;
    存储器,设置为存储至少一个程序,memory, arranged to store at least one program,
    当所述至少一个程序被所述至少一个处理器执行,使得所述至少一个处理器实现如权利要求1-12中任一项所述的肤色检测方法。When the at least one program is executed by the at least one processor, the at least one processor implements the skin color detection method according to any one of claims 1-12.
  15. 一种计算机可读存储介质,所述计算机可读存储介质上存储计算机程序,所述计算机程序被处理器执行时实现如权利要求1-12中任一项所述的肤色检测方法。A computer-readable storage medium, storing a computer program on the computer-readable storage medium, and when the computer program is executed by a processor, implements the skin color detection method according to any one of claims 1-12.
PCT/CN2021/141248 2020-12-25 2021-12-24 Skin color detection method and apparatus, and mobile terminal and storage medium WO2022135574A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202011563923.XA CN112712569B (en) 2020-12-25 2020-12-25 Skin color detection method and device, mobile terminal and storage medium
CN202011563923.X 2020-12-25

Publications (1)

Publication Number Publication Date
WO2022135574A1 true WO2022135574A1 (en) 2022-06-30

Family

ID=75546610

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2021/141248 WO2022135574A1 (en) 2020-12-25 2021-12-24 Skin color detection method and apparatus, and mobile terminal and storage medium

Country Status (2)

Country Link
CN (1) CN112712569B (en)
WO (1) WO2022135574A1 (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112712569B (en) * 2020-12-25 2023-12-12 百果园技术(新加坡)有限公司 Skin color detection method and device, mobile terminal and storage medium
CN113888543B (en) * 2021-08-20 2024-03-19 北京达佳互联信息技术有限公司 Skin color segmentation method and device, electronic equipment and storage medium
CN113554007B (en) * 2021-09-18 2022-01-11 上海齐感电子信息科技有限公司 Face frame calculation method and calculation system

Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060088209A1 (en) * 2004-10-21 2006-04-27 Microsoft Corporation Video image quality
CN102968623A (en) * 2012-12-07 2013-03-13 上海电机学院 System and method for detecting colors of skin
CN103455790A (en) * 2013-06-24 2013-12-18 厦门美图网科技有限公司 Skin identification method based on skin color model
CN104392211A (en) * 2014-11-12 2015-03-04 厦门美图网科技有限公司 Skin recognition method based on saliency detection
CN106650583A (en) * 2016-09-28 2017-05-10 广东欧珀移动通信有限公司 Face detection method, face detection device and terminal equipment
CN108388885A (en) * 2018-03-16 2018-08-10 南京邮电大学 The identification in real time of more people's features towards large-scale live scene and automatic screenshot method
CN112712569A (en) * 2020-12-25 2021-04-27 百果园技术(新加坡)有限公司 Skin color detection method, device, mobile terminal and storage medium

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10491895B2 (en) * 2016-05-23 2019-11-26 Intel Corporation Fast and robust human skin tone region detection for improved video coding
CN107292228A (en) * 2017-05-05 2017-10-24 珠海数字动力科技股份有限公司 A kind of method for accelerating face recognition search speed
CN107172354B (en) * 2017-06-21 2020-04-03 深圳市万普拉斯科技有限公司 Video processing method and device, electronic equipment and storage medium
CN107392166A (en) * 2017-07-31 2017-11-24 北京小米移动软件有限公司 Skin color detection method, device and computer-readable recording medium
CN109063580A (en) * 2018-07-09 2018-12-21 北京达佳互联信息技术有限公司 Face identification method, device, electronic equipment and storage medium
CN111047517B (en) * 2018-10-11 2022-09-30 展讯通信(上海)有限公司 Skin color adjusting method and device and readable storage medium
CN110706295A (en) * 2019-09-10 2020-01-17 中国平安人寿保险股份有限公司 Face detection method, face detection device and computer-readable storage medium
CN111291638A (en) * 2020-01-19 2020-06-16 上海云从汇临人工智能科技有限公司 Object comparison method, system, equipment and medium

Patent Citations (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060088209A1 (en) * 2004-10-21 2006-04-27 Microsoft Corporation Video image quality
CN102968623A (en) * 2012-12-07 2013-03-13 上海电机学院 System and method for detecting colors of skin
CN103455790A (en) * 2013-06-24 2013-12-18 厦门美图网科技有限公司 Skin identification method based on skin color model
CN104392211A (en) * 2014-11-12 2015-03-04 厦门美图网科技有限公司 Skin recognition method based on saliency detection
CN106650583A (en) * 2016-09-28 2017-05-10 广东欧珀移动通信有限公司 Face detection method, face detection device and terminal equipment
CN108388885A (en) * 2018-03-16 2018-08-10 南京邮电大学 The identification in real time of more people's features towards large-scale live scene and automatic screenshot method
CN112712569A (en) * 2020-12-25 2021-04-27 百果园技术(新加坡)有限公司 Skin color detection method, device, mobile terminal and storage medium

Also Published As

Publication number Publication date
CN112712569A (en) 2021-04-27
CN112712569B (en) 2023-12-12

Similar Documents

Publication Publication Date Title
JP7110502B2 (en) Image Background Subtraction Using Depth
WO2022135574A1 (en) Skin color detection method and apparatus, and mobile terminal and storage medium
CN109952594B (en) Image processing method, device, terminal and storage medium
WO2020063744A1 (en) Face detection method and device, service processing method, terminal device, and storage medium
US9864901B2 (en) Feature detection and masking in images based on color distributions
US8983152B2 (en) Image masks for face-related selection and processing in images
WO2022135579A1 (en) Skin color detection method and device, mobile terminal, and storage medium
WO2022156640A1 (en) Gaze correction method and apparatus for image, electronic device, computer-readable storage medium, and computer program product
US9053573B2 (en) Systems and methods for generating a virtual camera viewpoint for an image
WO2022199583A1 (en) Image processing method and apparatus, computer device, and storage medium
WO2016165060A1 (en) Skin detection based on online discriminative modeling
WO2022161009A1 (en) Image processing method and apparatus, and storage medium and terminal
CN112614060A (en) Method and device for rendering human face image hair, electronic equipment and medium
WO2021115242A1 (en) Super-resolution image processing method and related apparatus
CN111242074B (en) Certificate photo background replacement method based on image processing
CN109033935B (en) Head-up line detection method and device
WO2023045183A1 (en) Image processing
CN107153806B (en) Face detection method and device
CN111369478A (en) Face image enhancement method and device, computer equipment and storage medium
CN114187166A (en) Image processing method, intelligent terminal and storage medium
CN112597911A (en) Buffing processing method and device, mobile terminal and storage medium
CN113743243A (en) Face beautifying method based on deep learning
CN111915529A (en) Video dim light enhancement method and device, mobile terminal and storage medium
WO2022001630A1 (en) Method and system for capturing at least one smart media
WO2024051289A1 (en) Image background replacement method and related device

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 21909569

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 21909569

Country of ref document: EP

Kind code of ref document: A1