Android Question new Face API from Mobile Vision APIs

Elton Leung

Member
Licensed User
Longtime User
I have been using B4A for two months to prototype an app. It is a front facing camera app that needed to detect a face of the user (not recognize). I am using the CameraEX Module and added the face detection code from the following thread:

https://www.b4x.com/android/forum/threads/facedetectionlistener-callback-for-the-camera.38439/

Thing works ok until I move on to second phase, and needed to know the location of the features on the face, Eyes and Nose to be exact. I realize the face detection function from CameraEX could never provide these features and always returns NULL (on my Samsung Note 4).

I could use those online Face detection engines like Face++ but it is slow and cause privacy issue.

I just found Google Play Services 7.8 is providing a new Mobile Vision APIs with new Face API that is exactly what I needed. Can someone show me how to make use of these API with CameraEX? or will we see a module from Erel? Thanks.

https://developers.google.com/vision/face-detection-concepts
http://android-developers.blogspot.hk/2015/08/face-detection-in-google-play-services.html?m=1

image00.png


Elton
 

Elton Leung

Member
Licensed User
Longtime User
There aren't any reply, so I guess not everyone is excited about the new Face detection api as I do.

Instead of warping the API, can I take the function out from the sample code from below blog and put it in mine as inline Java? Please kindly show me how it can be done? Thanks!!!!!!

http://www.sitepoint.com/face-detection-in-android-with-google-play-services/

B4X:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    InputStream stream = getResources().openRawResource(R.raw.image01);
    Bitmap bitmap = BitmapFactory.decodeStream(stream);

    FaceDetector detector = new FaceDetector.Builder(getApplicationContext())
            .setTrackingEnabled(false)
            .build();

    // Create a frame from the bitmap and run face detection on the frame.
    Frame frame = new Frame.Builder().setBitmap(bitmap).build();
    SparseArray<Face> faces = detector.detect(frame);

    TextView faceCountView = (TextView) findViewById(R.id.face_count);
    faceCountView.setText(faces.size() + " faces detected");

    detector.release();

}
 
Upvote 0

Johan Schoeman

Expert
Licensed User
Longtime User
There aren't any reply, so I guess not everyone is excited about the new Face detection api as I do.

Instead of warping the API, can I take the function out from the sample code from below blog and put it in mine as inline Java? Please kindly show me how it can be done? Thanks!!!!!!

http://www.sitepoint.com/face-detection-in-android-with-google-play-services/

B4X:
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    InputStream stream = getResources().openRawResource(R.raw.image01);
    Bitmap bitmap = BitmapFactory.decodeStream(stream);

    FaceDetector detector = new FaceDetector.Builder(getApplicationContext())
            .setTrackingEnabled(false)
            .build();

    // Create a frame from the bitmap and run face detection on the frame.
    Frame frame = new Frame.Builder().setBitmap(bitmap).build();
    SparseArray<Face> faces = detector.detect(frame);

    TextView faceCountView = (TextView) findViewById(R.id.face_count);
    faceCountView.setText(faces.size() + " faces detected");

    detector.release();

}
See here https://www.b4x.com/android/forum/t...p-photo-using-google-mobile-vision-api.66469/
 
Upvote 0
Top