Question

I am using opencv and c++. When I use Haarcascade with the haarcascade_frontalface_alt2.xml file,it detects only the face and not the ears. I need the face as well as the ears in one image. Can anyone suggest a method for that please? Thanks

Was it helpful?

Solution

The cascade was trained for faces and not ears, so what you are seeing is "normal".

  • If you want detect faces that include ears also, then you can simply expand the face rectangle by some percentage of their width in order to retain them in the crop;
  • or if you want to really only detect the ears, then you have to train your own cascade. Like for the eyes, you wold need to apply face detection first in order to reduce the number of false positives. Here is a guide on how to train a cascade to help you.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top