Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android face detection - Vision API or Camera API

I need a simple way of detecting faces in my Camera app. All I care about is a callback saying that a face was detected in certain place or with coordinates where it was detected on the preview. I've noticed that there seem to be several face detection APIs - in Google Play services and in both legacy and camera2 APIs. Which one should I use for the simple requirement described above?

like image 912
vkislicins Avatar asked Jan 31 '16 14:01

vkislicins


1 Answers

The legacy version is older, and has much lower accuracy than the new Google Play services API.

The camera2 API depends upon face detection capabilities built into the camera hardware, so it isn't necessarily available on all devices. I have not done an exhaustive comparison, but I think that the accuracy is also lower than that of the new Google Play services API.

See this tutorial for using the Google Play services API for tracking faces in the camera preview:

https://developers.google.com/vision/face-tracker-tutorial

The callback that you'd define would be a subclass of Tracker, similar to the GraphicFaceTracker in the tutorial.

If you don't need to track faces or you have other code that manages the camera, you can call the face detector directly like this:

Frame frame = Frame.Builder().setBitmap(myBitmap).build();
SparseArray<Face> faces = faceDetector.detect(frame);

See for information here:

https://developers.google.com/android/reference/com/google/android/gms/vision/package-summary

like image 173
pm0733464 Avatar answered Oct 05 '22 03:10

pm0733464