nenadmarkus / picojs

A face detection library in 200 lines of JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Detect tilted faces

ozomer opened this issue · comments

Hi,
I need whether the user's head is tilted to the left, the right, or is more-or-less balanced. I'm using a simple algorithm that checks the angle between the a line that connects between the eyes to the x-axis (thinking in 2d only - I'm not looking for the 3d head-pose).
I noticed that the face detection is not so good when the face is tilted. I need to support a tilt of up to ~45 degrees. Do you have any suggestion for how to support that? Maybe I could run the the algorithm multiple times, on several rotation angles of the image?
I hope there is a simple solution because this library is very light and I don't want to switch to the heavier face-api.

Solved it by creating 3 canvases, rotated by the angles -10, 0, 10, and picking the result with the best score.
In webcam.html line 85 instead of handling all the results with score above 50.0, I picked only the result with the highest score for each canvas, and the picked the result with the highest score between the canvases.
Also, reducing the constant 50.0 lower-limit to 20.0 improved the detection when the face is tilted.