- Mastering OpenCV 4
- Roy Shilkrot David Millán Escrivá
- 551字
- 2021-07-02 14:47:36
Skin detection algorithm
There are many different techniques used for detecting skin regions, from simple color thresholds using RGB (short for Red-Green-Blue) or HSV (short for Hue-Saturation-Brightness) values, or color histogram calculation and re-projection, to complex machine learning algorithms of mixture models that need camera calibration in the CIELab color space, offline training with many sample faces, and so on. But even the complex methods don't necessarily work robustly across various camera and lighting conditions and skin types. Since we want our skin detection to run on an embedded device, without any calibration or training, and we are just using skin detection for a fun image filter; it is sufficient for us to use a simple skin detection method. However, the color responses from the tiny camera sensor in the Raspberry Pi Camera Module tend to vary significantly, and we want to support skin detection for people of any skin color but without any calibration, so we need something more robust than simple color thresholds.
For example, a simple HSV skin detector can treat any pixel as skin if its hue color is fairly red, saturation is fairly high but not extremely high, and its brightness is not too dark or extremely bright. But cameras in mobile phones or Raspberry Pi Camera Modules often have bad white balancing; therefore, a person's skin might look slightly blue instead of red, for instance, and this would be a major problem for simple HSV thresholding.
A more robust solution is to perform face detection with a Haar or LBP cascade classifier (shown in Chapter 5, Face Detection and Recognition with the DNN Module), then look at the range of colors for the pixels in the middle of the detected face, since you know that those pixels should be skin pixels of the actual person. You could then scan the whole image or nearby region for pixels of a similar color as the center of the face. This has the advantage that it is very likely to find at least some of the true skin region of any detected person, no matter what their skin color is or even if their skin appears somewhat blueish or reddish in the camera image.
Unfortunately, face detection using cascade classifiers is quite slow on current embedded devices, so that method might be less ideal for some real-time embedded applications. On the other hand, we can take advantage of the fact that for mobile apps and some embedded systems, it can be expected that the user will be facing the camera directly from a very close distance, so it can be reasonable to ask the user to place their face at a specific location and distance, rather than try to detect the location and size of their face. This is the basis of many mobile phone apps, where the app asks the user to place their face at a certain position or perhaps to manually drag points on the screen to show where the corners of their face are in a photo. So, let's simply draw the outline of a face in the center of the screen, and ask the user to move their face to the position and size shown.
- GeoServer Cookbook
- JMeter 性能測試實戰(zhàn)(第2版)
- VSTO開發(fā)入門教程
- Python神經(jīng)網(wǎng)絡項目實戰(zhàn)
- Visual C
- Securing WebLogic Server 12c
- 琢石成器:Windows環(huán)境下32位匯編語言程序設計
- 大模型RAG實戰(zhàn):RAG原理、應用與系統(tǒng)構(gòu)建
- 計算機應用基礎案例教程
- Spring MVC+MyBatis開發(fā)從入門到項目實踐(超值版)
- Python從入門到精通(第3版)
- SpringBoot從零開始學(視頻教學版)
- Instant GLEW
- Elasticsearch搜索引擎構(gòu)建入門與實戰(zhàn)
- Effective C++:改善程序與設計的55個具體做法(第三版)中文版(雙色)