Android detect skin color from live camera preview

I'm trying to build an application that can detect the skin color of different parts of the skin (hands, forehead, cheeks) regardless of the lighting conditions. I can use this project to do this, but it doesn't consider the lighting conditions. This is one of the iPhone apps

resolvent:

If you want to do some image processing yourself, I suggest creating a histogram for each face area of the image. As long as opencv can detect the face, you should be able to normalize the histogram in the area and obtain the color value of the normalized version

Perhaps you want to normalize all channels (R, G, b) separately to reduce the influence of color light

Read more about histograms here: https://en.wikipedia.org/wiki/Histogram

When you use this method, it is strongly recommended that you create a histogram with a face as the whole area

[Edit]

Now that I know what you're trying to do, I think you can do the following:

As you can see, the user needs to tap the camera back and forth. Since the image is illuminated by the indicator on the back of the phone, the histogram is indeed created by the creator of the application. However, it is not from different pixels, but from different samples of the same pixel with different lighting levels

When you are very close to the skin, the camera will show you an almost white image, that is, the histogram calculation "fixed point" you want

Although I will not display the direct code, I will try to explain the mathematical model:

>Define a "focus" area in the image. This area is the area you want to consider when calculating the histogram. All other areas at the edge will be ignored. > take some samples (e.g. 3 seconds, 10 samples per second = 30 samples) > create a histogram for each sample and add them together:

>For each luminance value (up to 256), calculate the number of pixels that match the luminance value, add all samples > find the maximum and minimum values with at least the threshold number (you can use the working range if you like) and call them histlow and histhigh > recalculate each pixel so that the pixel = (pixel histlow) / (histhigh histlow) *255 > limit pixel values to 0-255 > take the average color value of pixels in a narrow range (for example, the maximum number of samples)

If you don't know how to multiply or add colors in RGB, you should start with another problem

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>