IOS, determining the distance between the face of the user and the device using the front camera

Now I am developing an application for checking the human eye by reading letters and symbols, for this the user needs to maintain a distance of 2 feet from his device. Therefore, I need to determine the distance between the human face and the ios device using the front camera.

Regarding this, I have some doubts to clarify

  • To detect a human face, I planned to use the core-image infrastructure. In this case, can a human face be detected in the background without a camera user interface?

  • To calculate the distance, I planned to use the formula below

    distance = focal length * real height of object * camera frame height /(image height * sensor height)

  • And I saw several applications in the application store that use the rear camera to calculate the distance between the device and the object. Therefore, I have a bit of confusion as to whether it is possible to work with the front camera.

Please help me how to do this or tell me your suggestion whether this is correct or not.

+4
source share

All Articles