Please provide more informations:
- Which cascade file are you using?
- What is the height and width of small_img?
About your code:
- You are using
nested_cascade
variable without initializing it.
Generally - try to use haarcascade_mcs_eyepair_big.xml
file from openCV with this parameters: (image, cascade, storage, 1.1, 3, 0, cvSize()) or even with smaller value of scaleFactor parameter.
I have done something similar during writing my BSc Thesis (Eyetracking system) and ended with quite easy solution. At the beginning i was trying to find inside face all 'objects' which can be eye and then decide which one is left eye and which one is right, but now i don't think it's a good solution.
Finally i decided to try to search for both eyes (pair - haarcascade_mcs_eyepair_big.xml
file from opencv) at once inside face (haarcascade_frontalface_default.xml
) and i find out that it's much better solution. It's faster, less complicated (you don't have to decide which object is the one you are looking for - it can be quite complicated if you try to have ragard previous positions of eyes and few other things) and easier to implement.
The accuracy was good enough for me and speed was quite high (whole system - about 10-25fps - it depends on few things). If you want to use your code for real-time eye detection i can give you few more details about optimization.