为什么 Android 的 FaceDetectionListener 未检测到眼睛坐标
Why are eye coordinates not detected with FaceDetectionListener for Android
我正在开发一个 Android 应用程序,该应用程序使用 Android 的 FaceDetection API 进行面部和眼睛检测。我能够检测并在面部周围绘制矩形,但是我无法弄清楚为什么我所有的眼睛坐标都设置为 (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,因为我已经可以检测到人脸(如果可能)。感谢您的帮助。
并非所有设备都支持所有面部特征。
作为 leftEye 和大多数其他字段的 documentation 状态:
This is an optional field, may not be supported on all devices. If not supported, the value will always be set to null. The optional fields are supported as a set. Either they are all valid, or none of them are.
如果设备支持人脸检测,则只保证包含 Face.rect 和 Face.score 字段。
我正在开发一个 Android 应用程序,该应用程序使用 Android 的 FaceDetection API 进行面部和眼睛检测。我能够检测并在面部周围绘制矩形,但是我无法弄清楚为什么我所有的眼睛坐标都设置为 (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,因为我已经可以检测到人脸(如果可能)。感谢您的帮助。
并非所有设备都支持所有面部特征。
作为 leftEye 和大多数其他字段的 documentation 状态:
This is an optional field, may not be supported on all devices. If not supported, the value will always be set to null. The optional fields are supported as a set. Either they are all valid, or none of them are.
如果设备支持人脸检测,则只保证包含 Face.rect 和 Face.score 字段。