Search code examples
androidandroid-cameraandroid-camera2

Android camera preview vs background service


If I run an image processing app on Android, which will be better in terms of memory/cpu usage and heating issue?

  1. Run camera with the preview.
  2. Run camera in a background service. This says background service takes up a lot of memory( I used to think opposite ).

The reason I ask this is because I want to run the app 24/7, but I'm not sure which approach will be better with my purpose. I did test my app running camera with the preview and it stop due to heat after like 1 week.

Thanks.


Solution

  • The screen uses a lot of power, so leave it off if at all possible.

    The camera API itself doesn't care if you're in a foreground app or in a background service, but the more simultaneous outputs you request, the higher the power consumption will likely be. Similarly, the higher the output resolutions you ask for are, the higher the power consumption.

    You can have a foreground app with no preview, if you're using camera2; even with camera1, you can just add a dummy SurfaceTexture member to your activity/etc and set it as the preview target, so that you don't pay the cost of actual GPU activity.

    That still has the overhead of the camera API pushing pointless images to that SurfaceTexture, which you can only avoid with camera2.