Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get The Face bitmap from face detector #167

Closed
tperl opened this issue Dec 19, 2016 · 11 comments
Closed

Get The Face bitmap from face detector #167

tperl opened this issue Dec 19, 2016 · 11 comments

Comments

@tperl
Copy link

tperl commented Dec 19, 2016

Hi,

In the Face class documentation it gives API for getting all sorts of landmarks of the face, i.e eyes, nose, rotation, location in the frame.

If I want to use the whole face cropped out of the frame is there a way to do so from the API?

I am struggling in doing this from the frame itself, because the detector is connected to the camera preview without any access from the user to the preview frames, it also skips frames for performance.

How can I for example in FaceGraphic draw method - before I draw a circle around the face, get the entire face from the frame? and send it somewhere else?

is this possible?

@pm0733464
Copy link
Contributor

@tperl
Copy link
Author

tperl commented Dec 23, 2016

The link helps me get the "frame" but not its bitmap, I want to get the real frame, like I would from a matrix in openCV implementation, a databuffer would also suffice.

@rahulkulhalli
Copy link

rahulkulhalli commented Feb 3, 2017

Yes, it's pretty simple to do so.

Assuming you've initialized your frame and loaded the full image bitmap into it, this is what I'd normally do:

SparseArray<Face> detectedFaces = detector.detect(frame);
for(int i=0;i<detectedFaces.size();i++){          //can't use for-each loops for SparseArrays
    Face face = detectedFaces.valueAt(i);
    //get it's coordinates
    Bitmap faceBitmap = Bitmap.createBitmap(bitmap, (int) face.getPosition().x, (int) face.getPosition().y, (int) face.getWidth(), (int) face.getHeight());
    //Do whatever you want with this cropped Bitmap
}

@jagdeesh94
Copy link

Could you please tell about the bitmap in the first argument of createBitmap.Where did it come from?Is that an empty bitmap?

@liuyl
Copy link
Contributor

liuyl commented Apr 8, 2017

frame.getBitmap() returns the bitmap.

@liuyl liuyl closed this as completed Apr 8, 2017
@sumitatflo
Copy link

sumitatflo commented Apr 25, 2017

@liuyl @rahulkulhalli Could you please elaborate on the approach you mentioned? I always get a black render on the imageView I set the face on. Most probably it's the wrong Frame that I am setting.
@jagdeesh94 @tperl Were you able to find a working solution to this?

@bako-ak
Copy link

bako-ak commented Feb 3, 2018

sorry for my English :), you can see an example using "takePicture", after the capture of the image are cropped the face and passed mainFragment.
https://github.com/bako-ak/face-detection

@jagdeesh94
Copy link

@bako-ak ,thanks for your input dude.Could you tell me where is the "takePicture" method that you are referring?.

@bako-ak
Copy link

bako-ak commented Feb 6, 2018

@jagdeesh94 in a branch "develop" https://github.com/bako-ak/face-detection/blob/develop/app/src/main/java/kz/bako/facedetection/face/FaceFragment.kt
the line 39 is called when you click the button, after pressing the method calls "onPictureTaken", then get the face and pass back as a result.

@manuja96
Copy link

manuja96 commented Jun 7, 2018

@rahul its great and working but i want multiple faces in multiple imageview,any solution please?send me on manujagourav@gmail.com

@tush23
Copy link

tush23 commented Aug 26, 2019

Can anyone pleaae help me regarding same issue??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants