header photo

Level 3d - Add Parameter Tuning Features To Face Detection

January 19, 2012

TO DO:
NOT ALL FACES DETECTED? OR FACE DETECTION IS NOT UP TO YOUR REQUIREMENTS?
THEN ADD THE FEATURES(CODE) AS EXPLAINED IN THIS TUTORIAL, TO IMPROVE face detection according to your requirements by "Varying"/"Tuning" the parameter values of DetectHaarCascade(), by user input and see the difference in results!

LEARNING OBJECTIVE:

FINAL OUTPUT:

-------------------------------------------------------------------------------------------------------------------------------------------------------------------
We'll be adding this feature to the application we last modified in Level3b - Implement Face Detection. But in order to know what are these 'parameters' and what values to give them, please see Level3c - How To Improve Face Detection.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------
 STEP-WISE TUTORIAL:
-------------------------------------------------------------------------------------------------------------------------------------------------------------------

STEP 1: Add components to take user input for parameter values.AND declare global variables that will hold these input values and will replace the 'hard-coded' argument values in the DetectHaarCascade().

1.1) Add 2 comboBoxes for parameters that take a defined set of values! (i.e the minimum Neighbors and Scale Increase Rate.) and add a textBox for the parameter that can take many values (i.e the window size). Add a label on the form for each of these components, to show what parameter they identify.

1.2)Set the Name property of these 3 new components.

1.3)Declare 3 corresponding global variables in the code for these input parameter components, and give these global variables some "default" values. as i have.



STEP 2: Before calling the HaarClassifier, Assign the input from parameter components to their corresponding global variables.

NOTE:  
SomeDataType MyVar = SomeDataType.Parse(componentName.Text);

Above is the syntax to convert a windows forms' component's value to the corresponding value of MyVar of type SomeDataType. i have used this in the code to assign values to the global variables.



STEP 3: Replace the 'hard-coded' argument values in DetectHaarCascade() with the global variables:



STEP 4: Set the default 'set of values' of parameter components.
4.1) Set the Items property of the comboboxes as shown in video, to add the available value options.

4.2) TAKE SAFETY MEASURE -  Set the Text property of each of the parameter component as follows:
Minimum neighbors = 2
Scale Increase Rate = 1.1
Windows Size = 25 (CORRECTION: its marked 3 in the video, sorry that was a MISTAKE! please set it to  25 )

STEP 5 - Start Testing! vary the parameter values(tuning) and see the difference in Detection Results!
NOTE:
i have used a saved/loaded image (courtesy of google) for the testing. not a live image.

 

here's what the text file in the video says for this STEP:
oh it missed a face when i increased the scale rate! see? now you see? the detection gets minutely faster but more faces are missed! again!

ah! the picture quality was so good, that min.neighbor of 4(the highest) gets the strictest
detection! with one face lost in detection!

NOTE 1: im sorry, i made a mistake! the winsize was set to 3! it should've been set to 23 before debugging!

Anyhow, you saw that increasing the win size meant "look for bigger faces". since the size we specified(60) was way bigger than the faces in our image, so it didn't detect any face! 

Well i hope you learned something from this :)

see you again!
 -----------------------------------------------------------------------------------------------------------------------------
DOWNLOAD SOURCE CODE (VS2010)


-------------------------------------------------------------------------------------------------------------------------------------------------------------- 
IF YOU LIKE THIS TUTORIAL. PLEASE LEAVE A COMMENT BELOW :)

BUT ASK YOUR QUESTIONS ONLY AT THE FOLLOWING LINK. QUESTIONS IN COMMENTS WILL BE IGNORED.

SEE YOU IN THE NEXT TUTORIAL :)

Go Back

thnxxxxxxxxxxxx very very much for your greaaaaaaat effort :)

Thank you again for the brilliant work. More grease to your elbow.
Magical..

i want to ask you .... if i want to detect a face in another position .... not frontal .... how can i do this ???
and thxxx alot you are such a fantastic programmer :)



Comment