I am using Google Firebase's ML Kit to detect facial contours of images captured from the phone camera. However, it doesn't actually detect any faces. I've verified that the image was captured and saved properly from the camera by displaying the image in an ImageView. I also made sure to add
<meta-data android:name="com.google.android.gms.vision.DEPENDENCIES" android:value="face"/>
to AndroidManifest.xml and
implementation 'com.google.firebase:firebase-ml-vision:24.0.1'
implementation 'com.google.firebase:firebase-ml-vision-face-model:19.0.0'
to the app's build.gradle.
Here's the Firebase code:
FirebaseApp.initializeApp(context);
FirebaseVisionFaceDetectorOptions realTimeOpts =
new FirebaseVisionFaceDetectorOptions.Builder()
.setPerformanceMode(FirebaseVisionFaceDetectorOptions.ACCURATE)
.setContourMode(FirebaseVisionFaceDetectorOptions.ALL_CONTOURS)
.build();
fbImage = FirebaseVisionImage.fromBitmap(portrait);
FirebaseVisionFaceDetector detector = FirebaseVision.getInstance()
.getVisionFaceDetector(realTimeOpts);
Task<List<FirebaseVisionFace>> result =
detector.detectInImage(fbImage)
.addOnSuccessListener(
new OnSuccessListener<List<FirebaseVisionFace>>() {
@Override
public void onSuccess(List<FirebaseVisionFace> faces) {
Log.d(TAG, "No. Faces Detected: " + faces.size());
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Log.d(TAG, e.getMessage());
}
});
Does anyone know why this might not be detecting anything?