androidface-detectioneye-detection

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


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.


Solution

  • 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