我正在使用getIsLeftEyeOpenProbability
frommobile vision API
来知道眼睛是否睁开。然而,奇怪的事情发生了,我总是得到概率,-1
即使眼睛是睁开的。
这是代码:
FaceDetector faceDetector = new FaceDetector.Builder(getApplicationContext())
.setTrackingEnabled(false)
.setLandmarkType(FaceDetector.ALL_LANDMARKS)
.build();
Frame frame = new Frame.Builder().setBitmap(obtainedBitmap).build();
SparseArray < Face > facesForLandmarks = faceDetector.detect(frame);
faceDetector.release();
Thread homeSwipeThread;
for (int a = 0; a < facesForLandmarks.size(); a++) {
Face thisFace = facesForLandmarks.valueAt(a);
List < Landmark > landmarks = thisFace.getLandmarks();
for (int b = 0; b < landmarks.size(); b++) {
if (landmarks.get(b).getType() == landmarks.get(b).LEFT_EYE) {
leftEye = new Point(landmarks.get(b).getPosition().x, landmarks.get(b).getPosition().y - 3);
} else if (landmarks.get(b).getType() == landmarks.get(b).RIGHT_EYE) {
rightEye = new Point(landmarks.get(b).getPosition().x, landmarks.get(b).getPosition().y - 3);
} //end else if.
} //end inner
//for every detected face check eyes probability:
if (thisFace.getIsLeftEyeOpenProbability() <= 0.1) {
//some code
}
}
为什么会发生这种情况,我该如何解决?