I am trying to draw rectangle on face image. I have its eye location and nose location co-ordinates. So how can I do that?
Ex.
I have one image. I have its respected eye cordinates:
- Nose:- 351 186
- Left Eye:-379 138
- Right Eye:- 309 149
I want to draw rectangle covering face image. How can I do that?
I want to know how haarcascade do that.
What measurement it takes to compute rectangle.
Your coordinate system is 0,0 at upper right of view with negative coordinates on X-axis to the left and positive coordinates on Y-axis going down.
Sometimes the head will be rotated slightly or titled away slightly and so you have to use the measurements you have to try to determine that factor.
Here is a useful explanation of the proportions of the human face: http://www.artyfactory.com/portraits/pencil-portraits/proportions-of-a-head.html
Using these proportions, you should be able to calculate the appropriate sized square or rectangle that will cover the entire face including the forehead and chin to the left and right ears or just cover the eyes, nose and mouth area (depending upon what you want).
Once you have calculated the correct size of the rectangle/square, you would would need to calculate the placement coordinates. You don't want to simply center align the rectangle over both eyes because if the head is rotated slightly (profile view with both eyes visible) your rectangle wouldn't center properly.