Now that we have an understanding of how and why we do the grayscaling we can now continue to detect face, and eyes using some of the pre-compiled functions in OpenCV, so how do we do that?
Well the nice people at Intel have created a few .xml files containing OpenCV data structures which can be compared to number of scenarios using the CasacadeClassifier function (the definition is available here).
But for the sake of "it" I will quote it here, "The classifier outputs a “1” if the region is likely to show the object (i.e., face/car), and “0” otherwise. To search for the object in the whole image one can move the search window across the image and check every location using the classifier. The classifier is designed so that it can be easily “resized” in order to be able to find the objects of interest at different sizes, which is more efficient than resizing the image itself. So, to find an object of an unknown size in the image the scan procedure should be done several times at different scales.
The word “cascade” in the classifier name means that the resultant classifier consists of several simpler classifiers (stages) that are applied subsequently to a region of interest until at some stage the candidate is rejected or all the stages are passed"
So simple put you get the data from the .xml file, in this case "haarcascade_frontalface_alt.xml" and "haarcascade_eye_tree_eyeglasses.xml"
which can be called using the following method:
String face = "haarcascade_frontalface_alt.xml";
String eyes = "haarcascade_eye_tree_eyeglasses.xml";
So now the program will compare the matrix you gave and try and match the data structures and if they match it will show tell the programmer that yes that is true but in order to make sure that you, the user can see it you need to apply the same method used in highlight different colours (in one of the previous blog entries) to show where the face and eyes may be.
The result:
Well the nice people at Intel have created a few .xml files containing OpenCV data structures which can be compared to number of scenarios using the CasacadeClassifier function (the definition is available here).
But for the sake of "it" I will quote it here, "The classifier outputs a “1” if the region is likely to show the object (i.e., face/car), and “0” otherwise. To search for the object in the whole image one can move the search window across the image and check every location using the classifier. The classifier is designed so that it can be easily “resized” in order to be able to find the objects of interest at different sizes, which is more efficient than resizing the image itself. So, to find an object of an unknown size in the image the scan procedure should be done several times at different scales.
The word “cascade” in the classifier name means that the resultant classifier consists of several simpler classifiers (stages) that are applied subsequently to a region of interest until at some stage the candidate is rejected or all the stages are passed"
So simple put you get the data from the .xml file, in this case "haarcascade_frontalface_alt.xml" and "haarcascade_eye_tree_eyeglasses.xml"
which can be called using the following method:
String face = "haarcascade_frontalface_alt.xml";
String eyes = "haarcascade_eye_tree_eyeglasses.xml";
So now the program will compare the matrix you gave and try and match the data structures and if they match it will show tell the programmer that yes that is true but in order to make sure that you, the user can see it you need to apply the same method used in highlight different colours (in one of the previous blog entries) to show where the face and eyes may be.
The result:
![]() |
| Note: my colleague's eyes are not highlighted, this is not because of a lack of feature but because of a low grade camera |





