如何使用android人脸检测检测左右眼坐标

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

你好,我是 android 的新手。我想检测图像中左右眼的坐标以及毛发。 在此 link 中,它显示了检测眼睛的方法是什么,但我无法实现这些方法。 另外我想检测图像中的毛发,我该怎么做。

使用移动视觉API,可以将左眼和右眼检测为面部标志。请在此处查看地标检测教程:

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

和 API 在此处枚举地标类型:

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

只需对教程中的代码稍作修改即可专门找到眼睛:

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