【发布时间】:2017-07-27 03:01:31
【问题描述】:
我正在开发一个使用 FaceDetection API for Android 进行面部和眼睛检测的 Android 应用。我能够检测并在面部周围绘制矩形,但是我无法弄清楚为什么我的所有眼睛坐标都设置为(0,0)。
阅读本文 documentation,我看到并非所有设备都支持眼睛检测,但它说 Point 对象设置为 null,而不是 (0,0),所以我不明白这里发生了什么。
这是我的 FaceDetectionListener:
private List<Rect> faceRects;
private Point leftEye;
private Point rightEye;
@Override
public void onFaceDetection(Camera.Face[] faces, Camera camera) {
if (faces.length > 0) {
faceRects = new ArrayList<Rect>();
for (int i = 0; i < faces.length; i++) {
int left = faces[i].rect.left;
int right = faces[i].rect.right;
int top = faces[i].rect.top;
int bottom = faces[i].rect.bottom;
Rect uRect = new Rect(left, top, right, bottom);
faceRects.add(uRect);
leftEye = faces[i].leftEye; //***THIS IS (0,0) EVEN WHEN FACE IS DETECTED
rightEye = faces[i].rightEye;
}
}
}
为什么我的眼睛坐标点设置为 (0,0)。我在 Galaxy S7 上进行测试,我很难相信它不支持眼睛检测。我也愿意使用 OpenCV 解决这个问题,但我宁愿坚持使用 Android SDK,因为我已经可以检测到人脸(如果可能的话)。感谢您的帮助。
【问题讨论】:
标签: java android face-detection