Quickstart-android: Battery heat due to constant running of image processing

Created on 18 Oct 2018  路  10Comments  路  Source: firebase/quickstart-android

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 ?

mlkit

All 10 comments

@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?

@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 !

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 ?

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

@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.

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.

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

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.

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

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

HanSeungBeom picture HanSeungBeom  路  3Comments

rosariopfernandes picture rosariopfernandes  路  6Comments

the-dagger picture the-dagger  路  4Comments

DenLangeKilde picture DenLangeKilde  路  5Comments

shivamsriva31093 picture shivamsriva31093  路  3Comments