Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Opencv Haarlike eye-detection

Tags:

opencv

I have run this Opencv Haarlike eye-detection from this link with C++ visual studio 2010

http://docs.opencv.org/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html

And my camera isn't running smooth. So I delete for-loop(of this code) out and running only camera. The camera running smooth.

The question is if I want to modified this code to detect eye and face.

How can I modified this code to running in smooth?

please show the example to modified this code.

Best thank and sorry for bad language Chairat(Thailand)

like image 295
zlatan14 Avatar asked Jan 24 '26 20:01

zlatan14


1 Answers

Generally it's not a trivial question, but a basic idea (which i used for my BSc thesis) is quite simple. It's not the entire solution i've used, but this should be enough right now, if not - let me know i will write more about it.
For first frame:

  1. Find face (i've used haarcascade_frontalface_default.xml cascade, but you may try with different) and remember its position.
  2. Within face rectangle find eyes (use Haar cascade for eye pair (haarcascade_mcs_eyepair_big.xml), not for one eye - it's much faster and simpler solution) and remember position.

For other frames:

  1. Expand (for about 20-50%) rectangle in which you have found face recently.
  2. Find face in expanded rectangle.
  3. Find eyes within face. If you haven't found face in previous step, you may try to search for eyes in expanded rectangle of previous eyes position.



Few important things:

  • while searching use CV_HAAR_FIND_BIGGEST_OBJECT flag.
  • convert frame to grayscale before searching - during searching opencv uses only grayscale images so it will be faster to convert whole image once than converting whole image (for first search - face) and than converting only rectangle containing face (for second search - eyes)
  • some people say that equalizing histogram before searching may improve results, i'm not sure about that, but if you want you may try this - use equalizeHist function. Note that it works only on grayscale images.
like image 181
cyriel Avatar answered Jan 29 '26 19:01

cyriel