justadudewhohacks / face-api.js

JavaScript API for face detection and face recognition in the browser and nodejs with tensorflow.js
MIT License
16.52k stars 3.68k forks source link

The distance between the eyes #614

Open smety opened 4 years ago

smety commented 4 years ago

Hello, thank you to the authors for this nice library.

Is it possible to calculate the distance between the eyes (pupils) in centimeters?

We are trying to use this library in healthcare to detect squinting.

Thank you very much

Bluebie commented 4 years ago

this would be quite complex with a regular webcam. The web browser will have great difficulty figuring out the camera properties like focal length, sensor size, etc, as well as accurately estimating how far the user's face is from the camera. It has no information to detect the difference between a small head and a far away head accurately.

To achieve something like this, I think you would need to have the user wear something that provides a reference scale, like a set of eyeglasses that have tracking dots a known distance apart. Then you could measure the distance between the trackers, and scale the distance between the eye pupils to a relative amount within that scale.

If you will only be running the software in a situation where the user's face is a known distance from the camera, using a known camera (i.e. a workstation PC with special equipment, or a standard issue smartphone) you might be able to achieve something decent without a reference scale, but I think it will be difficult to do well.

If it was easy to measure IPD in real measurements using a regular webcam, the online eyeglasses companies that have AR eyeglasses try on features would surely be doing it.

smety commented 4 years ago

@Bluebie ok, thank you :)