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

Battery heat due to constant running of image processing #703

Closed
mourad-jemail opened this issue Oct 18, 2018 · 10 comments
Closed

Battery heat due to constant running of image processing #703

mourad-jemail opened this issue Oct 18, 2018 · 10 comments

Comments

@mourad-jemail
Copy link

mourad-jemail commented Oct 18, 2018

I ran this project but after few seconds of using camera in LivePreviewActivity, the battery started to heat. When I debugged the project, I figured out it's the constant call for image processing line of code that is causing the problem in CameraSource class :

frameProcessor.process();

Any solution to avoid battery heat and power drain ?

@samtstern
Copy link
Contributor

samtstern commented Oct 18, 2018

@mouradjemail what kind of device are you using? It's possible that the device just can't handle every-frame detection without getting overloaded.

Also this quickstart probably does not represent the best or most optimized camera code as I'm not an expert on that, instead we are just trying to show use of the MLKit APIs.

In a real app you may have better luck using an established library like camerakit-android (https://github.com/CameraKit/camerakit-android) rather than our CameraSource class.

@gkaldev any thoughts?

@mourad-jemail
Copy link
Author

@samtstern I tried it on Google Pixel and Huawei Y6 II so far and I noticed the same issue.
Yeah, I already thought about using camera kit API but then I didn't cause I thought using this code sample would help me save time integrating camera, especially considering that code samples provided by Google are usually presented with best practice code integration.
Any way, if you know any good code example which integrates both camerakit API and MLKit APIs, please let me know. Thanks !

@samtstern
Copy link
Contributor

That's really interesting, I am running the same sample on my Google Pixel (1st generation) and there's no noticeable heat up.

@the-dagger got any good MLKit + CameraKit (or other library) code samples or codelabs you'd like yo share with @mouradjemail ?

@mourad-jemail
Copy link
Author

PS: the heat starts only after I launch the camera preview to scan some text. When I show the logcat I see this log printed repeatedly :
MIDemoApp:CameraSource : Process an image

@the-dagger
Copy link
Contributor

@samtstern You bet I do!
@mouradjemail Hi there!
Please try out the following samples and lmk if you still face the same issues.

MLKit : https://github.com/the-dagger/MLKitAndroid
CodeLab on MLKit that uses a different library than CameraKit: https://codelabs.developers.google.com/codelabs/mlkit-image-objects-android/
PokeDex app that uses MLKit with a custom Model:
https://github.com/the-dagger/Pokidex

I personally haven't faced such issue, but do let me know if you encounter the same thing in the above-mentioned repos.

@mourad-jemail
Copy link
Author

Thank you @samtstern and @the-dagger , I really appreciate your help. I'll try the links suggested by @the-dagger then I'll give you my feedback.

@the-dagger
Copy link
Contributor

Hi @mouradjemail Any updates on this one?
Did the samples provided by me work well?

@mourad-jemail
Copy link
Author

Hello @the-dagger , I tried the MLKitAndroid sample and I got the same problem. Actually, battery heat is caused by the fact of trying to recognize text using a live camera preview. After all, it seems normal to me since the algorithm of live text recognition comes inside a while(true) block which results in too much CPU work.

@samtstern
Copy link
Contributor

For what it's worth I got my Pixel device pretty hot with the samples as well.

@samtstern
Copy link
Contributor

I am going to track this improvement and a bunch of others in #703

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

No branches or pull requests

3 participants