googlesamples / android-vision

Deprecated: The Mobile Vision API is now a part of ML Kit: Check out this repo:
https://github.com/firebase/quickstart-android/tree/master/mlkit
Apache License 2.0
2.92k stars 1.73k forks source link

Can I get the actual face image from the API? #64

Open GavinChengGitHub opened 8 years ago

GavinChengGitHub commented 8 years ago

When a face is detected, can I somehow get the cropped face (bitmap/image) from the API? Thanks!

pm0733464 commented 8 years ago

See the answer given here:

http://stackoverflow.com/questions/35399545/android-camerav2-face-detection-and-saving-image/35440718#35440718

AndroidDeveloperLB commented 8 years ago

https://search-codelabs.appspot.com/codelabs/face-detection#3

for(int i=0; i<faces.size(); i++) {
  Face thisFace = faces.valueAt(i);
  float x1 = thisFace.getPosition().x;
  float y1 = thisFace.getPosition().y;
  float x2 = x1 + thisFace.getWidth();
  float y2 = y1 + thisFace.getHeight();
  tempCanvas.drawRoundRect(new RectF(x1, y1, x2, y2), 2, 2, myRectPaint);
}
myImageView.setImageDrawable(new BitmapDrawable(getResources(),tempBitmap));