5
votes

I am developing a winForm c# program for smile detection with a webcam by using EmguCV library. I use some haarcascade_smile xml file to do it successfully. However, a detection error occures in some cases: Sometimes the mouth shape line is wrongly identified as the mouth.

I have a new idea, which is to look for the color red in addition to the original xml file to improve mouth detection, and attempt to reduce the error rate.

Does anyone know of a command or library that can be used to detect red color ?

Many thanks :)

var smiles = grayframe.DetectHaarCascade(_smiles, 
                                         ScaleIncreaseRate, 
                                         MinNeighbors, 
                                         HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, 
                                         new Size(WindowsSize, WindowsSize))[0];
if (smiles.Length == 0)
{
    // Number of smile face detected is 0
}
else
{

}
2
Thanks for your ans. But I want to detect the red color rather than analyze the detected image pixel. - user1994617

2 Answers

0
votes

With Bitmap.GetPixel() you can get the color of the pixel. You then have to determine whether or not that color is considered red. This is a challenge that is not very difficult to solve, but may require some research.

For example, looking at HTML color tables and their codes, you can already determine the following characteristics for most red colors:

  • The R element of the RGB value is higher than G and B.
  • The G element is lower than B most of the time, sometimes equal, but never higher.
  • For a high R value, the higher the B value, the more purple it becomes; what is acceptable and what not?

Et cetera, et cetera. You can create a class which defines these rules and check if a color is considered red for you particular use.

Since you are aiming for a narrowed range of red colors, you can specialize the class even more and get more precise answers.

0
votes

Bitmap.Getpixel() would get you the color of a specified pixel.