【问题标题】:How to detect coordinates of left and right eye using android face detection如何使用android人脸检测检测左右眼坐标
【发布时间】:2016-03-17 03:01:09
【问题描述】:

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

【问题讨论】:

标签: android face-detection eye-detection


【解决方案1】:

使用移动视觉 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

【讨论】:

  • 谢谢。但我在这段代码中遇到问题 FaceDetector detection = new FaceDetector.Builder(context) .setTrackingEnabled(false) .setLandmarkType(FaceDetector.ALL_LANDMARKS) .build(); android studio 无法识别“Builder(context)”,所以我该怎么办。
  • 查看设置 Google Play 服务的答案:stackoverflow.com/questions/16624827/…。添加到构建文件的依赖项是“compile 'com.google.android.gms:play-services:7.8.+'”
  • 您好,我仍然无法使用移动视觉。我安装了:Android 支持存储库、Google Play 服务、Google 存储库。我添加了最新的依赖项 'com.google.android.gms:play-services:8.3.0' 仍然说使用“Builder”时找不到类
  • 确保您对 FaceDetector 类的导入是正确的:“import com.google.android.gms.vision.face.FaceDetector;”
  • 那是个错误!!。非常感谢,过去 3 天让我发疯......
猜你喜欢
  • 2013-05-15
  • 1970-01-01
  • 2015-04-23
  • 2013-09-24
  • 2019-06-18
  • 1970-01-01
  • 2020-06-28
  • 2019-12-01
  • 2021-08-27
相关资源
最近更新 更多