Git Product home page Git Product logo

Comments (7)

aryarohit07 avatar aryarohit07 commented on May 27, 2024

If you have got RuntimeException with this message Initialize GlideFaceDetector by calling GlideFaceDetector.initialize(context)., it means you have not initialized the GlideFaceDetector before calling FaceCenterCrop().

Also, if you have released the detector by calling GlideFaceDetector.releaseDetector(); then you will have to re-initialize the detector.

Please add some code for better debugging the problem.

from glidefacedetectiontransformation.

 avatar commented on May 27, 2024

I have a recyclerView which loads images with glide. I have initialized GlideFaceDetector in my onCreate() method. Released it in the onDestroy() method and no where else. The exception occurs only when i open a detail of the image and close it and try to scroll the recyclerView again.

I have even tried calling GlideFaceDetector.initialize(context) inside onResume() method. But still the same error. Its a common setup with a recyclerView and ListViewHolder to open up an activity on click. Nothing extra in the code to be shared here.

from glidefacedetectiontransformation.

aryarohit07 avatar aryarohit07 commented on May 27, 2024

Are you using the recyclerView inside a fragment? And is the detail of the image also a fragment?

from glidefacedetectiontransformation.

 avatar commented on May 27, 2024

It is a single activity without fragments anywhere in it. The activity houses the recyclerView and the recyclerView uses a normal view which has this image and a textview. Typical setup.

There is no issue with launching this activity with the recyclerView using FaceCenterCrop for the first time. It only happens when you start another activity from it and return back to it and scroll the recyclerView which causes the onBindViewHolder to call Glide to load the next image to the viewHolder which causes the crash since the FaceCenterCrop() Transformation does not seem to keep the GlideFaceDetector.initialize(context) alive between activity switches. That will be my guess to whats happening here.

And Thanks for your quick replies Rohit.

from glidefacedetectiontransformation.

aryarohit07 avatar aryarohit07 commented on May 27, 2024

Are you releasing the detector in the image detail (second) activity? If yes, then that might be the cause of the crash because GlideFaceDetector maintains a singleton instance and you should release the detector only when you are done with it. Else you will have to re-initialize the GlideFaceDetector to use again.

from glidefacedetectiontransformation.

 avatar commented on May 27, 2024

Thanks Rohit. That seems to solve the problem.
But it gets hard to maintain this behaviour when you have to check whether to release the GlideFaceDetector or not in that activity as it could be called from many places within the app wherein I may not be initializing GlideFaceDetector in the activity that calls this detail activity. But anyway some extras with the intent passed to open the detail activity should work for now.

Kudos!

from glidefacedetectiontransformation.

aryarohit07 avatar aryarohit07 commented on May 27, 2024

Yes @jishincreo , I agree with you.

Just treat the GlideFaceDetector as a singleton instance (which actually is right now). Will try to improve it's lifecycle in further releases.

from glidefacedetectiontransformation.

Related Issues (8)

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.