How to detect coordinates of left and right eye using android face detection

泪湿孤枕 提交于 2021-01-28 04:33:57

问题


Hello I am new to android. I want to detect the coordinates of left and right eye along with hairs in an image. In this link it shows that what are the methods to detect eyes that but I am not able to implement these methods. Also I want to detect the hairs in the image so how can I do that.


回答1:


With the mobile vision API, left and right eyes can be detected as facial landmarks. See the tutorial for detecting landmarks here:

https://developers.google.com/vision/detect-faces-tutorial

and the API enumerating landmark types here:

https://developers.google.com/android/reference/com/google/android/gms/vision/face/Landmark

A slight modification to the code from the tutorial is all that is required to find the eyes specifically:

for (int i = 0; i < faces.size(); ++i) {
  Face face = faces.valueAt(i);
  for (Landmark landmark : face.getLandmarks()) {
    switch (landmark.getType()) {
      case Landmark.LEFT_EYE:
        // use landmark.getPosition() as the left eye position


来源:https://stackoverflow.com/questions/34219463/how-to-detect-coordinates-of-left-and-right-eye-using-android-face-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!