Coder Social home page Coder Social logo

aryarohit07 / glidefacedetectiontransformation Goto Github PK

View Code? Open in Web Editor NEW
359.0 13.0 59.0 522 KB

A memory efficient Android image transformation library providing cropping above Face Detection (Face Centering) for Glide.

Java 100.00%
face-detection detect-faces glide android vision-api

glidefacedetectiontransformation's Introduction

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

repositories {
    jcenter()
}
dependencies {
    compile 'com.github.aryarohit07:glide-facedetection-transformation:0.3.0'
}

Or via Maven

<dependency>
  <groupId>com.github.aryarohit07</groupId>
  <artifactId>glide-facedetection-transformation</artifactId>
  <version>0.3.0</version>
</dependency>

STEP 2:

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

GlideFaceDetector.initialize(context);

STEP 3:

Set glide transform

Glide.with(yourFragment)
    .load(yourUrl)
    .transform(new FaceCenterCrop())
    .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)

GlideFaceDetector.releaseDetector();

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

Library dependencies:

com.google.android.gms:play-services-vision:9.4.0
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

Copyright 2016 Rohit Arya

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

glidefacedetectiontransformation's People

Contributors

aryarohit07 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

glidefacedetectiontransformation's Issues

Image gets pixelated

Hello Rohit,

Thanks for this amazing library. Great work. I'm using your library to show image thumbnails in a recycler view. The images appear to be pixelated. Viewing the image thumbnail without adding this library does not pixelate the image.

Thanks!!

Throws RuntimeExeption: Initialize GlideFaceDetector

I have GlideFaceDetector.initialize(context) in the onCreate(). when opening an activity and coming back to the one using GlideFaceDetecor inside a RecyclerView, when scrolled, results in a crash with the above message.

FaceAware Imageview

I am looking for face Aware Image-view. Instead of cropping Image or simply center crop scale type of Imageview, the face should detect in image-view and adjust face to center of Image-view.
As your library crop the picture i want to do it without cropping picture.

I got Library in IOS but not getting anything in Android.
https://github.com/BeauNouvelle/FaceAware

The second scenario what does this library do if image have 3 faces?
Can anyone help me out? Thank You.

Is there any way to cache Face transformation data

I have to apply face detection on hundreds of images. This increases the time it takes to load these images. Is there any way I can cache the data of these images so that while scrolling or when loading the same images again it will load them instantly. Any kind of help will be appreciated. Thankyou for making such an amazing library.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.