项目作者: aryarohit07

项目描述 :
A memory efficient Android image transformation library providing cropping above Face Detection (Face Centering) for Glide.
高级语言: Java
项目地址: git://github.com/aryarohit07/GlideFaceDetectionTransformation.git


Glide face detection transformation

Download
Android Arsenal

An Android image transformation library providing cropping above Face Detection for Glide

Are you using Picasso? PicassoFaceDetectionTransformation.

Are you using Fresco? FrescoFaceDetectionProcessor.

Results

Original Image

original image 1

Results after cropping

resulting image 1

Original Image

original image 2

Results after cropping

resulting image 2

Original Image

original image 3

Results after cropping

resulting image 3

Original Image

original image 4

Results after cropping

resulting image 4

You can read more on my Medium article.

How to use it?

STEP 1:

Grab via Gradle

  1. repositories {
  2. jcenter()
  3. }
  4. dependencies {
  5. compile 'com.github.aryarohit07:glide-facedetection-transformation:0.3.0'
  6. }

Or via Maven

  1. <dependency>
  2. <groupId>com.github.aryarohit07</groupId>
  3. <artifactId>glide-facedetection-transformation</artifactId>
  4. <version>0.3.0</version>
  5. </dependency>

STEP 2:

Initialize the detector (May be in onCreate() method)

  1. GlideFaceDetector.initialize(context);

STEP 3:

Set glide transform

  1. Glide.with(yourFragment)
  2. .load(yourUrl)
  3. .transform(new FaceCenterCrop())
  4. .into(yourView);

STEP 4:

The face detector uses native resources in order to do detection. For this reason, it is necessary to release the detector instance once it is no longer needed (May be in onDestory() method)

  1. GlideFaceDetector.releaseDetector();

Note: If no face is detected, it will fallback to CENTER CROP.

Library dependencies:

  1. com.google.android.gms:play-services-vision:9.4.0
  2. com.github.bumptech.glide:glide:3.7.0

If you liked it, please Star it.

TODO

  • Making it generic for any point.

Performance:
Time taken to detect faces in the original image.

width height time taken(ms)
640 360 60-150
900 600 100-200
1280 720 250-350
1920 1080 350-400
2048 1536 500-550

License

  1. Copyright 2016 Rohit Arya
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.