RedApparat / FaceDetector

Face detection for your Android app
Apache License 2.0
1.17k stars 197 forks source link

Use Google Vision API w/ Fotoapparat #15

Open koenschauwaert opened 6 years ago

koenschauwaert commented 6 years ago

I want to use Fotoapparat in combination with the Google Vision API and work with landmarks to detect faces, eyes, nose and mouth; like this:

Landmarks on faces

The Fotoapparat FaceDetector only shows a square around faces.

Can I use your library together with Google's API? If so: how?

ghost commented 6 years ago

The Fotoapparat FaceDetector uses class FaceDetector(a class in library) to do face detection actually. The FaceDetector.detectFaces will return the detected faces location. You can use below code to do this:

FaceDetector mFaceDetector = FaceDetector.create(context);
List<Rectangle> detectedFaceAreas = mFaceDetector.detectFaces(nv21Image, width, height, 0);

Now you get the location of detected faces. And then you can use Google Vision API to detect the face item location. Lastly, just draw the face with rectangle and face item with number on your app(in bitmap or overlay).

Note: The nv21Image is the byte array stores the image nv21 format data.