Search code examples
androidface-detectiongoogle-vision

FaceDetector.Builder().build(getApplicationContext()) gives me errors


I'm trying to make an Android app that takes one picture when it detects a face. I was trying to follow Google's Mobile Vision FaceDetector Pipeline but I can't get past

FaceDetector faceDetector = new FaceDetector.Builder().build(getApplicationContext());

Builder is bright red and says cannot resolve symbol Builder.

I've checked my Gradle files and my Android Manifest, and they're the same as Google's.

I can't figure out what to do next.

Also, if someone could point me to a good tutorial on FaceDetection that uses the Camera2 API, I'd be really grateful.


Solution

  • Note that there is an old legacy FaceDetector class in Android:

    android.media.FaceDetector
    

    This is NOT what you want to use. The class for the newer mobile vision API is here:

    com.google.android.gms.vision.face.FaceDetector